Skip to content

predkambrij/btrfsBackup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is this project about?

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

Examples

Create Snapshots (for all subvolumes or for a specific one)

# ./backup.sh doSnapshotForAllSubvolumes
...
# ./backup.sh doSnapshot @test1
...

Send Created Snapshots to Local External BTRFS Storage

# ./backup.sh sendLocalAll
...

Send Created Snapshots to a Remote Machine over SSH

# ./backup.sh sendRemoteAll
...

Delete Transferred Snapshots from the computer

# ./backup.sh deleteTransferedAll
...

Manual test

# 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'

About

bash scripts for making, transfering and deleting snapshots of btrfs subvolumes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages