ZFS Snapshot Remote Backup Using SSH with Non-root

ZFS远程SSH非root用户备份

zfs could backup its dataset/filesystem by using command:

# zfs send tank/data@snap1 | zfs recv spool/ds01

You can also backup to another computer on the LAN/WAN with ssh encryption:

host1# zfs send tank/dana@snap1 | ssh host2 zfs recv newtank/dana

While in Ubuntu, this command can not use sudo to get root right, and ZoL is not full implementation of ZFS Allow, so here is the workaround:

  1. Add below content into /etc/sudoers.d/zfs

    remuser ALL = (root) NOPASSWD:/sbin/zfs recv *

    remuser is the user name on remote host.

  2. Start zfs send:

    localhost# zfs send tank/example@snap1 | ssh remuser@remhost sudo zfs recv -F backuppool/fs

  3. 增量备份:

    localhost# zfs send -i tank/example@snap1 tank/example@snap2 | ssh remuser@remhost sudo zfs recv -F backuppool/fs