Skip to content

About

Replicate ZFS snapshots to a remote host over SSH (Python CLI; replication only — it doesn't create snapshots).

Topics

Resources

Code of conduct

Contributing

Stars

24 stars

Watchers

5 watching

Forks

Repository files navigation

zfs-replicate

Licence Coverage Python versions

https://github.com/alunduil/zfs-replicate

By Alex Brandt alunduil@gmail.com

Description

zfs-replicate backs up Zettabyte File System (ZFS) data sets to a remote host by sending their snapshots over SSH. It does not create snapshots, so pair it with a tool that does.

zfs-replicate relates to several other projects, which fit other niches:

  1. sanoid: A full snapshot management system. Its companion, syncoid, handles replication with copious options.
  2. zfs-replicate (BASH): A similar project. The major differences include configuration style and system expectations (for example, logging controls). zfs-replicate uses parameters whereas zfs-replicate (BASH) uses a BASH script.
  3. znapzend: Another scheduling and replicating system.
  4. zrep: A SH script with several control commands for snapshot replication.

Prerequisites

  1. A local ZFS filesystem and zfs command-line tools
  2. Python 3.10 or later on the local system
  3. A remote system with a ZFS filesystem and the zfs command-line tools
  4. SSH access to that remote system
  5. lz4 on both systems, unless you pass --compression off

Don't use the root user on the remote system. Delegate the ZFS permissions replication needs on the backup data set to a regular user instead:

# FreeBSD only: let non-root users mount filesystems.
sysctl -w vfs.usermount=1

zfs allow "${USER}" clone,create,destroy,hold,mount,promote,quota,readonly,receive,rename,reservation,rollback,send,snapshot "${BACKUP_DATASET}"

Install zfs-replicate

Install zfs-replicate from PyPI:

pipx install zfs-replicate

Nix and NixOS users install the zfs-replicate package from nixpkgs. NixOS also provides a services.zfs.autoReplication module that runs replication as a system service.

How to use zfs-replicate

Replicate the snapshots of LOCAL_FS to REMOTE_FS on HOST:

zfs-replicate --user "${USER}" --identity-file ~/.ssh/id_ed25519 HOST REMOTE_FS LOCAL_FS

zfs-replicate --help lists every option. To tune the send stream or set properties on the replica, see How to tune the send and receive streams.

Documentation

Getting support

  • GitHub issues: Report any problems or feature requests to GitHub issues.

Contributing

Contributions are welcome as issues or pull requests. CONTRIBUTING explains how to set up a development environment and what a pull request needs. Everyone taking part follows the Code of Conduct.

Licence

You are free to copy, change, and distribute zfs-replicate with attribution under the terms of the BSD-2-Clause licence. See the LICENSE for details.

zfs-replicate began as a fork of FreeNAS's autorepl.py, so the LICENSE carries the iXsystems, Inc. copyright.

About

Replicate ZFS snapshots to a remote host over SSH (Python CLI; replication only — it doesn't create snapshots).

Topics

Resources

Code of conduct

Contributing

Stars

24 stars

Watchers

5 watching

Forks

Releases

Used by

Contributors

Languages