Add `--include-if-present` or a way to generate list of files to backup
Hi,
Finally I've got some time to try migrating backups from restic to rustic again. Right now it's big enough amount of shell code that generates CLI opts for restic. I'm very impressed with rustic config file and would like to use it. Ideally without passing any extra CLI args if possible
One of features that I use extensively is --exclude-if-present. Basically I've a few 'tiers' of data on all machines that I backup:
CACHEDIR.TAG-- cache and stuff that I don't want to backup.bckexclude_garbage-- I don't backup this to main repo. But it still has some value. For example~/tmpor~/Downloads.
So for my main repo I will exclude both. But at the same time I've second repository that I don't mirror to cloud. And I would like to backup only directories that were skipped due to .bckexclude_garbage. Yes. It makes restore more difficult. But still better than not have this data at all.
For restic I'm doing this using find /path -name ... and generating CLI args. For rustic I think that I can generate' profile.toml file before doing actual backup. But maybe it makes sense to have it in rustic itself. For example that --include-if-present option.
Basically such --include-if-present <filename> should assume everything as exclude unless there is filename in any parent directory.
I'm not fully aware of all rustic features. Maybe it's easier to achieve same results using other ways.
I have this kind of use case on one of my services. I first generate a list of things to backup with a run-before hook and use the glob option to backup those files:
[[backup.snapshots]]
label = "myservice"
sources = ["/etc/systemd/system/myservice.service", "/var/rustic-db/myservice"]
glob-files = ["/var/myservice/included-files.txt"]
[[backup.snapshots.hooks.run-before]]
command = "bash"
args = ["-c", "sudo -u postgres pg_dump myservice > /var/rustic-db/myservice/dump.sql"]
[[backup.snapshots.hooks.run-before]]
command = "bash"
args = ["-c", "myservice_command_to_get_included_files > /var/myservice/included-files.txt"]
[[backup.snapshots.hooks.run-after]]
command = "bash"
args = ["-c", "rm /var/rustic-db/myservice/dump.sql"]
[[backup.snapshots.hooks.run-failed]]
command = "/usr/local/bin/notify_backup_failure"
args = ["myservice"]