Setting up backup disk
Prepare partition
- Attach disk to laptop
- Start gparted (
sudo gparted), delete existing partitions and create a single new one; partition table should be gpt - Encrypt the partition with LUKS:
sudo cryptsetup luksFormat -c aes-xts-plain64 -s 512 -h sha512 -y /dev/DEVICENAME - Open the encrypted partition:
sudo cryptsetup luksOpen /dev/DEVICENAME backup10tb - Format the encrypted partition with btrfs:
sudo mkfs.btrfs -L "backup10tb" /dev/mapper/backup10tb - Mount the partition:
sudo mkdir /mnt/backup10tb && sudo mount /dev/mapper/backup10tb /mnt/backup10tb
Create initial subvolumes on external disk
cd /mnt/backup10tb sudo btrfs subvolume create ./annex sudo btrfs subvolume create ./backup
Send backups to external disk
- Create new snapshots for all partitions:
for i in @ @etckeeper @home @repos @root; do btrfs subvolume snapshot -r /mnt/master/$i /mnt/master/backups/for-external/$i/$(date "+%Y-%m-%d")--01 ; done - Create the target diretory:
for i in @ @etckeeper @home @repos @root; do mkdir /mnt/backup10tb/backup/$i/; done - Send snapshots to backup disk:
for i in @ @etckeeper @home @repos @root ; do btrfs send /mnt/master/backups/for-external/$i/2019-11-24--01 | btrfs receive /mnt/backup10tb/backup/$i/ ; done
Clone annex repos
cd /mnt/backup10tb/annex git clone /home/mfk/repos/annex/newspaper/ -o remote-name cd newspaper git config user.name "Name" git config user.email info@example.org git annex init "Repo Name" git annex get --from remote-name --all git annex sync
Send incremental backups
btrfs subvolumes
- Create new snapshots for all partitions:
for i in @ @etckeeper @home @repos @root; do btrfs subvolume snapshot -r /mnt/master/$i /mnt/master/backups/for-external/$i/$(date "+%Y-%m-%d")--02 ; done - Send incremental snapshots to backup disk:
for i in @ @etckeeper @home @repos @root ; do btrfs send -p /mnt/master/backups/for-external/$i/2019-11-24--01 /mnt/master/backups/for-external/$i/2019-11-24--02 | btrfs receive /mnt/backup10tb/backup/$i/ ; done
Annex repos
cd /mnt/backup10tb/annex/newspaper/ git annex sync git annex get --from remote-name --all git annex sync