backrest icon indicating copy to clipboard operation
backrest copied to clipboard

Add support for relative paths backup method

Open jibwf opened this issue 1 year ago • 4 comments

Note: if you have a question or want discussion please post in the discussions area.

Is your feature request related to a problem? Please describe.

Parent folders change impact snapshot

Note that when using absolute paths to specify the backup source, then also changes to the parent folders result in a changed snapshot. For example, a backup of /home/user/work will create a new snapshot if the metadata of either /, /home or /home/user change. To avoid this problem run restic from the corresponding folder and use relative paths.

https://restic.readthedocs.io/en/latest/040_backup.html#comparing-snapshots

Describe the solution you'd like Run backup cli into the exact folder.

cd /home/user/work && restic -r /srv/restic-repo backup . --skip-if-unchanged

jibwf avatar Dec 05 '24 03:12 jibwf

My initial thought is that this probably isn't something that makes sense for a built in capability for backrest, but is something that can be customized today by setting the working directory that you run backrest from.

Backrest doesn't do anything to change restic's working dir when forking it so it will be inherited.

garethgeorge avatar Dec 05 '24 06:12 garethgeorge

@garethgeorge I am using backrest on my NAS. Now all backup dirs maps to /backup. Do you means separate them to different folders? But in this way, if I have 10 folders, I need map them in docker volume one by one.

jibwf avatar Dec 05 '24 06:12 jibwf

Not sure I follow -- at a high level that sounds potentially fragile. I think I'm more so pointing out that I don't see a general purpose solution where backrest changes the working directory.

E.g. cd some_dir && restic -r /srv/restic-repo backup . --skip-if-unchanged works well if you want to backup a single directory and it's the current working directory, but backrest supports lists of paths e.g. potentially many disjoint folders.

In terms of work arounds, you can change the workdir that backrest runs from and try to use relative paths -- but I don't have any strong recommendations for how you should setup your folders in that case beyond doing something that makes the most sense to you :)

garethgeorge avatar Dec 05 '24 06:12 garethgeorge

Hi there @garethgeorge , i have a question i was hoping you might help me with;

but is something that can be customized today by setting the working directory that you run backrest from

i don't want to change the working directory of backrest, since it's running as a Launchdaemon on macOS, and i'm mounting "snapshots of the volume to backup" into ~/Volumes/my_daily_snapshot, for example;

So, as a workaround, would it work to create a pre-backup hook and have backrest change the cwd to ~/Volumes/my_daily_snapshot before executing restic ?

notDavid avatar Jan 27 '25 05:01 notDavid