ZFS ZFS replication tools

I am implementing a backup solution for a small webserver. So far, the tools I plan to use:
- zfSnap
- rclone

I want to zfs send an archive of the latest webserver snapshots to another HDD, then sync to cloud (rclone). I am missing a replication tool that does:
zfs send zroot/webserver@snapshot | gzip > /backup/archive.gz
and manages the zipped archives on the backup drive, ie. sends the latest snapshot, deletes the old ones.

Before writing a script for this task, I was wondering if there was any tool fit for the job, that I may have missed? I came accross sanoid, zxfer, znapzend and others, but they don't seem to handle the making of single file backups. I don't see the appeal in replicating the filesystem as is (with incremental snapshots, etc.) on the backup drive for this particular application. Although, even if I eventually choose to replicate the filesystem (as opposed to a compressed snapshot stream), I still need to archive the latest snapshots to another directory before syncing it to the cloud.

I have seen the requests for a "zfSnap send" feature, but I am not sure if it was ever added / still needed.
 
After some tinkering, I found out there is an easy way to get the latest snapshot:
zfs list -t snapshot -o name -s creation -d 1 zroot/webserver | tail -1

Now, I just need a way to manage the archives... I guess I could simply overwrite them:
zfs send -R `zfs list -t snapshot -o name -s creation -d 1 zroot/webserver | tail -1` | gzip > /backup/latest.gz
 
Keep in mind that using stdout redirection (>) does not place those files onto a remote server. I personally find it easier (and safer) to use SSH for that and then manage the remote files using a local cron job based on age. Of course this does imply a risk that old backups could be removed even if newer backups fail for some reason. It's not a problem for me because backups are often checked.

Anyway... zfs send ... | ssh backup@host "dd of=/opt/backups/mystuff.zfs" could be a way to generate and store the stream.
 
Last edited:
Thanks for the reply.

Could you explain the use of dd? I have not seen it in any example of Oracle or the handbook.
zfs send ... | ssh user@host 'gzip > /backup/archive.gz' seems to work, as well.

Also, how do you check the integrity of your backups?
 
Here is my script:
Code:
#!/bin/sh

# Send latest webserver snapshot
p=`zfs list -t snapshot -o name -s creation -d 1 zroot/webserver | tail -1`
f=`basename $p`
zfs send -R $p | gzip > /backup/archives/$f.gz

# Cleanup (keep 5 latest archives)
cd /backup/archives
ls -tp | grep -v '/$' | tail -n +6 | tr '\n' '\0' | xargs -0 rm --

Works for now.

Finally, I am also using zxfer to send the main zpool to the HDD. I will move the HDD out of that server in the near future and send with ssh as recommended.
 
Back
Top