rustic icon indicating copy to clipboard operation
rustic copied to clipboard

Please backup `exclude-if-present` file itself

Open dionorgua opened this issue 2 years ago • 1 comments

Hi,

I'm slowly trying to migrate my homelab backup from restic to rustic.

One of behavior difference that I don't like is --exclude-if-present handling:

  • restic stores that excluded file in snapshot. While rustic doesn't. And even worse: rustic doesn't store excluded directory itself. Presence of this file in snapshot is pretty good thing because it shows fact that directory was not empty, but was excluded due to that flag. Plus it's much easier to continue using system after restore (no need to recreate these files)
  • rustic correctly handles https://github.com/restic/restic/issues/2722 which is good thing!
/tmp/foo/src
├── backup_me.txt
├── cache
│   ├── CACHEDIR.TAG
│   └── ignore_me.txt
└── some_dir
    └── date.txt

restic:

$restic backup --exclude-if-present CACHEDIR.TAG /tmp/foo/src
$restic ls latest
/tmp
/tmp/foo
/tmp/foo/src
/tmp/foo/src/backup_me.txt
/tmp/foo/src/cache
/tmp/foo/src/cache/CACHEDIR.TAG
/tmp/foo/src/some_dir
/tmp/foo/src/some_dir/date.txt

rustic:

$rustic backup --exclude-if-present CACHEDIR.TAG /tmp/foo/src
$rustic ls latest
"tmp" 
"tmp/foo" 
"tmp/foo/src" 
"tmp/foo/src/backup_me.txt" 
"tmp/foo/src/some_dir" 
"tmp/foo/src/some_dir/date.txt"

dionorgua avatar Jun 06 '23 10:06 dionorgua

Thanks for opening the issue. Yes, this is the way rustic works at the moment. The reason is, that the exclude-if-present uses the ignore crate's functionality to exclude a dir with all its contents based on some condition. exclude-if-present uses the condition that a file with the given name should be present - and in this case obviously the whole dir and also this specific file is also excluded. I don't know how to change this without either changing the ignore crate or self-implementing the same logic...

aawsome avatar Jun 18 '23 19:06 aawsome