User Tools

Site Tools


project:rsnapshot-zfs-helper

This is an old revision of the document!


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 …'.

how

rsnapshot-zfs-helper is to be configured inside rsnapshot's configuration. i.e. '/etc/rsnapshot-backup.d/enabled/conf.<BACKUP-CLIENT>'

Additionally, 'cmd_cp' has to be set to '/bin/true'.

cmd_cp        /bin/true
cmd_preexec   /usr/sbin/rsnapshot-zfs-helper /etc/rsnapshot-backup.d/enabled/conf.<BACKUP-CLIENT> preexec
cmd_postexec  /usr/sbin/rsnapshot-zfs-helper /etc/rsnapshot-backup.d/enabled/conf.<BACKUP-CLIENT> postexec

Create a zfs dataset using:

zfs create <ZPOOL>/<BACKUP-CLIENT>/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

what's happening

  • '/usr/sbin/rsnapshot-zfs-helper … preexec' removes expired backups (that would be destroy zfs snapshots)
  • the removal of expired backups using rm will never occur because there is only a 'daily.0' as far as 'rsnapshot' is concerned
  • for the same reason, there will be no renaming or rotation of previous backups
  • 'rsync' updates 'daily.0' as usual
  • '/usr/sbin/rsnapshot-zfs-helper … postexec' creates a zfs snapshot using the name extension '@daily.<ISO8601-DATE-UTC>'

FAQ

  • Why does 'rsnapshot-zfs-helper' use timestamps instead of enumeration when naming the snapshots? A: Because I like it better that way: you see what you get. No renaming required. No moving targets.
  • Why the weird ISO date format? A: because it's an international standard. Lots of code is available to handle it. It's human readable. It scales well. No built in misinterpretation.
  • But why then use UTC? A: I would have preferred to use ISO-8601 with timezone notation. But zfs does not accept '+' as a character in snapshot names. So I used the format closest by - the UTC timestamp.
  • What's the deal with 'cmd_cp /bin/true'? A: Think of it as NOOP.
project/rsnapshot-zfs-helper.1516730692.txt.gz · Last modified: 2018/01/23 19:04 by 88.65.214.4