Commit Graph

31 Commits

Author SHA1 Message Date
ee19d44403 Cleanup hardlinking code
This moves special file link data to the chunk fields like symlink
hardlinks.
2023-10-07 13:55:51 -05:00
b8c0b1f86e tweak the symlink hardlink chunk ids 2023-10-07 13:55:51 -05:00
059e74da17 Support backup of sockets
This only works on Linux. Darwin does not allow mknod of a socket.
Have not tested BSD.
2023-10-07 13:55:51 -05:00
31c131b9e3 gofmt some files 2023-10-07 13:55:51 -05:00
e01008a56b 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-07 13:55:51 -05:00
4934df4e08 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-07 13:55:51 -05:00
88c92da9bd 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-07 13:55:51 -05:00
e61f5c2192 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-07 13:55:51 -05:00
d3b7cdc02d 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-07 13:55:51 -05:00
Gilbert Chen
d9f6545d63 Rewrite the backup procedure to reduce memory usage
Main changes:

* Change the listing order of files/directories so that the local and remote
  snapshots can be compared on-the-fly.

* Introduce a new struct called EntryList that maintains a list of
  files/directories, which are kept in memory when the number is lower, and
  serialized into a file when there are too many.

* EntryList can also be turned into an on-disk incomplete snapshot quickly,
  to support fast-resume on next run.

* ChunkOperator can now download and upload chunks, thus replacing original
  ChunkDownloader and ChunkUploader.  The new ChunkDownloader is only used
  to prefetch chunks during the restore operation.
2021-10-24 23:34:49 -04:00
Gilbert Chen
ace1ba5848 Remove runtime OS check for excluding by attributes 2020-09-25 22:37:54 -04:00
gilbertchen
1fedfd1b1a Merge branch 'master' into mac-exclude 2020-09-25 20:13:43 -04:00
Gilbert Chen
b32c3b2cd5 If a symlink is a directory, match it against the patterns as a directory 2019-11-21 23:10:54 -05:00
Gilbert Chen
9baafdafa2 Remove a log message meant for debugging only 2019-11-21 21:23:31 -05:00
Gilbert Chen
ca7d927840 Use joinPath instead of filepath.Join to generate UNC paths
This fix isn't probably necessary since filepath.Join can now produce UNC
paths too with the latest versions of go.  However, we still want to keep
it for consistency.
2019-11-21 14:56:31 -05:00
Michael Cook
0762c448c4 gofmt -s 2018-12-29 13:20:10 +01:00
Patrick Seal
a1efbe3b73 Add exclude_by_attribute preference 2018-09-21 21:35:40 -07:00
Gilbert Chen
a7d2a941be Restore UID and GID of symlinks 2018-08-29 17:10:35 -04:00
gilbertchen
736003323a Merge pull request #417 from amarcu5/fix-permissions
Fixed restoration of basic UNIX file permissions
2018-07-02 14:31:10 -04:00
Gilbert Chen
aadd2aa390 Add an -enum-only option to the backup command to enumerate the repository only 2018-05-24 11:34:46 -04:00
amarcu5
a4c46624ea Fix basic UNIX permissions 2018-04-29 20:24:50 +01:00
Frank
4dd5c43307 Add nobackup-file preference.
Directories containing a file with this name will not be backed up. I find it easier to drop a .nobackup file in directories I don't want backed up instead of maintaining a file of exclusions. This is also useful for scripts that create data in the repository but don't want it to be backed up.
2018-04-01 12:50:00 -07:00
Gilbert Chen
b99f4bffec Follow symlinks that point to paths starting with \\ 2018-03-22 22:37:09 -04:00
Mark Lowne
57edf5823d allow skip setting uid/gid on restored files 2017-10-30 20:16:28 +01:00
Gilbert Chen
923cd0aa63 Run goimports on all source files 2017-09-20 23:07:43 -04:00
Gilbert Chen
68fb6d671e Fixed symbolic link handling on Windows 2017-09-08 15:31:45 -04:00
Gilbert Chen
7f04a79111 Replace Fair Source 5 with our own free-for-personal-use license 2017-07-13 23:33:14 -04:00
Etienne Charlier
ae34347741 merge version 2.0.2 2017-06-10 17:12:44 +02:00
Gilbert Chen
42337d84c3 Move source files into src for a better looking front page 2017-06-07 14:04:11 -04:00
Gilbert Chen
4a1dc01ff4 Reorganize src directory 2017-06-02 16:33:36 -04:00
Gilbert Chen
bdf017e552 Move source files to src/ 2017-05-23 10:25:00 -04:00