Hello,
I use BTRFS and see the advantage in the duplication and the snapshots of subvolumes. I think restic and BTRFS are two strong tools that work well together. So for a daily backup I have created a script with systemd service + timer, which
a) create a BTRFS snapshot
b) mount the BTRFS snapshot read-only
c) Backup with restic from the BTRFS snapshot to the restic repository
(and all the error handling to make it solid)
situation
Now almost everything seemed to work, but… I noticed some details that I would like to share.
Since the content of my /home
folder is stored in a dedicated BTRFS subvolume, I just take a snapshot of it.
I can now either backup the byte stream or do a file based backup. I opted for the latter to enable partial restore. In the consequence, I need to mount the snapshot in /mnt/snapshot
, for example. Or more precisely: The BTRFS subvolume is mounted in the system in /home
, so my snapshot is mounted in /mnt/snapshot/home
Restic recognizes this absolute path and I can see this in the Restic snapshot list. However, this is not a big deal, as I can perform the restore specifically with --target
.
Maybe a new restic feature could cover this later, mapping the real source /mnt/snapshot/...
to /...
within the repository.
the issue
The relative path is used for the backup:
cd /mnt/snapshot
and then restic backup home
( “home” = local folder)
However, I want to exclude some files from my backup, so I use restic backup --exclude-file /foo/bar/exclude.txt home
But I can’t use an absolute path in my exclude file because /home/*/Downloads
in my backup source is actually located in /mnt/snapshot/home/user/Downloads
.
→ The solution seems not to use /home/*/Downloads
but home/*/Downloads
(without leading /
) in the exclude file.
But that gets me into trouble: Even project/home/foo/Downloads/bar
is now excluded.
Maybe this is not a problem - but I’m aiming on excluding root folders, e.g. /var
, cause exclude var
is maybe not the best idea.
(Please don’t suggest me to use var/*
instead - as this is just a simple example)
finaly
How does the exclude pattern really work? The restic documentation says: restic compares against the absolute path, but I was able to verify on my system that the relative match actually works. Although I am not able to accomplish this with the match() function.
Any suggestions, tips, hints?
Note on using a BTRFS snapshot as a source for the restic backup: I don’t like complex solutions, created a simple script myself - and eventually want to share it as soon as it is robust.
Thanks in advance!