Offsite ZFS replication with seeding

I have been working to get remote site replication with ZFS working and thought I would share my results. I started with the documentation in the UrBackup Admin guide and expanded from there.

I have a number of distributed UrBackup servers. Many of them have large data sets already built up from client backups. In order to make the replication work, I need to seed the head end destination server with the data on the remote UrBackup servers.

To do this, I first replicate the data from a remote server onto an external USB drive. I then ship the drive to the headend server, plug it in and replicate the data from the USB drive to the headend ZFS pool. Now that the data is on the headend pool, I simply need to replicate incremental snapshots on a regular basis from the remote server to the headend server.

###Setup
Headend ZFS pool name = urbackup
Remotenode ZFS pool name = urbackup
Make sure headend pool is set to read-only. This will not prevent replication. (very important)
Use SSH certificates to avoid password prompts
Install mbuffer to help speed up ZFS recv function

All commands will be executed from the remote server, except where denoted.

###Create ZFS filesystem on headend
zfs create urbackup/remotenode
zfs set mountpoint=/mnt/urbackup/remotenode urbackup/remotenode
zfs set atime=off urbackup
zfs set readonly=on urbackup

###Seeding Replication from urbackup to USB Drive
zpool create usb /dev/usb_drive
zfs set mountpoint=/mnt/usb usb
zfs snapshot -r urbackup@last
zfs send -R urbackup@last | zfs recv -F usb/remotenode

###Seeding Replication from USB Drive to headend
zfs create urbackup/remotenode
zfs set mountpoint=/mnt/urbackup/remotenode urbackup/remotenode
zfs send -R usb@last | zfs recv -F urbackup/remotenode

###Enable remote incremental replication to headend (wash, rinse, repeat)
zfs snapshot -r urbackup@now
ssh user@headend ‘zfs rollbackup -r urbackup/remotenode@last’
zfs send -RI urbackup@last urbackup@now | mbuffer -q -v 0 -s 128k -m 1G |
ssh -T user@headend ‘mbuffer -s 128k -m 1G | zfs recv urbackup/remotenode’
zfs destroy -r urbackup@last
zfs rename -r urbackup@now urbackup@last
ssh user@headend ‘zfs destroy -r urbackup/remotenode@last’
ssh user@headend ‘zfs rename -r urbackup/remotenode@now urbackup/remotenode@last’

1 Like

Made a few updates after more testing.