-
Notifications
You must be signed in to change notification settings - Fork 427
[Use Case] Backup a btrfs subvolume to your Google Drive
WARNING: This backup method is very lightly tested and should probably not be relied upon
Let's assume the following things:
- you have a btrfs subvolume that you'd like to backup mounted at
/home/
- you have drive and the xz and openssl utilities installed, initialized and working properly on your machine
- you have a plain text file,
~/secretPassword
, which contains a passphrase to be used for the encryption of your backup
First, cd
to some place in your drive folder structure on your local machine where you'd like your backup to reside, then:
sudo btrfs subvolume snapshot -r /home /home/home.snap.ro # create a read-only snapshot of your volume
sync # make sure the subvolume has been written to disk
sudo btrfs send /home/home.snap.ro/ | xz -9 | openssl enc -aes-256-cbc -pass file:${HOME}/secretPassword | drive push -piped home.bak.xz.enc
That's it!
You now have a compressed, encrypted backup of your btrfs volume in your Google Drive in the file home.bak.xz.enc
. If you'd like, you can safely remove the read-only snapshot created above with sudo btrfs subvolume delete /home/home.snap.ro/
after the upload is complete.
Note that this likely will not work for volumes containing data that does not compress to below 5TB (Google Drive's file size limit).
Also see: [Restore a btrfs subvolume backup from your Google Drive]([Use Case] Restore a btrfs subvolume backup from your Google Drive)