Skip to content

Instantly share code, notes, and snippets.

@freemo
Last active February 3, 2023 02:20
Show Gist options
  • Save freemo/3dbf1c0358d1bf66a077671174b3ed02 to your computer and use it in GitHub Desktop.
Save freemo/3dbf1c0358d1bf66a077671174b3ed02 to your computer and use it in GitHub Desktop.
Backing up with btrfs
sudo mount /mnt/backup #this should be a btrfs volume
sudo btrfs subvolume snapshot -r / /mnt/backups/root-backup-$(date +%F_%R)
#list all other subvolumes
sudo btrfs subvolume list -p /
#repeat for all subvolumes
sudo btrfs subvolume snapshot -r /home /mnt/backups/home-backup-$(date +%F_%R)
sudo btrfs subvolume snapshot -r /etc /mnt/backups/etc-backup-$(date +%F_%R)
sudo btrfs subvolume snapshot -r /var /mnt/backups/var-backup-$(date +%F_%R)
sudo btrfs subvolume snapshot -r /var/cache /mnt/backups/var-cache-backup-$(date +%F_%R)
sudo btrfs subvolume snapshot -r /var/lib/portables /mnt/backups/var-lib-portables-backup-$(date +%F_%R)
sudo btrfs subvolume snapshot -r /var/lib/machines /mnt/backups/var-lib-machines-backup-$(date +%F_%R)
#optionally show that the snapshot is listed
sudo btrfs subvolume show /
sudo mount /mnt/usb-backups
sudo btrfs send /mnt/backups/*_* | sudo btrfs receive /mnt/usb-backups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment