rustic-rs / rustic

rustic - fast, encrypted, and deduplicated backups powered by Rust
https://rustic.cli.rs
Apache License 2.0
1.79k stars 67 forks source link

Please backup `exclude-if-present` file itself #664

Open dionorgua opened 1 year ago

dionorgua commented 1 year ago

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:

/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"
aawsome commented 1 year ago

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...