Open
Description
HOWTO: set up complex, persistent archive configuration in btrbk.conf
After some deep man page reading and lateral thinking, here's how I setup archiving to avoid needing to specify all the config at the command line.
Features:
- Prevents snapshot creation (
snapshot_create no
) - Not run by default (
noauto yes
) - Preserves all source snapshots
- Allows different retention schedules for different subvolumes
- Labelled
group
statements, so be run viabtrbk run nas
, or sub-sections only: `btrbk run nas-home
Overview
This method makes uses two configuration sections:
The usual snapshot/backup config section (nothing new here, just check the terms I use):
- Source: live filesystem
- Snapshot target: another directory on the live filesystem
- Backup target: another filesystem. Below, I'll call this the backup disk
The archive config section
- Source: backup disk
- Snapshot target: DISABLED via
snapshot_create no
, but needs to be specified as a source for the backup target - Backup target: the archive repository, eg a NAS or S3 storage mounted as a filesystem
Example
I'm a digital nomad. My usual backup target is an external HDD. I also want to save backups on a NAS that resides at my parent's house.
I have 2 filesystems to backup:
- rootfs (subvolume
@
) - home, with two subvols:
@home
-- the bulk of it@home-var
--.cache
folders and data that could be regenerated, eg downloads, blockchains. I symlink these type of folders into this subvolume's mountpoint.
All my subvols get backed up to my external HDD /media/ssd/btrbk
:
volume /mnt/btrfs-vol/rootfs
group svelte
subvolume @
group rootfs
snapshot_dir btrbk/ # Seems to default to <volume>/btrbk
# snapshot_name defaults to <subvolume-name>, but be explicit:
snapshot_name rootfs
target send-receive /media/ssd/btrbk/rootfs
volume /mnt/btrfs-vol/home
group svelte
subvolume @home
group home
snapshot_dir btrbk/home
snapshot_name home
target send-receive /media/ssd/btrbk/home
subvolume @home@var
group home-var
snapshot_dir btrbk/home-var
snapshot_name home-var
snapshot_preserve_min 36h
# Ensure that these are preserved long enough to be picked up by sporadic runs of the `nas` groups below.
snapshot_preserve 48h 14d 6w 3m
target send-receive /media/ssd/btrbk/home-var
And now from external HDD /media/ssd/btrbk
to NAS:
# Using a hack here - we never want to 'run' these profiles to create new snapshots.
# The snaps are created above. This section is for copying from the above section's backup target to archive target.
volume /media/ssd/btrbk
group nas # Add this whole section's scope for command line filtering
ssh_user root # FIXME: change to btrbk
# Don't create snapshots
noauto yes # Only run this section if explicitly included in a filter
snapshot_create no # Skip snapshot creation
snapshot_preserve *h # Don't delete backup disk snaps at all
snapshot_preserve_min all # Don't delete backup disk snaps at all
target_preserve 52w *m # Archive retention policy
target_preserve_min no # Don't create a non-preserved backups
subvolume home
group nas-home # for command line filtering
snapshot_dir home
snapshot_name home
target send-receive ssh://nas:5090/btrbk/svelte/home
subvolume rootfs
group nas-rootfs # for command line filtering
snapshot_dir rootfs
snapshot_name root
target send-receive ssh://nas:5090/btrbk/svelte/rootfs
subvolume home-var
group nas-home-var # for command line filtering
snapshot_dir home-var
target send-receive ssh://nas:5090/btrbk/svelte/home-var
Metadata
Metadata
Assignees
Labels
No labels