Mirror a ZFS filesystem from a remote server using incremental transfers.
# git clone https://github.com/nadavgolden/zfs-auto-mirror.git
# cd zfs-auto-mirror
# sudo make install
* Note: for the --progress
option to work, pv
should be installed, e.g.:
# sudo apt install pv
Usage: zfs-auto-mirror [options] target remote_dataset local_dataset
options:
-f Force full sync if conflict is detected between local and remote snapshots
-d N Print N-th log level (1=DEBUG, 2=INFO, 3=WARNING, 4=ERROR)
-h, --help Print this usage message
-l, --label Filter this label from snapshots (default: zfs-auto-mirror)
-p, --progress Display data transfer information. 'pv' installation required
-D, --destroy=DAYS Destroy snapshots taken up to DAYS days ago
positional:
target user@remote, used for SSH
local_dataset The dataset to mirror into
remote_dataset The dataset to mirror from
- ZFS installed (duh).
- User on remote should be allowed to:
# zfs allow <user> send,hold <dataset>
- User on mirror (local machine) should be allowed to:
# zfs allow <user> create,destroy,mount,receive <dataset>
- SSH to remote with public key authentication so that SSH would not prompt for password.
Notes about the script:
- It runs on the mirror - it pulls changes from the main server. This is by design.
- It does not remove snapshots which has been deleted on the main server.