Ability to overwrite Drive/Path on backups
Restic has the ability to override the machine name, but not the actual path name. This would be useful for backing up USB drives from different machines as they may not always mount to the same drive letter.
This is more relevant in windows than in linux, but the same issue might arise for temporarily mounted volumes.
Reference: https://forum.restic.net/t/ability-to-override-drive-path-name/201
Thanks for raising this issue, it's quite specific to Windows and I wasn't aware of that problem.
This might also be a way around VSS backups (ie use a script to create a shadow copy and backup from the shadow folder but with the original root path.
After 0.9.0 released I started using Restic a bit more because it stopped renaming my base folders, e.g.. /Desktop and /Desktop-1. However the Absolute Pathing thing actually ended up causing me more issues...
Issue
As you also observed, my USB drive backups have become somewhat fractured. On my windows machine a single USB drive has been backed up as both E:\ and F:\ over time, and on the mac unfortunately as /Volumes/Photos/ and /Volumes/Photos-2018/. This is because I changed the label on the drive at some point.
Hopes
Ideally for me, it would be great if Restic allowed a way to provide a base path for how the backed up files are stored. I realise though that it would probably have to support both a --flag to affect all Sources and a per-source string notation to assign each individually. Something like:c:\Users\Jon\Documents:::/Documents.
Workaround
I recently tried to find a way to at least force Restic to using a consistent root path regardless of device. The only solution I found was to change CWD and do restic backup .. I really hope this option doesn't go away, its really handy.
The main sacrafice when doing this is that I can only backup one source for each backup/snapshot, but that is fine for my needs as I like to run them separately so I can prioritize folders/jobs. The other issue is that there isn't that other dimension like --root/base/path that you can set to provide an alias path for the backup to be represented under. Right now I get arround this using the --tag system (which is awesome) doing something like..
cd c:\Users\Jon\Documents
restic backup --tag base:/Documents .
cd c:\Users\Jon\Desktop
restic backup --tag base:/Desktop .
This works well in combination with the CWD and . work around. In the end I decided to use 3 tags to uniquely identify a backup, because it helped me filter/find stuff easier:
-
Type: Device Type -
USBNASLaptop -
Name: Unique Name/ID -
PersonalMedia... -
Base: Override Path -
/Documents/Photos...
Type is handy for me so that I can see all USB or Network backups easily, as they can be instigated from any host device (ie.. two laptops can backup the same USB drive or Network share).
Name is basically the same as Hostname, but I think of it more as an Unique Invariant name to group paths by. For example, I may buy a new laptop in the future, but want to still group all my Personal folders in the same identifier Personal.
Base is just the root path that allows organization and separation under a name.
I think of this structure a little like this: laptop://Personal/Documents.
Conclusion
I guess I'm really trying to map a source structure to a custom one (which might be a fringe case for most), but I figured I'd share my approach incase its useful for others.
One of the big benefits of doing this with tags, is that you can change them and mass-update them later if you need to rename anything.
It would still be handy to have that --flag and string notation to set the internal path of the backed up files. Tags are really perfect for the other customizations, its just that one that feels like it should be a dedicated option.
I'm bumping this thread because I'd love to see something like this implemented! Thanks for this wonderful software by the way.
Hey, I think I'm in a similar situation I used to do backups simply using rsync, now I want to switch to restic. I have serveral TB of data on a remote machine (my rsync backups). I want to avoid copying all of that data over sftp again. So I just created an restic repo on the remote machine and backed up my rsync backup via restic which is on the same machine. Now I want to push changes to that repo via sftp from my local machine. But of course the paths there are different. Is the workaround @jonreeves proposed applicable in that situation, do I even need a workaround?
If you now run restic on your local machine, restic will scan all the files that you ask it to back up, but it will not re-upload the data in the files. So you can simply run that backup in your local machine, then you'll get a snapshot with the "right" paths, and then you can forget the first snapshot you made, leaving only the new one.
I'd love a --path-root/RESTIC_PATH_ROOT option or the such, to be able to backup my phone separately.
# normal backup
restic backup /file/on/host
# phone backup
restic backup --host "$PHONE_SERIAL" --path-root "$PHONE_PATH" /file/on/phone
with the latter backing-up "$PHONE_PATH"/file/on/phone but storing it in the repository as /file/on/phone
Would make it nicer to switch computers / switch from backing up over usb to using an app on the phone instead / etc as the paths will always be the same for that device regardless of how I'd backup
edit: oh nevermind, seems https://github.com/rustic-rs/rustic/pull/296 adds support for doing this by storing relative paths as absolute paths?
edit edit: though the path of the snapshot itself is unaffected it seems
summer wildfire /tmp/tmp.QjwfC9p3ED RESTIC_PASSWORD=x restic snapshots --repo x
repository 3af4697d opened (version 2, compression level auto)
ID Time Host Tags Paths
------------------------------------------------------------------------------
d18725ce 2024-06-03 07:04:40 wildfire /tmp/tmp.QjwfC9p3ED/y/z
------------------------------------------------------------------------------
1 snapshots
summer wildfire /tmp/tmp.QjwfC9p3ED RESTIC_PASSWORD=x restic ls --repo x d18725ce
repository 3af4697d opened (version 2, compression level auto)
[0:00] 100.00% 1 / 1 index files loaded
snapshot d18725ce of [/tmp/tmp.QjwfC9p3ED/y/z] filtered by [] at 2024-06-03 07:04:40.244568787 +0930 ACST):
/y
/y/z