ZFS Backup
Previous Poudriere setup Next Firewall Switch
ZFS Backup Synopsis
We are going to use ZFS to backup disk. We could use ZFS send and ZFS receive to write the dataset snapshot to the backup server disks. This will however cause problems with mount points for backups of the root file system. We therefore use ZFS send to a file for backups of root file systems. We also ensure that those ZFS pools which contain data are named unique within the landscape., i.e. zdata for the file-server data pool and zbackup for the backup server data pool. Backups are send of the LAN using nc (netcat). We are not using compression as we have a fast 10gig LAN and LZ4 compression is used on all disks.
There are 4 general steps as listed below: 1 Prerequisites
Prerequisites
There are different requirements for backup storage using storage to file or storage to disk. For file we just need a files system, for disk we need a unique dataset.
To file.
ZFS backups to file will be stored in a directory per server. On the dataset "zbackup/var/zfsbackup".
># mkdir -p /var/zfsbackup/{aap,noot,mies}
To disk.
If the dataset exists and needs to be deleted first use:
># zfs destroy zbackup/var/zfsbackup/[hostname]
Make sure there is a dataset on the backup server for each server. That will be the destination for the streamed backups.
># zfs create -o mountpoint=/var/zfsbackup/[hostname] zbackup/var/zfsbackup/[hostname]
Then create a dataset for each data set to be received
># zfs create -o mountpoint=/var/zfsbackup/[hostname][dataset] zbackup/var/zfsbackup/[hostname][dataset]
For aap that will be: ># zfs destroy -r zbackup/var/zfsbackup/aap
Create the mount points for the host root datasets first
># mkdir -p /var/zfsbackup/{aap,noot,mies}/zroot
Then create the datasets for the hosts.
># zfs create -o mountpoint=/var/zfsbackup/aap zbackup/var/zfsbackup/aap ># zfs create -o mountpoint=/var/zfsbackup/noot zbackup/var/zfsbackup/noot ># zfs create -o mountpoint=/var/zfsbackup/mies zbackup/var/zfsbackup/mies
For noot the sequence would be
># zfs destroy -r zbackup/var/zfsbackup/noot@znoot2001101319 ># zfs destroy -r zbackup/var/zfsbackup/noot ># zfs create -o mountpoint=/var/zfsbackup/noot zbackup/var/zfsbackup/noot
Create snapshot
It is best to remove older snapshots when a full backup is made, use:
># for f in `zfs list -H -rt snapshot [zroot name] | cut -f 1`; do zfs destroy -nvf $f; done
Then create the snapshot with the date and time as part of the name. Format used is:
># zfs snapshot -r [zroot name]@[host name]YYMMDDhhmm