Package: zfs-tools-zbackup
# ZFS toolsThis repo has diverged from the upstream
[Rudd-O/zfs-tools](http://github.com/Rudd-O/zfs-tools), as described
[here](https://github.com/Rudd-O/zfs-tools/issues/25).  It is now
being maintained directly here by the original author of the `zbackup`
utility, and has its own release numbering.Differences from upstream include (but may not be limited to):parallel replication, for increased performance of `zreplicate`locking of filesystems during replication, to avoid problems
arising from very long replicationsresumable replications using the facility introduced in zfs 0.7.0This version of the zfs-tools suite is used in production on the
author’s system comprising 7 fileservers, 3400 filesystems, and 550TB
of data.The ZFS backup tools will help you graft an entire ZFS pool as a filesystem
into a backup machine, without having to screw around snapshot names or
complicated shell commands or crontabs.The utilities let you do this:zfs-shell:
a shell that allows remote ZFS administration and nothing morezsnap:
a command that snapshots a dataset or pool, then deletes old snapshotszreplicate
a command that replicates an entire dataset tree using ZFS replication
streams.  Best used in combination with zsnap as in:zsnap on the local machinezreplicate from the local machine to the destination machineObsolete snapshots deleted by zsnap will be automatically purged on
the destination machine by zreplicate, as a side effect of using
replication streams.  To inhibit this, use the
–no-replication-stream option.Runzreplicate –helpfor a compendium of options you may use.zbackup:
a command to snapshot and replicate filesystems according to their user properties.
This uses zsnap and zreplicate to do the work, which is all driven by properties.
For details, see this [further description of zbackup](doc/README-zbackup.md).zflock:
a command to lock a filesystem against replication by zbackup.
For details, see this [further description of zbackup](doc/README-zbackup.md).## Setting upSetup is rather complicated.  It assumes that you already have ZFS running
and vaults on both the machine you’re going to back up and the machine that
will be receiving the backup.### On the machine to back upInstall the zfs-shell commandcp zfs-shell /usr/local/sbinchmod 755 /usr/local/sbin/zfs-shellchown root.root /usr/local/sbin/zfs-shellCreate a user with a home directory and shellzfs-shelluseradd -rUm -b /var/lib -s /usr/local/sbin/zfs-shell zfsLetsudoknow that the new user can run the zfs commandzfs ALL = NOPASSWD: /usr/local/sbin/zfs(ensure you remove therequirettydefault on/etc/sudoers)
(checksudoers.zfs-toolsincontrib/for an example)Set up a cron job to runzsnapas frequently as you want to,
snapshotting the dataset you intend to replicate.### On the backup machineSet up public key authentication for SSH so the backup machine
may log as the userzfs(as laid out above) in the machine to
be backed up.Create a dataset to receive the backup stream.Set up a cron job to fetch the dataset snapshotted by zsnap
from the remote machine into the newly created dataset.  You
will usezreplicatefor that (see below for examples).After the first replication, you may want to set themountpointattributes on the received datasets so they do not automount
on the backup machine.### TestIf all went well, you should be able to do this without issue:(on the machine to back up)[root@peter]
zsnap senderpool(on the machine to receive)[root@paul]
zfs create receiverpool/senderpool # <— run this ONLY ONCE
zreplicate -ozfs@paul:senderpool receiverpool/senderpool
# this should send the entire senderpool with all snapshots
# over from peter to paul, placing it in receiverpool/senderpool(on the machine to back up)[root@peter]
zsnap senderpool(on the machine to receive)[root@paul]
zreplicate -ozfs@paul:senderpool receiverpool/senderpool
# this should send an incremental stream of senderpool
# into receiverpool/senderpoolAnd that’s it, really.