U bent hier

How to do incremental snapshot backups with ZFS

In this example asp01 is the main data pool, where asp01b will be a pool created on a backup disk (erasing anything else which was already on that disk)

1. Create a backup pool

sudo zpool create b_asp01 /dev/disk/by-id/ata-ST1000LM024_HN-M101MBB_S2XQJ9DC600377

2. Rotate previous snapshots

(Assuming these snapshots exist)

sudo zfs destroy -r asp01@snap002
sudo zfs rename -r asp01@snap001 snap002
sudo zfs rename -r asp01@snap000 snap001

3. Take a snapshot

sudo zfs snapshot -r asp01@snap000

4. Look at the differences between two snapshots

Example:

sudo zfs diff asp01/qsys@snap001 asp01/qsys@snap000

5. Option 1) Send to a local disk containing the b_asp01-pool

5A.1 Send that snapshot (completely) to the backup pool (first-time run)

sudo zfs send asp01/qsys@snap000 | sudo zfs receive b_asp01/qsys

5A.2 Send that snapshot to the backup pool, incrementally to the previous time (from the second time on)

sudo zfs send -i snap001 asp01/qsys@snap000 | sudo zfs receive b_asp01/qsys

Result is that now b_asp01 is again a duplicate of asp01, up until the moment the last snapshot was taken

5 Option 2) Send to a remote disk containing the b_asp01-pool

In this way you can have the snapshot replicated to another system on a safe(r) location

5B.1Send that snapshot (completely) to the backup pool

sudo zfs send asp01/qsys@snap000 | ssh stephan@10.7.1.157 sudo zfs receive b_asp01/qsys

5B.2 Send that snapshot to the backup pool, incrementally to the previous time

sudo zfs send -i snap001 asp01/qsys@snap000 | ssh stephan@10.7.1.157 sudo zfs receive b_asp01/qsys

My script

This is how I run a snapshots backup on my file server. The result is an exact copy of the data on a 1TB usb hard disk, with the option to go back 3 versions before the last backup... It's a simple static hard coded script, just for a simple home server...

#!/bin/bash

sudo zpool import b_asp01

echo "Remove oldest snapshot in the master pool"
sudo zfs destroy -r asp01@snap003
echo "Remove oldest snapshot in the backup pool"
sudo zfs destroy -r b_asp01@snap003

echo "Rotate snapshots (aging) in the master pool"
sudo zfs rename -r asp01@snap002 snap003
sudo zfs rename -r asp01@snap001 snap002
sudo zfs rename -r asp01@snap000 snap001
echo "Rotate snapshots (aging) in the backup pool"
sudo zfs rename -r b_asp01/qsys@snap002 snap003
sudo zfs rename -r b_asp01/qsys@snap001 snap002
sudo zfs rename -r b_asp01/qsys@snap000 snap001
echo "Create newest snapshot in the master pool"
sudo zfs snapshot -r asp01@snap000

echo "Preparations finished..."
echo "Now sending snapshot from the master pool into the backup pool..."
sudo zfs send -i snap001 asp01/qsys@snap000 | sudo zfs receive b_asp01/qsys
echo "Done."

sudo zpool export b_asp01

IT area: