Commit Graph

851 Commits

Author SHA1 Message Date
9046b12f92 ReadFileFlags on linux minor fix
Add ignoring EINTR to syscall, set O_NOATIME on open, ignore
ENOTTY error (unsupported ioctl) to avoid massive spam for
non-exceptional failure on nonsupporting file systems
2023-10-06 15:47:50 -05:00
95ba772e2d Fix hardlink to symlink naming bug
When creating cloned entries of hardlinked symlinks we have to
preserve the target link data in the entry obviously.
2023-10-06 06:03:58 -05:00
e791bc1f9b Split out xattr and flags routines to new files 2023-10-06 06:03:57 -05:00
fd0f544c04 Cleanup some of the unix code and don't pass ptr to iface to GetOwner
Don't bother using checked type assertion for stat since we are
guarded by specific build configuration, we should know the
correct type, and if not, panicing is fine.

Despite syscall being deprecated a decade ago, we still need it
for FileInfo and sys/windows still calls it as well.
2023-10-06 05:57:08 -05:00
84822200ed Fix some deprecated functions in windows code 2023-10-06 05:57:08 -05:00
9f28a6900d Break up Restore options into struct 2023-10-06 05:57:08 -05:00
42ee20a9e1 Improve error handling and setting of xattr and file flags
- Improve error handling of file flags and xattrs. You now get warnings
- file flags on *BSD/Darwin use a mask and combine with the user/superuser
mask to prevent spurious warnings. The mask is not yet implemented as
a preference
- error handling/report for reading special files
- bump to go 1.20 for errors.Join
2023-10-06 05:57:02 -05:00
7df1ba5d82 RestoreMetadata improved error messages 2023-10-05 21:39:41 -05:00
60870cdabd Remove unnecessary fileInfo indirection (it's already interface) 2023-10-05 21:28:36 -05:00
1a2896ca8e Remove obsolete fileEncoder 2023-10-05 16:41:16 -05:00
52e511d5f3 Set file attributes before setting mode and owner. 2023-10-05 16:30:55 -05:00
1e045c2320 update readme 2023-10-05 13:20:59 -05:00
381d4a7159 Factor out hard link code for cross platform build
Move system specific code out of entry so the build continues to work on
Windows. Hard links are not currently supported on Windows, the behavior
is a no-op.
2023-10-05 12:00:30 -05:00
c782def49b Fix and reorganize for build for FreeBSD
- the xattr handling of namespaces is different on BSD with the
xattr package, the user namespace is implicit
- Don't backup/exclude files with flag nodump on BSD/Darwin
2023-10-04 23:55:30 -05:00
f931d3e9f1 Don't rewrite existing special file 2023-10-04 22:58:36 -05:00
7843df9584 update readme 2023-10-04 19:49:24 -05:00
3b50b7ec05 Rename hardlink to hard link (two words) 2023-10-04 13:37:26 -05:00
e5a72ddf4f minor: missing variable assignment in CheckSnapshot, struct-tag 2023-10-04 13:37:26 -05:00
de2a5c5fd9 fix broken tests 2023-10-04 13:37:26 -05:00
bdbd75f88c Fix formatting of diagnostic some diagnostic messages 2023-10-04 13:37:26 -05:00
ab74d19d2b Cleanup hardlinking code
This moves special file link data to the chunk fields like symlink
hardlinks.
2023-10-04 13:37:22 -05:00
9755b666b3 tweak the symlink hardlink chunk ids 2023-10-04 04:09:38 -05:00
28efe91c3f Support backup of sockets
This only works on Linux. Darwin does not allow mknod of a socket.
Have not tested BSD.
v3.2.2-ix
2023-10-04 02:53:48 -05:00
73ca9794ab gofmt some files 2023-10-04 02:53:48 -05:00
70ea4d3acf Fix handling of hardlinks and special files
Also, don't attempt xattr ops on special files on the BSD likes.

TODO: Should have a way to allow restore without special files,
otherwise very cumbersome for a regular user.
2023-10-04 02:53:48 -05:00
a1a3f3d4cb Support for hardlinks to symlinks
This is a specialized use-case, but it is indeed possible to do this
and can be used if xattrs are attached to the symlink.
2023-10-04 02:53:48 -05:00
5b40bf3d93 Fix handling of xattrs with symlinks
Fix Linux, Darwin, and other BSD (untested) to allow proper
handling of xattrs with symlinks. On Linux we cannot use the f*
syscalls for symlinks because symlinks cannot be opened.
File flags must be handled differently on darwin and other BSD due
to the lack of the LCHFLAGS syscall on darwin, and the fact that it
is emulated in libc. However, we do have O_SYMLINK on darwin.
2023-10-04 02:53:48 -05:00
5087ac738d Support backup and restore of special files on POSIX style systems
Special files are device nodes and named pipes. The necessity of the
former is clear, the latter is debatable.
In order to preserve backward compatibility, the device number is
encoded in the StartChunk/StartOffset fields of the entry.
2023-10-04 02:53:48 -05:00
99e4dcae00 Don't overwrite symlinks if file already exists 2023-10-04 02:53:48 -05:00
997ff5bdf6 Support backup and restore of hardlinks
This tracks inode/device from the stat info and creates backward
compatible snapshots that allow preserving hardlinks. Backwards
compatibility is preserved by saving a virtual inode number index in the
Link field of the file entry. Since this field was previously only used
for symlinks, this won't break old versions. Additionally, the entry
data is cloned so restoration with an old version works.

Current limitations are primarility with restore. They include:
- no command line option to prevent hard link restore
- if a file has the immutable or append only flag it will be set before
hardlinks are restored, so hardlinking will fail.
- if a partial restore includes a hardlink but not the parent
directories the hardlink will fail.

These will be solved by grouping restore of hardlinks together
with file, prior to applying final metadata.

- if a file is changed and is being rewritten by a restore hardlinks are
not preserved.
2023-10-04 02:53:48 -05:00
34b1e19278 Initial implementation of file/inode flags (Linux, BSD, darwin)
Basic support for BSD and Darwin style chflags (stat flags). Applies
these flags at the end of file restore.
Supports linux style ioctl_iflags(2) in a 2 step process. Flags that
need to be applied prior to writes such as compress and especially no-COW
are applied immediately upon file open.

The flags format is backwards compatible. An attribute starting with a
null byte is used to store flags in the entry attributes table. With
an old version of duplicacy the restore of this attribute should silently
fail (effectively be ignored).

Fixes xattr restore to use O_NOFOLLOW so attributes are applied to symlink.

TODO: Tests, possible option to switch off mutable/append prior to
restore of existing file similar to rsync. Does not apply attributes
or flags to the top most directory.
2023-10-04 02:53:48 -05:00
c1c8af1de9 Increase b2 client max file listing count to 10000
Considerable speed improvement with listing large storage.
2023-10-04 02:53:48 -05:00
8b788572c8 Fix exclude_by_attribute feature on POSIX
The exclude by attribute function is broken on non-Darwin POSIX: linux and freebsd.
This is because those xattrs must be prefixed by a legal namespace. The old xattr
library implicitly appended the user namespace to the xattr, but the current
official go pkg does not (which is just as well).

Also fix the test to remove the discordant old xattr dependency and provide
test cases for both darwin and non-darwin POSIX.
2023-10-04 02:53:48 -05:00
b592484b54 Use S3 ListObjectsV2 for listing files
ListObjects has been deprecated since 2016 and ListObjectsV2 with use of
explicit pagination tokens is more performant for large listings as well.

This also mitigates an issue with iDrive E2 where the StartAfter/Marker
is included in the output, leading to duplicate entries. Right now this
causes an exhaustive prune to delete chunks erroneously flagged as
duplicate, destroying the storage.
2023-10-04 02:53:48 -05:00
Gilbert Chen
50120146df Bump version to 3.2.2 v3.2.2 2023-10-03 22:35:18 -04:00
Gilbert Chen
7bfc0e7d51 Save passwords after a storj storage has been created 2023-10-03 22:33:41 -04:00
Gilbert Chen
fd3bceae19 Bump version to 3.2.1 v3.2.1 2023-10-02 12:30:23 -04:00
Gilbert Chen
7cc1b4222c Update go version to 1.19.13 2023-09-28 23:17:24 -04:00
Gilbert Chen
d92b1734f4 Skip identical entries when listing chunks
The prune command can remove redundant chunks (chunks with the same chunk id
but at different subdirectory level).  However, if the same chunk appears
mutliple times in the listing returned by the storage, it will be treated as
a redundant chunk and thus removed.
2023-09-27 15:31:08 -04:00
Gilbert Chen
4e9d2c4cca Allow two copy-compatible storages to have different compression levels
This is useful for upgrading an existing storage to zstd compression or others.
Chunks need to be decompressed and re-compressed during copy anyway.  Only
the bit-identical option requires the same compression level

Also fix a typo: compatiable -> compatible
2023-09-18 14:44:41 -04:00
gilbertchen
cc482beb95 Merge pull request #653 from gorbak25/fix-compression
Fix compression level check
2023-09-18 10:50:55 -04:00
Grzegorz Uriasz
bf3ea8a83c Fix compression level check 2023-09-11 23:03:34 +02:00
Gilbert Chen
981efc13e6 Bump version to 3.2.0 v3.2.0 2023-09-08 15:25:22 -04:00
Gilbert Chen
6445ecbcde Add dependencies required by github.com/hirochachacha/go-smb2 2023-09-08 13:54:03 -04:00
Gilbert Chen
ff207ba5bf Convert the file path to the real one when downloading a chunk
This is mainly to handle the case when a fossil needs to be downloaded.
This happens when a metadata chunk has been marked as a fossil while the
correpsonding snapshot must be reconstructed for determine referenced
chunks.
2023-09-08 13:30:28 -04:00
Gilbert Chen
3a81c1065a Add a new Samba backend
The storage url is smb://user@server[:port]/share/path.  The password can be
set in the environment variable DUPLICACY_SMB_PASSWORD for default storage or
DUPLICACY_<STORAGE_NAME>_SMB_PASSWORD.

This backend is based on https://github.com/hirochachacha/go-smb2.  The
previous samba:// backend is just an alias for the disk-based backend with
caching enabled.
2023-07-05 22:51:24 -04:00
Gilbert Chen
cdf8f5a857 Check the length of 'file' before checking if it ends with '/' 2023-04-09 22:11:08 -04:00
Gilbert Chen
1f9ad0e35c B2 backend should be able to download .fsl files
This is needed when a metadata chunk has been turned into a fossil.  In B2,
the fossil file is the last version of the file with an 'upload' action, so
to download the file, the 'b2_list_file_versions' api is called to find the
file id and then download it using 'b2_download_file_by_id'.

This is needed when a metadata chunk has been turned into a fossil
2023-03-30 13:27:29 -04:00
Gilbert Chen
53b0f3f7b6 Implement zstd compression
Zstd compression can be enabled by providing `-zstd` or `-zstd-level <level>`
to `init`, `add`, or `backup`. With `-zstd` the compression level will be
`default`, and with `-zstd-level` the level can be any of `fastest`, `default`,
`better`, or `best`.
2023-03-26 21:31:51 -04:00
Gilbert Chen
9f276047db Fixed a typo in log id
SFT_RECONNECT -> SFTP_RECONNECT
2023-03-26 21:26:51 -04:00