Bash scripts for making, transferring, and deleting snapshots of Btrfs subvolumes.
It's useful if you have Btrfs on your computer and want to make regular snapshots, transfer them all to an external Btrfs storage — either a locally mounted volume or a remote machine over SSH — and then delete the transferred snapshots from your computer.
The script is designed to send to only one destination (locally or remotely over SSH) per configuration. Deletion of original snapshots is possible only after the sending has completed.
First time setup: copy conf.sample.sh to conf.sh and set the variables.
Multiple configurations can coexist — each config file handles one BTRFS filesystem and one destination. Use the BTRFSBACKUP_CONF_FILE environment variable to select which config to use. This makes it easy to manage backups of multiple BTRFS filesystems independently.
Example for disk2:
BTRFSBACKUP_CONF_FILE=conf_disk2.sh ./backup.sh doSnapshotForAllSubvolumes# ./backup.sh doSnapshotForAllSubvolumes
...
# ./backup.sh doSnapshot @test1
...# ./backup.sh sendLocalAll
...# ./backup.sh sendRemoteAll
...# ./backup.sh deleteTransferedAll
...# Note: wait 1 min in between doSnapshotForAllSubvolumes
sudo btrfs subvolume create /btrfs/@test1
sudo btrfs subvolume create /btrfs/@test2
# Remote
sudo su -c 'BTRFSBACKUP_CONF_FILE=conf_test.sh ./backup.sh doSnapshotForAllSubvolumes'
sudo su -c 'BTRFSBACKUP_CONF_FILE=conf_test.sh ./backup.sh sendRemoteAll'
sudo su -c 'BTRFSBACKUP_CONF_FILE=conf_test.sh ./backup.sh deleteTransferedAll'
# Local
sudo su -c 'BTRFSBACKUP_CONF_FILE=conf_test.sh ./backup.sh doSnapshotForAllSubvolumes'
sudo su -c 'BTRFSBACKUP_CONF_FILE=conf_test.sh ./backup.sh sendLocalAll'
sudo su -c 'BTRFSBACKUP_CONF_FILE=conf_test.sh ./backup.sh deleteTransferedAll'