OpenMediaVault-Plugin-Developers / openmediavault-borgbackup

openmediavault plugin for borgbackup
10 stars 5 forks source link

Easier integration with btrfs snapshots #45

Open mikeage opened 4 months ago

mikeage commented 4 months ago

[I realize that this might be a bit vague, but I'm kinda brainstorming here]

I currently use btrfs for the filesystem on my drives, and back them up with borg from the command line. I'd like to replace my scripts and their cron jobs with the GUI from this plugin, but I can't quite figure out how to make it behave the way I want.

My problem is that I don't actually back up a directory, but rather, I want to back up a snapshot, which will appear as a subdirectory somewhere. My current script runs the following:

btrfs subvolume snapshot -r $BTRFS_ROOT $BTRFS_ROOT/.snapshots/snap
cd $BTRFS_ROOT/.snapshots/snap/

borg create ... ./foo ./bar /baz

cd -
btrfs subvolume delete $BTRFS_ROOT/.snapshots/snap

Where foo and bar are directories within the btrfs snapshot, and baz in this case is outsize. (I can live without baz, or make it a separate archive).

I do the directory change and relative path to not include the snapshot prefix, so that if I need to restore it, I could restore it directly. This is based on borg's suggestion (see https://borgbackup.readthedocs.io/en/stable/faq.html#how-can-i-avoid-unwanted-base-directories-getting-stored-into-archives).

I could restore with --strip-components, but ideally, i like storing what I need. The fact that there's a prefix of /path/to/.snapshots/snap is not something that really belongs in the archive; it's a side effect of borg.

Using the plugin, I could add the snapshotting part as a pre-script / post-script, but I'm at a loss about the relative paths.

Any suggestions for how this could be easier? Would adding an option for a base directory be possible / reasonable? I'm not sure if this has value for non-btrfs filesystems; I don't use ZFS, for example.

ryecoaaron commented 4 months ago

I guess I could add a text box option that would do the change directory to the path in the text box right before the borg create if the text box had a path in it.

ryecoaaron commented 2 months ago

I made this change weeks ago and forgot to push the change. 7.0.8 is in the repo now.