GithubHelp home page GithubHelp logo

zfsync's Introduction

zfsync

remote ZFS replication made easy

Using ZFS opens up the really cool possibility to send snapshots to remote ZFS enabled servers, but managing synchronization of your snapshots can turn out more difficult. zfsync makes keeping these snapshots in sync easy.

It offers a purely in shell written script, and works without any dependencies on FreeBSD and *Solaris systems.

##TL;DR:

zfsync -H remote.host -T tank/backups/myhost zroot/precious/data

syncs all filesystems from zroot/precious/data to the remote host.

##Usage:

zfsync [-dhiPq] [-U target_user] [-I identity_file] [-k retention]
       [-K retention] -H target_host -T target_zfs
       source_zfs

    source_zfs is the filesystem that should be synced to a remote host

Options:
    -d                   enable debugging (negates -q)
    -B                   even when mbuffer is detected, don't buffer
    -h                   show you this help page
    -H target_host       host to send snapshots to [required]
    -i                   send incremental stream between local and remote
                         snapshot instead of a stream package of all
                         intermediary snapshots
    -I identity_file     use this key for authentication
    -k local_retention   after synchronizing, apply local retention
    -K remote_retention  after synchronizing, apply remote retention
    -P                   do not set user properties on remote end
    -q                   be more quiet
    -T target_zfs        ZFS on target host to send snapshots to [required]
    -U target_user       alternative user to authenticate as on remote host

##Preparing remote host

Currently, zfsync should just work as long as the remote host is running FreeBSD or *Solaris and you have access to it over SSH. While it is certainly possible, you really shouldn't use the root user for receiving the ZFS snapshots (arguably for no SSH access at all, actually). Instead, set up a non-privileged user, most preferably with public key access, on the remote host. Here is a FreeBSD example:

remote host:

pw useradd -n zfsync -d /home/zfsync -m -w random -s /bin/sh
mkdir ~zfsync/.ssh/
ssh-keygen -f ~zfsync/.ssh/id_rsa
chown -R zfsync ~zfsync/.ssh
zfs allow -u zfsync create,mount,receive tank/backups/myhost

to create non-privileged user zfsync, set up a public/private key and give user zfsync minimal permissions for receiving ZFS snapshots tank/backups/myhost (zfsync will warn you otherwise). The public key ~zfsync/.ssh/id_rsa.pub should be copied to the source host via a secure channel, so it could be pointed to with -I while using -U zfsync on the next sync. You should add a strong passphrase to the key file, and use ssh-agent so you can cron syncing your filesystems. If you want to keep remote retention, make sure user zfsync has destroy permissions as well on the remote filesystem.

##Known issues

  • has to be tested on GNU/Linux with ZFSOnLinux
  • zfsync does not support multiple source_zfs arguments yet
  • on *Solaris, /bin/sh is symlinked to ksh on some systems, which breaks zfsync

zfsync's People

Contributors

skoef avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

zfsync's Issues

Error: target ZFS root not found

Could you help please, trying to test the tool with localhost but should work.

Source: zroot/iohyve/bichono
Target: zroot/backup

./zfsync -d -H localhost -T zroot/backup zroot/iohyve/bichono

[Sun Jan 31 12:57:38 CET 2016] Debug: running local command: zpool get feature@large_blocks zroot | awk '/^zroot / {print $3}'
[Sun Jan 31 12:57:38 CET 2016] Debug: running remote command: zpool get feature@large_blocks zroot | awk '/^zroot / {print $3}'
[Sun Jan 31 12:57:38 CET 2016] Debug: ssh args: -l root
Password for root@tripax-seed3:
[Sun Jan 31 12:57:43 CET 2016] Using large blocks while sending
[Sun Jan 31 12:57:43 CET 2016] Debug: mbuffer found in PATH
[Sun Jan 31 12:57:43 CET 2016] Buffering streams with mbuffer
[Sun Jan 31 12:57:43 CET 2016] Checking source and target
[Sun Jan 31 12:57:43 CET 2016] Debug: running local command: zfs list zroot/iohyve/bichono >/dev/null 2>&1
[Sun Jan 31 12:57:43 CET 2016] Debug: running remote command: zfs list zroot/backup >/dev/null 2>&1
[Sun Jan 31 12:57:43 CET 2016] Debug: ssh args: -l root
Password for root@tripax-seed3:
Ambiguous output redirect.
[Sun Jan 31 12:57:51 CET 2016] Error: target ZFS root not found

thks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.