Table of Contents

CAVEAT : WORK IN PROGRESS

rsnapshot zfs helper

This is a plugin for rsnapshot (and of course rsnapshot-backup) to be used with zfs as storage backend.

general idea

The main objective why you may consider using zfs might be:

rsnapshot begins its job with creating a directory filled with hard links as “copy” of yesterday's backup, which subseqently is updated with rsync. This 'cp -al daily.1 daily.0' takes a significant amount of time, around 10-20% of the total time the backup takes. Worse, it creates a lot of disk activity, putting stress on hard drives, blocking concurrent backups and creating high loads on the backup system. To some extend the deletion of expired backups will add to this overhead.

As zfs uses copy-on-write there is no need to somehow emulate this with 'cp -al …'.

example for rsnapshot

Example for using rsnapshot-zfs-helper with rsnapshot

example for rsnapshot-backup

Example for using rsnapshot-zfs-helper with rsnapshot-backup

Example for creating a zpool:

##
## setup zfs (optional)
##
# 'bpo' kernel won't do the trick
apt-get install linux-image-amd64
apt-get clean
reboot

- add "contrib" to the apt-sources
apt-get update
apt-get install zfs-dkms zfsutils-linux
apt-get clean

/sbin/modprobe zfs

## caveat: this example (a single disk partition) is neither redundant nor exceptionally performant
## and serves for illustration purpose only! 
## create partition for zfs:
Device     Boot   Start       End   Sectors  Size Id Type
...
/dev/sda3       4194304 209715199 205520896   98G bf Solaris

## create zpool without mount point
zpool create zp-bak /dev/sda3 -m none

# create prereq. datasets
zfs create zp-bak/backup                        -o compression=lz4 -o snapdir=hidden -o xattr=sa -o acltype=posixacl -o mountpoint=/backup
zfs create zp-bak/backup/hosts                  -o compression=lz4 -o snapdir=hidden -o xattr=sa -o acltype=posixacl -o mountpoint=/backup/hosts
df  
->
   Filesystem     1K-blocks    Used Available Use% Mounted on
   ...
   zp-bak/backup        99041152     128  99041024   1% /backup
   zp-bak/backup/hosts  99041152     128  99041024   1% /backup/hosts

## if you use rsnapshot you have to add the commands commands below ## if you use rsnapshot-backups the tool rsnapshot-backup-conf will handle those for you Create a zfs dataset for a single backup:

zfs create <ZPOOL>/backup/hosts/<BACKUP-CLIENT> -o compression=lz4 -o snapdir=hidden -o xattr=sa -o acltype=posixacl -o mountpoint=/backup/hosts/<BACKUP-CLIENT>/daily.0
# e.g.
zfs create zp-bak/backup/hosts/srv42 -o compression=lz4 -o snapdir=hidden -o xattr=sa -o acltype=posixacl -o mountpoint=/backup/hosts/srv42/daily.0

Create cron jobs for backup promotion to higher rotation levels

45 23 * * * root /usr/sbin/rsnapshot-zfs-helper /etc/rsnapshot-backup.d/enabled/conf.<BACKUP-CLIENT> daily
50 23 * * 5 root /usr/sbin/rsnapshot-zfs-helper /etc/rsnapshot-backup.d/enabled/conf.<BACKUP-CLIENT> weekly
55 23 1 * * root /usr/sbin/rsnapshot-zfs-helper /etc/rsnapshot-backup.d/enabled/conf.<BACKUP-CLIENT> monthly

how it works

FAQ