feat(backup): add possibility to exclude macOS cloud-only files#5370
Conversation
52b221d to
1145076
Compare
|
Checked MS OneDrive, it uses the same stat information for cloud only files so should just work with OneDrive too: $ ls -lO%
-rw-r--r--% 1 me staff compressed,dataless 5 Apr 24 09:09 cloud
-rw-r--r-- 1 me staff - 5 Apr 24 09:09 local |
|
I built this fork and did a bunch of testing on an M3 Mac running MacOS 15.4.1. Everything I tried work perfectly. For already downloaded files, it worked just like restic always does. But cloud-only (dataless) files were consistently skipped without forcing the materialization of files. This would be a great feature enhancement for restic. Currently I cannot use restic on the laptop I share with my wife, as we need to have the iCloud Drive "optimize" feature turned on, in order to avoid filling up the disc. This would be fantastic. Kudos to @hashier for the great work here. |
MichaelEischer
left a comment
There was a problem hiding this comment.
This will only work on macOS 14.0 and newer source. Older versions of macOS will materialize the file when calling stat() on cloud files.
Are you sure that the old stub files trigger a download when restic accesses them? The article sounds like the use a special filetype which has to be converted by Finder or something else into a regular file.
Other than that, I've only found a few nits, see below.
Can test this tomorrow on my old 2015 Mac that has an old version of macOS running. Will resolve now the conflicts in a merge and push. Please let me know if you want this PR squashed/rebased instead. Thanks a ton for the review, much appreciated. |
Please rebase and squash the PR. Squashing is optional, but at first glance the commits aren't structured that it's worth keeping the individual commits. |
158e39e to
9e5d48e
Compare
9e5d48e to
f3d9589
Compare
|
Rebased and squashed. Should be all good now. |
MichaelEischer
left a comment
There was a problem hiding this comment.
LGTM. Thanks!
Did you test this with an older macOS version yet?
|
@MichaelEischer I had time to check on my old system (macOS 12.7.6 Monterey) and you are right, there is a stub
I think this is true. On new versions of macOS files get automatically materialized when acted upon them. So running restic backup in iCloud drive will materialize all files by default. (fun fact: this automatically materialization did not work for me when restic is run from LaunchAgent and the backup would give some errors for those files but would complete successfully with all files that are already local.) |
What does this PR change? What problem does it solve?
Be able to exclude cloud-only files on macOS. Tested with iCloud drive. Should work with Dropbox/OneDrive too.
Some files local, some are only in the cloud
$ ls -lO% total 2048 -rw-r--r--% 1 me staff compressed,dataless 1048576 Apr 9 17:34 cloud-only-file -rw-r--r--% 1 me staff compressed,dataless 62 Apr 10 00:32 go.mod -rw-r--r--% 1 me staff compressed,dataless 153 Apr 20 00:14 go.sum -rw-r--r--@ 1 me staff - 1048576 Apr 9 17:34 local -rw-r--r--% 1 me staff compressed,dataless 501 Apr 20 00:13 main.gorestic backupwill only backup the one file that are locally available (named: local)Materialize all files in the folder
Let's run
restic backupagain. The newly materialized files are going to be backed up now too that were not backed up in the lastrestic backuprunAnd Debug Log info:
Note: I'm a bit surprised to see 2 log lines about
cloud-only-filein the Debug Log.Was the change previously discussed in an issue or on the forum?
Closes #5352
Checklist
changelog/unreleased/that describes the changes for our users (see template).Additional info/questions
Older versions of macOS will materialize the file when calling(On older macOS version restic should behave the same whether --exclude-cloud-files is provided or not)stat()on cloud files. Should we maybe print out a warning when using--exclude-cloud-fileson older macOS versions than 14.0?