simplesnap-1.0.3/0000755000000000000000000000000012277431533010563 5ustar simplesnap-1.0.3/simplesnap0000755000000000000000000002137412277431533012673 0ustar #!/bin/bash # Simple snapshot manager # Copyright (c) 2014 John Goerzen # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . set -e # Log a message logit () { logger -p info -t "`basename $0`[$$]" "$1" } # Log stdin with the given code. Used normally to log stderr. logstdin () { logger -p info -t "`basename $0`[$$/$1]" } # Run command, logging stderr and exit code runcommand () { logit "Running $*" if "$@" 2> >(logstdin "$1") ; then logit "$1 exited successfully" return 0 else RETVAL="$?" logit "$1 exited with error $RETVAL" return "$RETVAL" fi } exiterror () { logit "$1" echo "$1" 1>&2 exit 10 } syntaxerror () { cat < /dev/null || DATE="date" SED="gsed" gsed &> /dev/null || SED="sed" GREP="ggrep" ggrep &> /dev/null || GREP="grep" # Validating [ -n "$SSHCMD" ] || syntaxerror "Invalid SSH command: $SSHCMD" [ -n "$STORE" ] || syntaxerror "Missing --store" [ -n "$SETNAME" ] || syntaxerror "Missing --setname" [ -n "$CHECKMODE" -o -n "$HOST" ] || syntaxerror "Missing --host" echo "_${STORE}" | $GREP -qv " " || syntaxerror "Space in --store: ${STORE}" TEMPLATEPATTERN="^[a-zA-Z0-9]\+\$" echo "a${SETNAME}" | $GREP -q "${TEMPLATEPATTERN}" || syntaxerror "Invalid characters in setname \"${SETNAME}\"; pattern is \"${TEMPLATEPATTERN}\"" echo "_${SETNAME}" | $GREP -qv '^_-' || syntaxerror "Set name cannot begin with a dash: \"${SETNAME}\"" TEMPLATE="__simplesnap_${SETNAME}_" [ -n "$DATASETDEST" -a -z "$BACKUPDATASET" ] && syntaxerror "--datasetdest given without --backupdataset" MOUNTPOINT="`zfs list -H -o mountpoint -t filesystem \"${STORE}\"`" logit "Store ${STORE} is mounted at ${MOUNTPOINT}" cd "${MOUNTPOINT}" # template - $1 # dataset - $2 listsnaps () { runzfs list -t snapshot -r -d 1 -H -o name "$2" | $GREP "@$1" || true } CHECKRETVAL=0 runzfs () { runcommand /sbin/zfs "$@" } checkbackups () { CHECKHOST="$1" DATASETS="`runzfs list -t filesystem,volume -o name -H -r \"${STORE}/${HOST}\"`" CUTOFF="`$DATE -d \"${CHECKMODE}\" +%s`" for CHECKDS in ${DATASETS}; do # Don't check the top-level host dataset itself. if [ "${CHECKDS}" = "${STORE}/${HOST}" ]; then continue fi FOUNDOK=0 # Extract timestamps for TIMESTAMP in `listsnaps "$TEMPLATE" "$CHECKDS" | $SED 's/^.*_\([^_]\+\)__$/\1/'`; do TSSEC=`$DATE -d "${TIMESTAMP}" +%s` if [ "$TSSEC" -gt "$CUTOFF" ]; then FOUNDOK=1 fi done if [ "$FOUNDOK" = "0" ]; then echo "${CHECKDS} last back up is too old; created at `$DATE -d \"@${TSSEC}\"` but cutoff is `$DATE -d \"@${CUTOFF}\"`!" 1>&2 CHECKRETVAL=10 fi done } if [ -n "$CHECKMODE" ]; then # Do a check only. if [ -n "$HOST" ]; then checkbackups "$HOST" else for HOST in *; do checkbackups "$HOST"; done fi logit "check: exiting with value $CHECKRETVAL" exit $CHECKRETVAL fi runwrap () { if [ "$LOCALMODE" = "on" ]; then runcommand "${WRAPCMD}" reinvoked simplesnapwrap "$@" else runcommand ${SSHCMD} ${HOST} ${WRAPCMD} "$@" fi } if [ ! -d "${MOUNTPOINT}/${HOST}" ]; then runzfs create "${STORE}/${HOST}" fi LOCKFILE="${MOUNTPOINT}/${HOST}/.lock" if dotlockfile -r 0 -l -p "${LOCKFILE}"; then LOCKMETHOD="dotlockfile" logit "Lock obtained at ${LOCKFILE} with dotlockfile" trap "ECODE=$?; dotlockfile -u \"${LOCKFILE}\"; exit $ECODE" EXIT INT TERM else RETVAL="$?" if [ "$RETVAL" = "127" ]; then LOCKMETHOD="mkdir" mkdir "${LOCKFILE}" || exiterror "Could not obtain lock at ${LOCKFILE}; if $0 is not already running, rmdir that path." logit "Lock obtained at ${LOCKFILE} with mkdir" trap "ECODE=$?; rmdir \"${LOCKFILE}\"" EXIT INT TERM else exiterror "Could not obtain lock at ${LOCKFILE}; $0 likely already running." fi fi reap () { DATASET="$1" # We always save the most recent. SNAPSTOREMOVE="`listsnaps \"${TEMPLATE}\" \"${DATASET}\" | head -n -1`" if [ -z "${SNAPSTOREMOVE}" ]; then logit "No snapshots to remove." else for REMOVAL in ${SNAPSTOREMOVE}; do logit "Destroying snapshot ${REMOVAL}" echo "_${REMOVAL}" | $GREP -q '@' || exiterror "PANIC: snapshot name doesn not contain @" runzfs destroy "${REMOVAL}" done fi } backupto() { DATASET="$1" DESTDIR="$2" DATASETPATTERN="^[a-zA-Z0-9_/.-]\+\$" if echo "a$DATASET" | $GREP -vq "$DATASETPATTERN"; then logit "Dataset \"$DATASET\" contains invalid characters; pattern is $DATASETPATTERN" return fi if echo "a$DATASET" | $GREP -q "^[/-]"; then exiterror "Dataset \"$DATASET\" begins with a / or a -; something is wrong. Aborting." fi if echo "a$DATASET" | $GREP -q '\.\.'; then exiterror "Dataset \"$DATASET\" contains ..; something is wrong. Aborting." fi if runwrap sendback "${SETNAME}" "${DATASET}" | \ runzfs receive -F "${DESTDIR}"; then logit "Received backup into ${DESTDIR}" runwrap reap "${SETNAME}" "${DATASET}" reap "${DESTDIR}" else logit "zfs receive died with error: $?" exit 100 fi } # If the user requested only one dataset to be backed up: if [ -n "${BACKUPDATASET}" ]; then logit "Option --backupdataset ${BACKUPDATASET} requested; not asking remote for dataset list." # If the user gave a specified location: if [ -n "${DATASETDEST}" ]; then backupto "${BACKUPDATASET}" "${DATASETDEST}" else backupto "${BACKUPDATASET}" "${STORE}/${HOST}/${BACKUPDATASET}" fi else logit "Finding remote datasets to back up" REMOTEDATASETS="`runwrap listfs`" for DATASET in ${REMOTEDATASETS}; do backupto "${DATASET}" "${STORE}/${HOST}/${DATASET}" done fi logit "Exiting successfully." simplesnap-1.0.3/simplesnapwrap0000755000000000000000000001241612277151401013553 0ustar #!/bin/bash # Simple Snapshot Command Wrapper # Copyright (c) 2014 John Goerzen # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . set -e ZFSCMD=/sbin/zfs ZFS=runzfs EXCLUDEPROP="org.complete.simplesnap:exclude" logit () { logger -p info -t "`basename $0`[$$]" "$1" } exiterror () { logit "$1" exit 10 } runzfs () { logit "Running: $ZFSCMD $*" if $ZFSCMD "$@"; then logit "zfs exited successfully." return 0 else RETVAL="$?" logit "zfs exited with error: $RETVAL" return $RETVAL fi } DATE="gdate" gdate &> /dev/null || DATE="date" SED="gsed" gsed &> /dev/null || SED="sed" GREP="ggrep" ggrep &> /dev/null || GREP="grep" # template - $1 # dataset - $2 listsnaps () { $ZFS list -t snapshot -r -d 1 -H -o name "$2" | $GREP "@$1" || true } PATTERN="^[a-zA-Z0-9_/. -]\+\$" if [ "$1" = "reinvoked" ]; then shift logit "Reinvoked with paramters \"$*\"" shift # Drop the call to simplesnapwrap # Validate again. Just to be sure. echo ".$*" | $GREP -q "${PATTERN}" || exiterror "Invalid characters found on re-validate; pattern is ${PATTERN}" echo ".$*" | $GREP -vq '\.\.' || exiterror "Found .. in input; aborting." # We don't want any paramters to contain a space or leading dash. for ARG; do echo ",${ARG}" | $GREP -vq '^,-' || exiterror "Found leading '-' in parameter \"${ARG}\"; aborting." echo ",${ARG}" | $GREP -vq ' ' || exiterror "Found space in parameters; aborting." done MODE="$1" shift || exiterror "Missing mode." case "$MODE" in "listfs") logit "Listing ZFS datasets without ${EXCLUDEPROP}=on" $ZFS list -t filesystem,volume -o "name,${EXCLUDEPROP}" -H | \ $GREP -v $'\ton$' | $SED $'s/\t.*$//' ;; "sendback") # Next lines shared with reap TEMPLATE="__simplesnap_$1_" TEMPLATEPATTERN="^[a-zA-Z0-9]\+\$" echo "a$1" | $GREP -q "${TEMPLATEPATTERN}" || exiterror "Invalid characters in sendback template \"$1\"; pattern is ${TEMPLATEPATTERN}" DATASET="$2" echo "_${DATASET}" | $GREP -vq " " || exiterror "Space found in dataset name" [ -z "${DATASET}" ] && exiterror "No dataset given." [ -z "$1" ] && exiterror "No template given." logit "Listing snapshots on \"${DATASET}\" with template \"${TEMPLATE}\"" OLDESTSNAP="`listsnaps \"${TEMPLATE}\" \"${DATASET}\" | head -n 1`" if [ -z "${OLDESTSNAP}" ]; then logit "Found no existing snapshot." else logit "Will use ${OLDESTSNAP} as basis." fi # Make a new snapshot. NEWSNAP="${TEMPLATE}`$DATE +%FT%T`__" NEWFULLSNAP="${DATASET}@${NEWSNAP}" logit "Making snapshot ${NEWFULLSNAP}" $ZFS snapshot "${NEWFULLSNAP}" if [ -z "${OLDESTSNAP}" ]; then # No existing snapshot. Send the whole thing. logit "Sending non-incremental stream." $ZFS send "${NEWFULLSNAP}" else # Use the oldest existing snapshot. logit "Sending incremental stream back to ${OLDESTSNAP}" $ZFS send -I "${OLDESTSNAP}" "${NEWFULLSNAP}" fi ;; "reap") # Next lines shared with sendback TEMPLATE="__simplesnap_$1_" TEMPLATEPATTERN="^[a-zA-Z0-9_]\+\$" echo "_$TEMPLATE" | $GREP -q "${TEMPLATEPATTERN}" || exiterror "Invalid characters in reap template; pattern is ${TEMPLATEPATTERN}" DATASET="$2" echo "_${DATASET}" | $GREP -vq " " || exiterror "Space found in dataset name" [ -z "${DATASET}" ] && exiterror "No dataset given." [ -z "$1" ] && exiterror "No template given." # We always save the most recent. SNAPSTOREMOVE="`listsnaps \"${TEMPLATE}\" \"${DATASET}\" | head -n -1`" if [ -z "${SNAPSTOREMOVE}" ]; then logit "No snapshots to remove." else for REMOVAL in ${SNAPSTOREMOVE}; do logit "Destroying snapshot ${REMOVAL}" echo "_${REMOVAL}" | $GREP -q '@' || exiterror "PANIC: snapshot name doesn't contain '@'" $ZFS destroy "${REMOVAL}" done fi ;; *) exiterror "Invalid mode \"${MODE}\" specified." ;; esac logit "Exiting successfully." exit 0 fi CMD="${SSH_ORIGINAL_COMMAND}" logit "Invoked with parameters \"$*\" and SSH_ORIGINAL_COMMAND: \"${CMD}\"" if [ -z "${SSH_ORIGINAL_COMMAND}" ]; then echo "simplesnapwrap: This program is to be run from ssh." exiterror "Not run from ssh." fi # Sanitize input. We don't want special characters here. echo ".${CMD}" | $GREP -q "${PATTERN}" || exiterror "Invalid characters in input; pattern is: ${PATTERN}" echo ".${CMD}" | $GREP -vq '\.\.' || exiterror "Found .. in input; aborting." logit "Reinvoking to parse parameters" exec "$0" reinvoked ${CMD} simplesnap-1.0.3/examples/0000755000000000000000000000000012277427766012416 5ustar simplesnap-1.0.3/examples/cron.weekly.zfsnap.serverhost0000644000000000000000000000033712276722267020300 0ustar #!/bin/bash # Create weekly snapshots, lasting 1 month on the serverhost # (expiry time different on the backuphost) # The serverhost daily job will expire them. set -e /usr/sbin/zfSnap -a 1m -p hostname-weekly- -r tank simplesnap-1.0.3/examples/cron.hourly.simplesnap.backuphost0000644000000000000000000000162112276722523021123 0ustar #!/bin/bash # Reach out to each host hourly. This script runs on the backuphost. set -e # We load the SETNAME from a file I created with: # echo setname > /bakfs/local-simplesnap-setname SETNAME="`cat /bakfs/local-simplesnap-setname`" # Or you could simply set it with: # SETNAME="mainset" SSHCMD="ssh -i /root/.ssh/id_rsa_simplesnap" if [ -z "$SETNAME" ]; then echo "Failure: couldn't find a setname" exit 5 fi # Change this to where you store your backups. STORE="bakfs/simplesnap" SIMPLESNAP () { simplesnap --store "$STORE" --setname "$SETNAME" \ --sshcmd "$SSHCMD" "$@" } for HOST in host1 host2 host3 host4; do SIMPLESNAP --host $HOST || echo "Simplesnap failure on host $HOST: $?" done # Only do laptophost at certain times HOUR=`date +%H` if [ "$HOUR" -eq 12 ] || [ "$HOUR" -lt 7 ] || [ "$HOUR" -gt 23 ] ; then SIMPLESNAP --host laptophost || true # laptop, don't squawk fi simplesnap-1.0.3/examples/cron.hourly.zfsnap.serverhost0000644000000000000000000000033612276722361020314 0ustar #!/bin/bash # Create hourly snapshots, lasting 2 days on the serverhost # (expiry time different on the backuphost) # The serverhost daily job will expire them. set -e /usr/sbin/zfSnap -a 2d -p hostname-hourly- -r tank simplesnap-1.0.3/examples/cron.monthly.zfsnap.serverhost0000644000000000000000000000034212276722314020457 0ustar #!/bin/bash # Create monthly snapshots, lasting 3 months on the serverhost # (expiry time different on the backuphost) # The serverhost daily job will expire them. set -e /usr/sbin/zfSnap -a 3m -p hostname-monthly- -r tank simplesnap-1.0.3/examples/cron.daily.simplesnap.backuphost0000644000000000000000000000277412277427766020731 0ustar #!/bin/bash # Daily script to run on the backuphost. Do the check of the backups and # clean up old snapshots. set -e # We load the SETNAME from a file I created with: # echo setname > /bakfs/local-simplesnap-setname SETNAME="`cat /bakfs/local-simplesnap-setname`" # Or you could simply say: # SETNAME="mainset" if [ -z "$SETNAME" ]; then echo "Failure: couldn't find a setname" exit 5 fi # Where your backups are stored STORE="bakfs/simplesnap" SIMPLESNAP () { simplesnap --store "$STORE" --setname "$SETNAME" \ "$@" } if SIMPLESNAP --check '3 days ago'; then for HOSTDS in `zfs list -o name -H -r -d 1 -t filesystem "$STORE"`; do if [ "$HOSTDS" = "$STORE" ]; then continue # Skip the simplesnap dataset itself fi HOSTNAME="`basename ${HOSTDS}`" # Delete hourly snapshots more than 2 days old. zfSnap -v -F 2d -p "${HOSTNAME}-hourly-" # Delete daily snapshots more than 1 month old. zfSnap -v -F 1m -p "${HOSTNAME}-daily-" # Delete weekly snapshots more than 2 months old. zfSnap -v -F 2m -p "${HOSTNAME}-weekly-" # Delete monthly snapshots more than 18 months old. zfSnap -v -F 18m -p "${HOSTNAME}-monthly-" done else echo "Check failed: $?, skipping snapshot cleanup." fi # If using zfSnap, this might be useful to find any extraneous snapshots to remove #if zfs list -H -o name -t snap -r "$STORE" | egrep -v "(-hourly-2|-daily-2|-weekly-2|-monthly-2|@__simplesnap_${SETNAME}_)"; then # echo "Please clean up above snapshots." # exit 5 #fi simplesnap-1.0.3/examples/cron.daily.zfsnap.serverhost0000644000000000000000000000062612276722427020101 0ustar #!/bin/bash # Create daily snapshots lasting 1 week on the serverhost # (different time on the backuphost) set -e /usr/sbin/zfSnap -a 1w -p hostname-daily- -r crypt/jgoerzen tank # Now apply the expiration settings for the other snapshots. /usr/sbin/zfSnap -d -p hostname-hourly- /usr/sbin/zfSnap -d -p hostname-daily- /usr/sbin/zfSnap -d -p hostname-weekly- /usr/sbin/zfSnap -d -p hostname-monthly- simplesnap-1.0.3/debian/0000755000000000000000000000000012277431542012005 5ustar simplesnap-1.0.3/debian/rules0000755000000000000000000000116012276721426013065 0ustar #!/usr/bin/make -f # -*- makefile -*- # Sample debian/rules that uses debhelper. # This file was originally written by Joey Hess and Craig Small. # As a special exception, when this file is copied by dh-make into a # dh-make output file, you may use that output file without restriction. # This special exception was added by Craig Small in version 0.37 of dh-make. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 %: dh $@ override_dh_auto_install-indep: install -m 0755 -g root -o root simplesnap debian/simplesnap/usr/sbin/ install -m 0755 -g root -o root simplesnapwrap debian/simplesnap/usr/sbin/ simplesnap-1.0.3/debian/compat0000644000000000000000000000000212276506274013207 0ustar 8 simplesnap-1.0.3/debian/simplesnap.manpages0000644000000000000000000000002112276721127015666 0ustar doc/simplesnap.8 simplesnap-1.0.3/debian/simplesnap.examples0000644000000000000000000000001312276722756015723 0ustar examples/* simplesnap-1.0.3/debian/docs0000644000000000000000000000001312276721042012646 0ustar README.txt simplesnap-1.0.3/debian/dirs0000644000000000000000000000001112276721154012661 0ustar usr/sbin simplesnap-1.0.3/debian/changelog0000644000000000000000000000141112277431533013654 0ustar simplesnap (1.0.3) unstable; urgency=low * Add --backupdataset and --datasetdest options. * Enhance examples and documentation. * Fixed bug in --local -- John Goerzen Fri, 14 Feb 2014 00:22:48 -0600 simplesnap (1.0.2) unstable; urgency=low * Enhanced logging in simplesnapwrap. * Added information about interrogating the backup pool to the manpage. -- John Goerzen Thu, 13 Feb 2014 00:47:10 -0600 simplesnap (1.0.1) unstable; urgency=low * Fixed exit code from simplesnap. -- John Goerzen Wed, 12 Feb 2014 02:45:03 -0600 simplesnap (1.0.0) unstable; urgency=low * Initial Release. Closes: #738740. -- John Goerzen Tue, 11 Feb 2014 00:44:47 -0600 simplesnap-1.0.3/debian/source/0000755000000000000000000000000012276506274013311 5ustar simplesnap-1.0.3/debian/source/format0000644000000000000000000000001512276506274014520 0ustar 3.0 (native) simplesnap-1.0.3/debian/copyright0000644000000000000000000000212112276723070013733 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: simplesnap Source: Files: * Copyright: 2014 John Goerzen License: GPL-3.0+ Files: debian/* Copyright: 2014 John Goerzen License: GPL-3.0+ License: GPL-3.0+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. . This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . You should have received a copy of the GNU General Public License along with this program. If not, see . . On Debian systems, the complete text of the GNU General Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". simplesnap-1.0.3/debian/control0000644000000000000000000000303412276723271013412 0ustar Source: simplesnap Section: admin Priority: extra Maintainer: John Goerzen Build-Depends: debhelper (>= 8.0.0) Standards-Version: 3.9.3 Homepage: https://github.com/jgoerzen/simplesnap Vcs-Git: https://github.com/jgoerzen/simplesnap.git Vcs-Browser: https://github.com/jgoerzen/simplesnap Package: simplesnap Architecture: all Depends: ${misc:Depends}, zfs-fuse | zfsutils | zfs, liblockfile-bin Suggests: zfsnap Description: Simple and powerful network transmission of ZFS snapshots simplesnap is a simple way to send ZFS snapshots across a net‐ work. Although it can serve many purposes, its primary goal is to manage backups from one ZFS filesystem to a backup filesystem also running ZFS, using incremental backups to minimize network traffic and disk usage. . simplesnap it is designed to perfectly compliment snapshotting tools, permitting rotating backups with arbitrary retention periods. It lets multiple machines back up a single target, lets one machine back up multiple targets, and keeps it all straight. . simplesnap is easy; there is no configuration file needed. One ZFS property is available to exclude datasets/filesystems. ZFS datasets are automatically discovered on machines being backed up. . simplesnap is robust in the face of interrupted transfers, and needs little help to keep running. . nlike many similar tools, simplesnap does not require full root access to the machines being backed up. It runs only a small wrapper as root, and the wrapper has only three commands it implements. simplesnap-1.0.3/COPYING0000644000000000000000000010451312276463635011631 0ustar GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . simplesnap-1.0.3/INSTALL.txt0000644000000000000000000000157512276502236012440 0ustar PREREQUISITES Requires: * GNU bash * logger (from bsdutils on Linux; ftp://ftp.us.kernel.org/pub/linux/utils/util-linux-ng/ or git://git.debian.org/~lamont/util-linux.git ) Highly recommended: * An automatic snapshotting and rotation system. I use zfSnap from https://github.com/graudeejs/zfSnap * optional but recommended: dotlockfile from liblockfile. This has been tested on Debian Linux with ZFSOnLinux. It will probably work on FreeBSD or Solaris as well, especially if the GNU tools are installed or available under "g" names. The script will try to find them with those names and use them if possible. INSTALLATION Copy simplesnap somewhere on the host that will store backups and mark it executable. Copy simplesnapwrap somewhere on the hosts that will be backed up and mark it executable. If the host storing backups will also be backed up, it needs both. simplesnap-1.0.3/TODO0000644000000000000000000000001612277427766011265 0ustar reapothersets simplesnap-1.0.3/README.txt0000644000000000000000000000072012277427766012275 0ustar simplesnap is a powerful system for transferring ZFS snapshots across a network. It has excellent documentation. See it at: Or, if simplesnap is installed on your system, simply run: man simplesnap See also the examples included in the source distribution. See also my blog post about it: simplesnap-1.0.3/doc/0000755000000000000000000000000012277427766011345 5ustar simplesnap-1.0.3/doc/manpage.links0000644000000000000000000000000012277151521013764 0ustar simplesnap-1.0.3/doc/simplesnap.html0000644000000000000000000010043012277427766014404 0ustar simplesnap

simplesnap

Name

simplesnap -- Simple and powerful way to send ZFS snapshots across a network

Synopsis

simplesnap [--sshcmd COMMAND] [--wrapcmd COMMAND] [--local] [--backupdataset DATASET [--datasetdest DEST]] --store STORE --setname NAME --host HOST

simplesnap --check TIMEFRAME --store STORE --setname NAME [--host HOST]

Description

simplesnap is a simple way to send ZFS snapshots across a network. Although it can serve many purposes, its primary goal is to manage backups from one ZFS filesystem to a backup filesystem also running ZFS, using incremental backups to minimize network traffic and disk usage.

simplesnap is FLEXIBLE; it is designed to perfectly compliment snapshotting tools, permitting rotating backups with arbitrary retention periods. It lets multiple machines back up a single target, lets one machine back up multiple targets, and keeps it all straight.

simplesnap is EASY; there is no configuration file needed. One ZFS property is available to exclude datasets/filesystems. ZFS datasets are automatically discovered on machines being backed up.

simplesnap is SAFE; it is robust in the face of interrupted transfers, and needs little help to keep running.

simplesnap is SECURE; unlike many similar tools, it does not require full root access to the machines being backed up. It runs only a small wrapper as root, and the wrapper has only three commands it implements.

Feature List

Besides the above, simplesnap:

  • Does one thing and does it well. It is designed to be used with a snapshot auto-rotator on both ends (such as zfSnap). simplesnap will transfer snapshots made by other tools, but will not destroy them on either end.

  • Requires ssh public key authorization to the host being backed up, but does not require permission to run arbitrary commands. It has a wrapper to run on the backup host, written in bash, which accepts only three operations and performs them simply. It is suitable for a locked-down authorized_keys file.

  • Creates minimal snapshots for its own internal purposes, generally leaving no more than 1 or 2 per dataset, and reaps them automatically without touching others.

  • Is a small program, easily audited. In fact, most of the code is devoted to sanity-checking, security, and error checking.

  • Automatically discovers what datasets to back up from the remote. Uses a user-defined zfs property to exclude filesystems that should not be backed up.

  • Logs copiously to syslog on all hosts involved in backups.

  • Intelligently supports a single machine being backed up by multiple backup hosts, or onto multiple sets of backup media (when, for instance, backup media is cycled into offsite storage)

Method of Operation

simplesnap's operation is very simple.

The simplesnap program runs on the machine that stores the backups -- we'll call it the backuphost. There is a restricted remote command wrapper called simplesnapwrap that runs on the machine being backed up -- we'll call it the activehost. simplesnapwrap is never invoked directly by the end-user; it is always called remotely by simplesnap.

With simplesnap, the backuphost always connects to the activehost -- never the other way round.

simplesnap runs in the backuphost, and first connects to the simplesnapwrap on the activehost and asks it for a list of the ZFS datasets ("listfs" operation). simplesnapwrap responds with a list of all ZFS datasets that were not flagged for exclusion.

Next, simplesnap connects back to simplesnapwrap once for each dataset to be backed up -- the "sendback" operation. simplesnap passes along to it only two things: the setname and the dataset (filesystem) name.

simplesnapwrap looks to see if there is an existing simplesnap snapshot corresponding to that SETNAME. If not, it creates one and sends it as a full, non-incremental backup. That completes the job for that dataset.

If there is an existing snapshot for that SETNAME, simplesnapwrap creates a new one, constructing the snapshot name containing a timestamp and the SETNAME, then sends an incremental, using the oldest snapshot from that setname as the basis for zfs send -I.

After the backuphost has observed zfs receive exiting without error, it contacts simplesnapwrap once more and requests the "reap" operation. This cleans up the old snapshots for the given SETNAME, leaving only the most recent. This is a separate operation in simplesnapwrap ensuring that even if the transmission is interrupted, still it will be OK in the end because zfs receive -F is used, and the data will come across next time.

The idea is that some system like zfSnap will be used on both ends to make periodic snapshots and clean them up. One can use careful prefix names with zfSnap to use different prefixes on each activehost, and then implement custom cleanup rules with -F on the holderhost.

Quick Start

This section will describe how a first-time simplesnap user can get up and running quickly. It assumes you already have simplesnap installed and working on your system. If not, please follow the instructions in the INSTALL.txt file in the source distribution.

As above, I will refer to the machine storing the backups as the "backuphost" and the machine being backed up as the "activehost".

First, on the backuphost, as root, generate an ssh keypair that will be used exclusively for simplesnap.

ssh-keygen -t rsa -f ~/.ssh/id_rsa_simplesnap

When prompted for a passphrase, leave it empty.

Now, on the activehost, edit or create a file called ~/.ssh/authorized_keys. Initialize it with the content of ~/.ssh/id_rsa_simplesnap.pub from the backuphost. (Or, add to the end, if you already have lines in the file.) Then, at the beginning of that one very long line, add text like this:

command="/usr/sbin/simplesnapwrap",from="1.2.3.4",
no-port-forwarding,no-X11-forwarding,no-pty 

(I broke that line into two for readability, but this must all be on a single line in your file.)

The 1.2.3.4 is the IP address that connections from the backuphost will appear to come from. It may be omitted if the IP is not static, but it affords a little extra security. The line will wind up looking like:

command="/usr/sbin/simplesnapwrap",from="1.2.3.4",
no-port-forwarding,no-X11-forwarding,no-pty ssh-rsa AAAA....

(Again, this should all be on one huge line.)

If there are any ZFS datasets you do not want to be backed up, set org.complete.simplesnap:exclude property on the activehost to on. For instance:

zfs set org.complete.simplesnap:exclude=on tank/junkdata

Now, back on the backuphost, you should be able to run:

ssh -i ~/.ssh/id_rsa_simplesnap activehost

say yes when asked if you want to add the key to the known_hosts file. At this point, you should see output containing:

"simplesnapwrap: This program is to be run from ssh."

If you see that, then simplesnapwrap was properly invoked remotely.

Now, create a ZFS filesystem to hold your backups. For instance:

zfs create tank/simplesnap

I often recommend compression for simplesnap datasets, so:

zfs set compression=lz4 tank/simplesnap

(If that gives an error, use compression=on instead.)

Now, you can run the backup:

simplesnap --host activehost --setname mainset --store tank/simplesnap --sshcmd "ssh -i /root/.ssh/id_rsa_simplesnap"

You can monitor progress in /var/log/syslog. If all goes well, you will see filesystems start to be populated under tank/simplesnap/host.

Simple!

Now, go test that you have the data you expected to: look at your STORE filesystems and make sure they have everything expected. Test repeatedly over time that you can restore as you expect from your backups.

Advanced: SETNAME usage

Most people will always use the same SETNAME. The SETNAME is used to track and name the snapshots on the remote end. simplesnap tries to always leave one snapshot on the remote, to serve as the base for a future incremental.

In some situations, you may have multiple bases for incrementals. The two primary examples are two different backup servers backing up the same machine, or having two sets of backup media and rotating them to offsite storage. In these situations, you will have to keep different snapshots on the activehost for the different backups, since they will be current to different points in time.

Options

All simplesnap options begin with two dashes (`--'). Most take a parameter, which is to be separated from the option by a space. The equals sign is not a valid separator for simplesnap.

The normal simplesnap mode is backing up. An alternative check mode is available, which requires fewer parameters. This mode is described below.

--backupdataset DATASET

Normally, simplesnap automatically obtains a list of datasets to back up from the remote, and backs up all of them except those that define the org.complete.simplesnap:exclude=on property. With this option, simplesnap does not bother to ask the remote for a list of datasets, and instead backs up only the one precise DATASET given. For now, ignored when --check is given, but that may change in the future. It would be best to not specify this option with --check for now.

--check TIMEFRAME

Do not back up, but check existing backups. If any datasets' newest backup is older than TIMEFRAME, print an error and exit with a nonzero code. Scans all hosts unless a specific host is given with --host. The parameter is in the format given to GNU date(1); for instance, --check "30 days ago". Remember to enclose it in quotes if it contains spaces.

--datasetdest DEST

Valid only with --backupdataset, gives a specific destination for the backup, whith may be outside the STORE. The STORE must still exist, as it is used for storing lockfiles and such.

--host HOST

Gives the name of the host to back up. This is both passed to ssh and used to name the backup sets.

In a few situations, one may not wish to use the same name for both. It is recommend to use the Host and HostName options in ~/.ssh/config to configure aliases in this situation.

--local

Specifies that the host being backed up is local to the machine. Do not use ssh to contact it, and invoke the wrapper directly.

--sshcmd COMMAND

Gives the command to use to connect to the remote host. Defaults to "ssh". It may be used to select an alternative configuration file or keypair. Remember to quote it per your shell if it contains spaces. For example: --sshcmd "ssh -i /root/.id_rsa_simplesnap". This command is ignored when --local or --check is given.

--setname SETNAME

Gives the backup set name. Can just be a made-up word if multiple sets are not needed; for instance, the hostname of the backup server. This is used as part of the snapshot name.

--store STORE

Gives the ZFS dataset name where the data will be stored. Should not begin with a slash. The mountpoint will be obtained from the ZFS subsystem. Always required.

--wrapcmd COMMAND

Gives the path to simplesnapwrap (which must be on the remote machine unless --local is given). Not usually relevant, since the command parameter in ~root/.ssh/authorized_keys gives the path. Default: "simplesnapwrap"

Backup Interrogation

Since simplesnap stores backups in standard ZFS datasets, you can use standard ZFS tools to obtain information about backups. Here are some examples.

Space used per host

Try something like this:

# zfs list -r -d 1 tank/store
NAME               USED  AVAIL  REFER  MOUNTPOINT
tank/store         540G   867G    34K  /tank/store
tank/store/host1   473G   867G    32K  /tank/store/host1
tank/store/host2  54.9G   867G    32K  /tank/store/host2
tank/store/host3  12.2G   867G    31K  /tank/store/host3

Here, you can see that the total size of the simplesnap data is 540G - the USED value from the top level. In this example, host1 was using the most space -- 473G -- and host3 the least -- 12.2G. There is 867G available on this zpool for backups.

The -r parameter to zfs list requests a recursive report, but the -d 1 parameter sets a maximum depth of 1 -- so you can see just the top-level hosts without all their component datasets.

Space used by a host

Let's say that you had the above example, and want to drill down into more detail. Perhaps, for instance, we continue the above example and drill down into host2:

# zfs list -r tank/store/host2
NAME                                 USED  AVAIL  REFER  MOUNTPOINT
tank/store/host2                    54.9G   867G    32K  /tank/...
tank/store/host2/tank               49.8G   867G    32K  /tank/...
tank/store/host2/tank/home          7.39G   867G  6.93G  /tank/...
tank/store/host2/tank/vm            42.4G   867G    30K  /tank/...
tank/store/host2/tank/vm/vm1        32.0G   867G  29.7G  -
tank/store/host2/tank/vm/vm2        10.4G   867G  10.4G  -
tank/store/host2/rpool              5.12G   867G    32K  /tank/...
tank/store/host2/rpool/misc          521M   867G   521M  /tank/...
tank/store/host2/rpool/host2-1      4.61G   867G    33K  /tank/...
tank/store/host2/rpool/host2-1/ROOT  317M   867G   312M  /tank/...
tank/store/host2/rpool/host2-1/usr  3.76G   867G  3.76G  /tank/...
tank/store/host2/rpool/host2-1/var   554M   867G   401M  /tank/...

I've trimmed the "mountpoint" column here so it doesn't get too wide for the screen.

You see here the same 54.9G used as in the previous example, but now you can trace it down. There were two zpools on host2: tank and rpool. Most of the backup space -- 49.8G of the 54.9G -- is used by tank, and only 5.12G by rpool. And in tank, 42.4G is used by vm. Tracing it down, of that 42.4G used by vm, 32G is in vm1 and 10.4G in vm2. Notice how the values at each level of the tree include their descendents.

So in this example, vm1 and vm2 are zvols corresponding to virtual machines, and clearly take up a lot of space. Notice how vm1 says it uses 32.0G but in the refer column, it only refers to 29.7G? That means that the latest backup for vm2 used 29.7G, but when you add in the snapshots for that dataset, the total space consumed is 32.0G.

Let's look at an alternative view that will make the size consumed by snapshots more clear:

# zfs list -o space -r tank/store/host2
NAME                         AVAIL   USED  USEDSNAP  USEDDS  USEDCHILD
.../host2                     867G  54.9G         0     32K      54.9G
.../host2/tank                867G  49.8G         0     32K      49.8G
.../host2/tank/home           867G  7.39G      474M   6.93G          0
.../host2/tank/vm             867G  42.4G       50K     30K      42.4G
.../host2/tank/vm/vm1         867G  32.0G     2.35G   29.7G          0
.../host2/tank/vm/vm1         867G  10.4G       49K   10.4G          0
.../host2/rpool               867G  5.12G         0     32K      5.12G
.../host2/rpool/misc          867G   521M       51K    521M          0
.../host2/rpool/host2-1       867G  4.61G       51K     33K      4.61G
.../host2/rpool/host2-1/ROOT  867G   317M     5.44M    312M          0
.../host2/rpool/host2-1/usr   867G  3.76G      208K   3.76G          0
.../host2/rpool/host2-1/var   867G   554M      153M    401M          0

(Again, I've trimmed some irrelevant columns from this output.)

The AVAIL and USED columns are the same as before, but now you have a breakdown of what makes up the USED column. USEDSNAP is the space used by the snapshots of that particular dataset. USEDDS is the space used by that dataset directly -- the same value as was in REFER before. And USEDCHILD is the space used by descendents of that dataset.

The USEDSNAP column is the easiest way to see the impact your retention policies have on your backup space consumption.

Viewing snapshots of a dataset

Let's take one example from before -- the 153M of snapshots in host2-1/var, and see what we can find.

# zfs list -t snap -r tank/store/host2/rpool/host2-1/var 
NAME                                              USED  AVAIL  REFER
...
.../var@host2-hourly-2014-02-11_05.17.02--2d       76K      -   402M
.../var@host2-hourly-2014-02-11_06.17.01--2d       77K      -   402M
.../var@host2-hourly-2014-02-11_07.17.01--2d     18.8M      -   402M
.../var@host2-daily-2014-02-11_07.17.25--1w        79K      -   402M
.../var@host2-hourly-2014-02-11_08.17.01--2d      156K      -   402M
.../var@host2-monthly-2014-02-11_09.01.36--1m     114K      -   402M
...

In this output, the REFER column is the amount of data pointed to by that snapshot -- that is, the size of /var at the moment the snapshot is made. And the USED column is the amount of space that would be freed if just that snapshot were deleted.

Note this important point: it is normal for the sum of the values in the USED column to be less than the space consumed by the snapshots of the datasets as reported by USEDSNAP in the previous example. The reason is that the USED column is the data unique to that one snapshot. If, for instance, 100MB of data existed on the system being backed up for three hours yesterday, each snapshot could very well show less than 100KB used, because that 100MB isn't unique to a particular snapshot. Until, that is, two of the three snapshots referncing the 100MB data are destroyed; then the USED value of the last one referencing it will suddenly jump to 100MB higher because now it references unique data.

One other point -- an indication that the last backup was successfully transmitted is the presence of a __simplesnap_...__ snapshot at the end of the list. Do not delete it.

Finding what changed over time

The zfs diff command can let you see what changed over time -- either across a single snapshot, or across many. Let's take a look.

# zfs diff .../var@host2-hourly-2014-02-11_05.17.02--2d \
  .../var@host2-hourly-2014-02-11_06.17.01--2d \
  | sort -k2 | less
M	/tank/store/host2/rpool/host2-1/var/log/Xorg.0.log
M	/tank/store/host2/rpool/host2-1/var/log/auth.log
M	/tank/store/host2/rpool/host2-1/var/log/daemon.log
...
M	/tank/store/host2/rpool/host2-1/var/spool/anacron/cron.daily
M	/tank/store/host2/rpool/host2-1/var/spool/anacron/cron.monthly
M	/tank/store/host2/rpool/host2-1/var/spool/anacron/cron.weekly
M	/tank/store/host2/rpool/host2-1/var/tmp

Here you can see why there was just a few KB of changes in that snapshot: mostly just a little bit of logging was happening on the system. Now let's inspect the larger snapshot:

# zfs diff .../var@host2-hourly-2014-02-11_07.17.01--2d \
   .../var@host2-daily-2014-02-11_07.17.25--1w \
   | sort -k2 | less
M	/tank/store/host2/rpool/host2-1/var/backups
+	/tank/store/host2/rpool/host2-1/var/backups/dpkg.status.0
-	/tank/store/host2/rpool/host2-1/var/backups/dpkg.status.0
+	/tank/store/host2/rpool/host2-1/var/backups/dpkg.status.1.gz
R	/tank/store/host2/rpool/host2-1/var/backups/dpkg.status.1.gz -> /tank/store/host2/rpool/host2-1/var/backups/dpkg.status.2.gz
R	/tank/store/host2/rpool/host2-1/var/backups/dpkg.status.2.gz -> /tank/store/host2/rpool/host2-1/var/backups/dpkg.status.3.gz
...
M	/tank/store/host2/rpool/host2-1/var/cache/apt
R	/tank/store/host2/rpool/host2-1/var/cache/apt/pkgcache.bin.KdsMLu -> /tank/store/host2/rpool/host2-1/var/cache/apt/pkgcache.bin

Here you can see some file rotation going on, and a temporary file being renamed to permanent. Normal daily activity on a system, but now you know what was taking up space.

Warnings, Cautions, and Good Practices

Importance of Testing

Any backup scheme should be tested carefully before being relied upon to serve its intended purpose. This item is not simplesnap-specific, but pertains to every backup solution: test that you are backing up the data you expect to before you need it.

Use of zfs receive -F

In order to account for various situations that could lead to divergence of filesystems, including the simple act of mounting them, simplesnap always uses zfs receive -F. Any local changes you make to the simplesnap store datasets will be lost at any time. If you need to make local changes there, it is best to copy them elsewhere.

Extraneous Snapshot Buildup

Since simplesnap sends all snapshots, it is possible that locally-created snapshots made outside of your rotation scheme will also be sent to your backuphost. These may not be automatically reaped there, and may stick around. An example at the end of the cron.daily.simplesnap.backuphost file included with simplesnap is one way to check for these. They could automatically be reaped with zfs destroy as well, but this must be carefully tuned to local requirements, so an example of doign that is intentionally not supplied with the distribution.

Internal simplesnap snapshots

simplesnap creates snapshots beginning with __simplesnap_ followed by your SETNAME. Do not create, remove, or alter these snapshots in any way, either on the activehost or the backuphost. Doing so may lead to unpredictable side-effects.

Bugs

Ordinarily, an interrupted transfer is no problem for simplesnap. However, the very first transfer of a dataset poses a bit of a problem, since the simplesnap wrapper can't detect failure in this one special case. If your first transfer gets interrupted, simply zfs destroy the __simplesnap_...__ snapshot on the activehost and rerun. NEVER DESTROY __simplesnap SNAPSHOTS IN ANY OTHER SITUATION!

See Also

zfSnap (1), zfs (8).

The simplesnap homepage: https://github.com/jgoerzen/simplesnap

The examples included with the simplesnap distribution, or on its homepage.

The zfSnap package compliments simplesnap perfectly. Find it at https://github.com/graudeejs/zfSnap.

AUTHOR

This software and manual page was written by John Goerzen . Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 3 any later version published by the Free Software Foundation. The complete text of the GNU General Public License is included in the file COPYING in the source distribution.

simplesnap-1.0.3/doc/simplesnap.sgml0000644000000000000000000010327412277427766014413 0ustar manpage.1'. You may view the manual page with: `docbook-to-man manpage.sgml | nroff -man | less'. A typical entry in a Makefile or Makefile.am is: manpage.1: manpage.sgml docbook-to-man $< > $@ The docbook-to-man binary is found in the docbook-to-man package. Please remember that if you create the nroff version in one of the debian/rules file targets (such as build), you will need to include docbook-to-man in your Build-Depends control field. --> JOHN"> GOERZEN"> 8"> jgoerzen@complete.org"> simplesnap"> simplesnap"> Debian"> GNU"> GPL"> ]>
&dhemail;
&dhfirstname; &dhsurname; 2014 &dhusername;
&dhucpackage; &dhsection; &dhpackage; Simple and powerful way to send ZFS snapshots across a network &dhpackage; COMMAND COMMAND DATASET DEST STORE NAME HOST &dhpackage; TIMEFRAME STORE NAME HOST Description &simplesnap; is a simple way to send ZFS snapshots across a network. Although it can serve many purposes, its primary goal is to manage backups from one ZFS filesystem to a backup filesystem also running ZFS, using incremental backups to minimize network traffic and disk usage. &simplesnap; is FLEXIBLE; it is designed to perfectly compliment snapshotting tools, permitting rotating backups with arbitrary retention periods. It lets multiple machines back up a single target, lets one machine back up multiple targets, and keeps it all straight. &simplesnap; is EASY; there is no configuration file needed. One ZFS property is available to exclude datasets/filesystems. ZFS datasets are automatically discovered on machines being backed up. &simplesnap; is SAFE; it is robust in the face of interrupted transfers, and needs little help to keep running. &simplesnap; is SECURE; unlike many similar tools, it does not require full root access to the machines being backed up. It runs only a small wrapper as root, and the wrapper has only three commands it implements. Feature List Besides the above, &simplesnap;: Does one thing and does it well. It is designed to be used with a snapshot auto-rotator on both ends (such as zfSnap). simplesnap will transfer snapshots made by other tools, but will not destroy them on either end. Requires ssh public key authorization to the host being backed up, but does not require permission to run arbitrary commands. It has a wrapper to run on the backup host, written in bash, which accepts only three operations and performs them simply. It is suitable for a locked-down authorized_keys file. Creates minimal snapshots for its own internal purposes, generally leaving no more than 1 or 2 per dataset, and reaps them automatically without touching others. Is a small program, easily audited. In fact, most of the code is devoted to sanity-checking, security, and error checking. Automatically discovers what datasets to back up from the remote. Uses a user-defined zfs property to exclude filesystems that should not be backed up. Logs copiously to syslog on all hosts involved in backups. Intelligently supports a single machine being backed up by multiple backup hosts, or onto multiple sets of backup media (when, for instance, backup media is cycled into offsite storage) Method of Operation &simplesnap;'s operation is very simple. The simplesnap program runs on the machine that stores the backups -- we'll call it the backuphost. There is a restricted remote command wrapper called simplesnapwrap that runs on the machine being backed up -- we'll call it the activehost. simplesnapwrap is never invoked directly by the end-user; it is always called remotely by simplesnap. With &simplesnap;, the backuphost always connects to the activehost -- never the other way round. simplesnap runs in the backuphost, and first connects to the simplesnapwrap on the activehost and asks it for a list of the ZFS datasets ("listfs" operation). simplesnapwrap responds with a list of all ZFS datasets that were not flagged for exclusion. Next, simplesnap connects back to simplesnapwrap once for each dataset to be backed up -- the "sendback" operation. simplesnap passes along to it only two things: the setname and the dataset (filesystem) name. simplesnapwrap looks to see if there is an existing simplesnap snapshot corresponding to that SETNAME. If not, it creates one and sends it as a full, non-incremental backup. That completes the job for that dataset. If there is an existing snapshot for that SETNAME, simplesnapwrap creates a new one, constructing the snapshot name containing a timestamp and the SETNAME, then sends an incremental, using the oldest snapshot from that setname as the basis for zfs send -I. After the backuphost has observed zfs receive exiting without error, it contacts simplesnapwrap once more and requests the "reap" operation. This cleans up the old snapshots for the given SETNAME, leaving only the most recent. This is a separate operation in simplesnapwrap ensuring that even if the transmission is interrupted, still it will be OK in the end because zfs receive -F is used, and the data will come across next time. The idea is that some system like zfSnap will be used on both ends to make periodic snapshots and clean them up. One can use careful prefix names with zfSnap to use different prefixes on each activehost, and then implement custom cleanup rules with -F on the holderhost. Quick Start This section will describe how a first-time &simplesnap; user can get up and running quickly. It assumes you already have &simplesnap; installed and working on your system. If not, please follow the instructions in the INSTALL.txt file in the source distribution. As above, I will refer to the machine storing the backups as the "backuphost" and the machine being backed up as the "activehost". First, on the backuphost, as root, generate an ssh keypair that will be used exclusively for &simplesnap;. ssh-keygen -t rsa -f ~/.ssh/id_rsa_simplesnap When prompted for a passphrase, leave it empty. Now, on the activehost, edit or create a file called ~/.ssh/authorized_keys. Initialize it with the content of ~/.ssh/id_rsa_simplesnap.pub from the backuphost. (Or, add to the end, if you already have lines in the file.) Then, at the beginning of that one very long line, add text like this: (I broke that line into two for readability, but this must all be on a single line in your file.) The 1.2.3.4 is the IP address that connections from the backuphost will appear to come from. It may be omitted if the IP is not static, but it affords a little extra security. The line will wind up looking like: (Again, this should all be on one huge line.) If there are any ZFS datasets you do not want to be backed up, set org.complete.simplesnap:exclude property on the activehost to on. For instance: zfs set org.complete.simplesnap:exclude=on tank/junkdata Now, back on the backuphost, you should be able to run: ssh -i ~/.ssh/id_rsa_simplesnap activehost say yes when asked if you want to add the key to the known_hosts file. At this point, you should see output containing: "simplesnapwrap: This program is to be run from ssh." If you see that, then simplesnapwrap was properly invoked remotely. Now, create a ZFS filesystem to hold your backups. For instance: zfs create tank/simplesnap I often recommend compression for &simplesnap; datasets, so: zfs set compression=lz4 tank/simplesnap (If that gives an error, use compression=on instead.) Now, you can run the backup: simplesnap --host activehost --setname mainset --store tank/simplesnap --sshcmd "ssh -i /root/.ssh/id_rsa_simplesnap" You can monitor progress in /var/log/syslog. If all goes well, you will see filesystems start to be populated under tank/simplesnap/host. Simple! Now, go test that you have the data you expected to: look at your STORE filesystems and make sure they have everything expected. Test repeatedly over time that you can restore as you expect from your backups. Advanced: SETNAME usage Most people will always use the same SETNAME. The SETNAME is used to track and name the snapshots on the remote end. simplesnap tries to always leave one snapshot on the remote, to serve as the base for a future incremental. In some situations, you may have multiple bases for incrementals. The two primary examples are two different backup servers backing up the same machine, or having two sets of backup media and rotating them to offsite storage. In these situations, you will have to keep different snapshots on the activehost for the different backups, since they will be current to different points in time. Options All &simplesnap; options begin with two dashes (`--'). Most take a parameter, which is to be separated from the option by a space. The equals sign is not a valid separator for &simplesnap;. The normal &simplesnap; mode is backing up. An alternative check mode is available, which requires fewer parameters. This mode is described below. Normally, &simplesnap; automatically obtains a list of datasets to back up from the remote, and backs up all of them except those that define the org.complete.simplesnap:exclude=on property. With this option, &simplesnap; does not bother to ask the remote for a list of datasets, and instead backs up only the one precise DATASET given. For now, ignored when is given, but that may change in the future. It would be best to not specify this option with --check for now. Do not back up, but check existing backups. If any datasets' newest backup is older than TIMEFRAME, print an error and exit with a nonzero code. Scans all hosts unless a specific host is given with . The parameter is in the format given to GNU date(1); for instance, --check "30 days ago". Remember to enclose it in quotes if it contains spaces. Valid only with , gives a specific destination for the backup, whith may be outside the STORE. The STORE must still exist, as it is used for storing lockfiles and such. HOST Gives the name of the host to back up. This is both passed to ssh and used to name the backup sets. In a few situations, one may not wish to use the same name for both. It is recommend to use the Host and HostName options in ~/.ssh/config to configure aliases in this situation. Specifies that the host being backed up is local to the machine. Do not use ssh to contact it, and invoke the wrapper directly. Gives the command to use to connect to the remote host. Defaults to "ssh". It may be used to select an alternative configuration file or keypair. Remember to quote it per your shell if it contains spaces. For example: --sshcmd "ssh -i /root/.id_rsa_simplesnap". This command is ignored when or is given. Gives the backup set name. Can just be a made-up word if multiple sets are not needed; for instance, the hostname of the backup server. This is used as part of the snapshot name. Gives the ZFS dataset name where the data will be stored. Should not begin with a slash. The mountpoint will be obtained from the ZFS subsystem. Always required. Gives the path to simplesnapwrap (which must be on the remote machine unless is given). Not usually relevant, since the command parameter in ~root/.ssh/authorized_keys gives the path. Default: "simplesnapwrap" Backup Interrogation Since &simplesnap; stores backups in standard ZFS datasets, you can use standard ZFS tools to obtain information about backups. Here are some examples. Space used per host Try something like this: Here, you can see that the total size of the &simplesnap; data is 540G - the USED value from the top level. In this example, host1 was using the most space -- 473G -- and host3 the least -- 12.2G. There is 867G available on this zpool for backups. The -r parameter to zfs list requests a recursive report, but the -d 1 parameter sets a maximum depth of 1 -- so you can see just the top-level hosts without all their component datasets. Space used by a host Let's say that you had the above example, and want to drill down into more detail. Perhaps, for instance, we continue the above example and drill down into host2: I've trimmed the "mountpoint" column here so it doesn't get too wide for the screen. You see here the same 54.9G used as in the previous example, but now you can trace it down. There were two zpools on host2: tank and rpool. Most of the backup space -- 49.8G of the 54.9G -- is used by tank, and only 5.12G by rpool. And in tank, 42.4G is used by vm. Tracing it down, of that 42.4G used by vm, 32G is in vm1 and 10.4G in vm2. Notice how the values at each level of the tree include their descendents. So in this example, vm1 and vm2 are zvols corresponding to virtual machines, and clearly take up a lot of space. Notice how vm1 says it uses 32.0G but in the refer column, it only refers to 29.7G? That means that the latest backup for vm2 used 29.7G, but when you add in the snapshots for that dataset, the total space consumed is 32.0G. Let's look at an alternative view that will make the size consumed by snapshots more clear: (Again, I've trimmed some irrelevant columns from this output.) The AVAIL and USED columns are the same as before, but now you have a breakdown of what makes up the USED column. USEDSNAP is the space used by the snapshots of that particular dataset. USEDDS is the space used by that dataset directly -- the same value as was in REFER before. And USEDCHILD is the space used by descendents of that dataset. The USEDSNAP column is the easiest way to see the impact your retention policies have on your backup space consumption. Viewing snapshots of a dataset Let's take one example from before -- the 153M of snapshots in host2-1/var, and see what we can find. In this output, the REFER column is the amount of data pointed to by that snapshot -- that is, the size of /var at the moment the snapshot is made. And the USED column is the amount of space that would be freed if just that snapshot were deleted. Note this important point: it is normal for the sum of the values in the USED column to be less than the space consumed by the snapshots of the datasets as reported by USEDSNAP in the previous example. The reason is that the USED column is the data unique to that one snapshot. If, for instance, 100MB of data existed on the system being backed up for three hours yesterday, each snapshot could very well show less than 100KB used, because that 100MB isn't unique to a particular snapshot. Until, that is, two of the three snapshots referncing the 100MB data are destroyed; then the USED value of the last one referencing it will suddenly jump to 100MB higher because now it references unique data. One other point -- an indication that the last backup was successfully transmitted is the presence of a __simplesnap_...__ snapshot at the end of the list. Do not delete it. Finding what changed over time The zfs diff command can let you see what changed over time -- either across a single snapshot, or across many. Let's take a look. Here you can see why there was just a few KB of changes in that snapshot: mostly just a little bit of logging was happening on the system. Now let's inspect the larger snapshot: /tank/store/host2/rpool/host2-1/var/backups/dpkg.status.2.gz R /tank/store/host2/rpool/host2-1/var/backups/dpkg.status.2.gz -> /tank/store/host2/rpool/host2-1/var/backups/dpkg.status.3.gz ... M /tank/store/host2/rpool/host2-1/var/cache/apt R /tank/store/host2/rpool/host2-1/var/cache/apt/pkgcache.bin.KdsMLu -> /tank/store/host2/rpool/host2-1/var/cache/apt/pkgcache.bin ]]> Here you can see some file rotation going on, and a temporary file being renamed to permanent. Normal daily activity on a system, but now you know what was taking up space. Warnings, Cautions, and Good Practices Importance of Testing Any backup scheme should be tested carefully before being relied upon to serve its intended purpose. This item is not &simplesnap;-specific, but pertains to every backup solution: test that you are backing up the data you expect to before you need it. Use of zfs receive -F In order to account for various situations that could lead to divergence of filesystems, including the simple act of mounting them, &simplesnap; always uses zfs receive -F. Any local changes you make to the &simplesnap; store datasets will be lost at any time. If you need to make local changes there, it is best to copy them elsewhere. Extraneous Snapshot Buildup Since &simplesnap; sends all snapshots, it is possible that locally-created snapshots made outside of your rotation scheme will also be sent to your backuphost. These may not be automatically reaped there, and may stick around. An example at the end of the cron.daily.simplesnap.backuphost file included with &simplesnap; is one way to check for these. They could automatically be reaped with zfs destroy as well, but this must be carefully tuned to local requirements, so an example of doign that is intentionally not supplied with the distribution. Internal simplesnap snapshots &simplesnap; creates snapshots beginning with __simplesnap_ followed by your SETNAME. Do not create, remove, or alter these snapshots in any way, either on the activehost or the backuphost. Doing so may lead to unpredictable side-effects. Bugs Ordinarily, an interrupted transfer is no problem for &simplesnap;. However, the very first transfer of a dataset poses a bit of a problem, since the &simplesnap; wrapper can't detect failure in this one special case. If your first transfer gets interrupted, simply zfs destroy the __simplesnap_...__ snapshot on the activehost and rerun. NEVER DESTROY __simplesnap SNAPSHOTS IN ANY OTHER SITUATION! See Also zfSnap (1), zfs (8). The &simplesnap; homepage: The examples included with the &simplesnap; distribution, or on its homepage. The zfSnap package compliments &simplesnap; perfectly. Find it at . AUTHOR This software and manual page was written by &dhusername; &dhemail;. Permission is granted to copy, distribute and/or modify this document under the terms of the &gnu; General Public License, Version 3 any later version published by the Free Software Foundation. The complete text of the GNU General Public License is included in the file COPYING in the source distribution.
simplesnap-1.0.3/doc/simplesnap.80000644000000000000000000005603612277427766013623 0ustar .\" This manpage has been automatically generated by docbook2man .\" from a DocBook document. This tool can be found at: .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . .TH "SIMPLESNAP" "8" "14 February 2014" "" "" .SH NAME simplesnap \- Simple and powerful way to send ZFS snapshots across a network .SH SYNOPSIS \fBsimplesnap\fR [ \fB--sshcmd \fICOMMAND\fB\fR ] [ \fB--wrapcmd \fICOMMAND\fB\fR ] [ \fB--local\fR ] [ \fB--backupdataset \fIDATASET\fB [ --datasetdest \fIDEST\fB ]\fR ] \fB--store \fISTORE\fB\fR \fB--setname \fINAME\fB\fR \fB--host \fIHOST\fB\fR \fBsimplesnap\fR \fB--check \fITIMEFRAME\fB\fR \fB--store \fISTORE\fB\fR \fB--setname \fINAME\fB\fR [ \fB--host \fIHOST\fB\fR ] .SH "DESCRIPTION" .PP \fBsimplesnap\fR is a simple way to send ZFS snapshots across a network. Although it can serve many purposes, its primary goal is to manage backups from one ZFS filesystem to a backup filesystem also running ZFS, using incremental backups to minimize network traffic and disk usage. .PP \fBsimplesnap\fR is \fBFLEXIBLE\fR; it is designed to perfectly compliment snapshotting tools, permitting rotating backups with arbitrary retention periods. It lets multiple machines back up a single target, lets one machine back up multiple targets, and keeps it all straight. .PP \fBsimplesnap\fR is \fBEASY\fR; there is no configuration file needed. One ZFS property is available to exclude datasets/filesystems. ZFS datasets are automatically discovered on machines being backed up. .PP \fBsimplesnap\fR is \fBSAFE\fR; it is robust in the face of interrupted transfers, and needs little help to keep running. .PP \fBsimplesnap\fR is \fBSECURE\fR; unlike many similar tools, it does not require full root access to the machines being backed up. It runs only a small wrapper as root, and the wrapper has only three commands it implements. .SS "FEATURE LIST" .PP Besides the above, \fBsimplesnap\fR: .TP 0.2i \(bu Does one thing and does it well. It is designed to be used with a snapshot auto-rotator on both ends (such as zfSnap). simplesnap will transfer snapshots made by other tools, but will not destroy them on either end. .TP 0.2i \(bu Requires ssh public key authorization to the host being backed up, but does not require permission to run arbitrary commands. It has a wrapper to run on the backup host, written in bash, which accepts only three operations and performs them simply. It is suitable for a locked-down authorized_keys file. .TP 0.2i \(bu Creates minimal snapshots for its own internal purposes, generally leaving no more than 1 or 2 per dataset, and reaps them automatically without touching others. .TP 0.2i \(bu Is a small program, easily audited. In fact, most of the code is devoted to sanity-checking, security, and error checking. .TP 0.2i \(bu Automatically discovers what datasets to back up from the remote. Uses a user-defined zfs property to exclude filesystems that should not be backed up. .TP 0.2i \(bu Logs copiously to syslog on all hosts involved in backups. .TP 0.2i \(bu Intelligently supports a single machine being backed up by multiple backup hosts, or onto multiple sets of backup media (when, for instance, backup media is cycled into offsite storage) .SS "METHOD OF OPERATION" .PP \fBsimplesnap\fR\&'s operation is very simple. .PP The \fBsimplesnap\fR program runs on the machine that stores the backups -- we'll call it the backuphost. There is a restricted remote command wrapper called \fBsimplesnapwrap\fR that runs on the machine being backed up -- we'll call it the activehost. \fBsimplesnapwrap\fR is never invoked directly by the end-user; it is always called remotely by \fBsimplesnap\fR\&. .PP With \fBsimplesnap\fR, the backuphost always connects to the activehost -- never the other way round. .PP \fBsimplesnap\fR runs in the backuphost, and first connects to the \fBsimplesnapwrap\fR on the activehost and asks it for a list of the ZFS datasets ("listfs" operation). \fBsimplesnapwrap\fR responds with a list of all ZFS datasets that were not flagged for exclusion. .PP Next, \fBsimplesnap\fR connects back to \fBsimplesnapwrap\fR once for each dataset to be backed up -- the "sendback" operation. \fBsimplesnap\fR passes along to it only two things: the setname and the dataset (filesystem) name. .PP \fBsimplesnapwrap\fR looks to see if there is an existing simplesnap snapshot corresponding to that \fISETNAME\fR\&. If not, it creates one and sends it as a full, non-incremental backup. That completes the job for that dataset. .PP If there is an existing snapshot for that \fISETNAME\fR, simplesnapwrap creates a new one, constructing the snapshot name containing a timestamp and the \fISETNAME\fR, then sends an incremental, using the oldest snapshot from that setname as the basis for zfs send -I. .PP After the backuphost has observed \fBzfs receive\fR exiting without error, it contacts \fBsimplesnapwrap\fR once more and requests the "reap" operation. This cleans up the old snapshots for the given \fISETNAME\fR, leaving only the most recent. This is a separate operation in \fBsimplesnapwrap\fR ensuring that even if the transmission is interrupted, still it will be OK in the end because \fBzfs receive -F\fR is used, and the data will come across next time. .PP The idea is that some system like \fBzfSnap\fR will be used on both ends to make periodic snapshots and clean them up. One can use careful prefix names with zfSnap to use different prefixes on each activehost, and then implement custom cleanup rules with -F on the holderhost. .SH "QUICK START" .PP This section will describe how a first-time \fBsimplesnap\fR user can get up and running quickly. It assumes you already have \fBsimplesnap\fR installed and working on your system. If not, please follow the instructions in the \fIINSTALL.txt\fR file in the source distribution. .PP As above, I will refer to the machine storing the backups as the "backuphost" and the machine being backed up as the "activehost". .PP First, on the backuphost, as root, generate an ssh keypair that will be used exclusively for \fBsimplesnap\fR\&. .PP \fBssh-keygen -t rsa -f ~/.ssh/id_rsa_simplesnap\fR .PP When prompted for a passphrase, leave it empty. .PP Now, on the activehost, edit or create a file called \fI~/.ssh/authorized_keys\fR\&. Initialize it with the content of \fI~/.ssh/id_rsa_simplesnap.pub\fR from the backuphost. (Or, add to the end, if you already have lines in the file.) Then, at the beginning of that one very long line, add text like this: .nf command="/usr/sbin/simplesnapwrap",from="1.2.3.4", no-port-forwarding,no-X11-forwarding,no-pty .fi .PP (I broke that line into two for readability, but this must all be on a single line in your file.) .PP The \fI1.2.3.4\fR is the IP address that connections from the backuphost will appear to come from. It may be omitted if the IP is not static, but it affords a little extra security. The line will wind up looking like: .nf command="/usr/sbin/simplesnapwrap",from="1.2.3.4", no-port-forwarding,no-X11-forwarding,no-pty ssh-rsa AAAA.... .fi .PP (Again, this should all be on one huge line.) .PP If there are any ZFS datasets you do not want to be backed up, set \fIorg.complete.simplesnap:exclude\fR property on the activehost to \fIon\fR\&. For instance: .PP \fBzfs set org.complete.simplesnap:exclude=on tank/junkdata\fR .PP Now, back on the backuphost, you should be able to run: .PP \fBssh -i ~/.ssh/id_rsa_simplesnap activehost\fR .PP say yes when asked if you want to add the key to the known_hosts file. At this point, you should see output containing: .PP "simplesnapwrap: This program is to be run from ssh." .PP If you see that, then simplesnapwrap was properly invoked remotely. .PP Now, create a ZFS filesystem to hold your backups. For instance: .PP \fBzfs create tank/simplesnap\fR .PP I often recommend compression for \fBsimplesnap\fR datasets, so: .PP \fBzfs set compression=lz4 tank/simplesnap\fR .PP (If that gives an error, use compression=on instead.) .PP Now, you can run the backup: .PP \fBsimplesnap --host activehost --setname mainset --store tank/simplesnap --sshcmd "ssh -i /root/.ssh/id_rsa_simplesnap" \fR .PP You can monitor progress in \fI/var/log/syslog\fR\&. If all goes well, you will see filesystems start to be populated under \fItank/simplesnap/host\fR\&. .PP Simple! .PP Now, go test that you have the data you expected to: look at your \fISTORE\fR filesystems and make sure they have everything expected. Test repeatedly over time that you can restore as you expect from your backups. .SH "ADVANCED: SETNAME USAGE" .PP Most people will always use the same \fISETNAME\fR\&. The \fISETNAME\fR is used to track and name the snapshots on the remote end. simplesnap tries to always leave one snapshot on the remote, to serve as the base for a future incremental. .PP In some situations, you may have multiple bases for incrementals. The two primary examples are two different backup servers backing up the same machine, or having two sets of backup media and rotating them to offsite storage. In these situations, you will have to keep different snapshots on the activehost for the different backups, since they will be current to different points in time. .SH "OPTIONS" .PP All \fBsimplesnap\fR options begin with two dashes (`--'). Most take a parameter, which is to be separated from the option by a space. The equals sign is not a valid separator for \fBsimplesnap\fR\&. .PP The normal \fBsimplesnap\fR mode is backing up. An alternative check mode is available, which requires fewer parameters. This mode is described below. .TP \fB--backupdataset \fIDATASET\fB \fR Normally, \fBsimplesnap\fR automatically obtains a list of datasets to back up from the remote, and backs up all of them except those that define the \fIorg.complete.simplesnap:exclude=on\fR property. With this option, \fBsimplesnap\fR does not bother to ask the remote for a list of datasets, and instead backs up only the one precise \fIDATASET\fR given. For now, ignored when \fB--check\fR is given, but that may change in the future. It would be best to not specify this option with --check for now. .TP \fB--check \fITIMEFRAME\fB \fR Do not back up, but check existing backups. If any datasets' newest backup is older than \fITIMEFRAME\fR, print an error and exit with a nonzero code. Scans all hosts unless a specific host is given with \fB--host\fR\&. The parameter is in the format given to GNU \fBdate\fR(1); for instance, --check "30 days ago". Remember to enclose it in quotes if it contains spaces. .TP \fB--datasetdest \fIDEST\fB \fR Valid only with \fB--backupdataset\fR, gives a specific destination for the backup, whith may be outside the \fISTORE\fR\&. The \fISTORE\fR must still exist, as it is used for storing lockfiles and such. .TP \fB--host \fIHOST\fB\fR Gives the name of the host to back up. This is both passed to ssh and used to name the backup sets. In a few situations, one may not wish to use the same name for both. It is recommend to use the Host and HostName options in \fI~/.ssh/config\fR to configure aliases in this situation. .TP \fB--local \fR Specifies that the host being backed up is local to the machine. Do not use ssh to contact it, and invoke the wrapper directly. .TP \fB--sshcmd \fICOMMAND\fB \fR Gives the command to use to connect to the remote host. Defaults to "ssh". It may be used to select an alternative configuration file or keypair. Remember to quote it per your shell if it contains spaces. For example: --sshcmd "ssh -i /root/.id_rsa_simplesnap". This command is ignored when \fB--local\fR or \fB--check\fR is given. .TP \fB--setname \fISETNAME\fB\fR Gives the backup set name. Can just be a made-up word if multiple sets are not needed; for instance, the hostname of the backup server. This is used as part of the snapshot name. .TP \fB--store \fISTORE\fB \fR Gives the ZFS dataset name where the data will be stored. Should not begin with a slash. The mountpoint will be obtained from the ZFS subsystem. Always required. .TP \fB--wrapcmd \fICOMMAND\fB \fR Gives the path to simplesnapwrap (which must be on the remote machine unless \fB--local\fR is given). Not usually relevant, since the \fIcommand\fR parameter in \fI~root/.ssh/authorized_keys\fR gives the path. Default: "simplesnapwrap" .SH "BACKUP INTERROGATION" .PP Since \fBsimplesnap\fR stores backups in standard ZFS datasets, you can use standard ZFS tools to obtain information about backups. Here are some examples. .SS "SPACE USED PER HOST" .PP Try something like this: .nf # zfs list -r -d 1 tank/store NAME USED AVAIL REFER MOUNTPOINT tank/store 540G 867G 34K /tank/store tank/store/host1 473G 867G 32K /tank/store/host1 tank/store/host2 54.9G 867G 32K /tank/store/host2 tank/store/host3 12.2G 867G 31K /tank/store/host3 .fi .PP Here, you can see that the total size of the \fBsimplesnap\fR data is 540G - the USED value from the top level. In this example, host1 was using the most space -- 473G -- and host3 the least -- 12.2G. There is 867G available on this zpool for backups. .PP The \fI-r\fR parameter to \fBzfs list\fR requests a recursive report, but the \fI-d 1\fR parameter sets a maximum depth of 1 -- so you can see just the top-level hosts without all their component datasets. .SS "SPACE USED BY A HOST" .PP Let's say that you had the above example, and want to drill down into more detail. Perhaps, for instance, we continue the above example and drill down into host2: .nf # zfs list -r tank/store/host2 NAME USED AVAIL REFER MOUNTPOINT tank/store/host2 54.9G 867G 32K /tank/... tank/store/host2/tank 49.8G 867G 32K /tank/... tank/store/host2/tank/home 7.39G 867G 6.93G /tank/... tank/store/host2/tank/vm 42.4G 867G 30K /tank/... tank/store/host2/tank/vm/vm1 32.0G 867G 29.7G - tank/store/host2/tank/vm/vm2 10.4G 867G 10.4G - tank/store/host2/rpool 5.12G 867G 32K /tank/... tank/store/host2/rpool/misc 521M 867G 521M /tank/... tank/store/host2/rpool/host2-1 4.61G 867G 33K /tank/... tank/store/host2/rpool/host2-1/ROOT 317M 867G 312M /tank/... tank/store/host2/rpool/host2-1/usr 3.76G 867G 3.76G /tank/... tank/store/host2/rpool/host2-1/var 554M 867G 401M /tank/... .fi .PP I've trimmed the "mountpoint" column here so it doesn't get too wide for the screen. .PP You see here the same 54.9G used as in the previous example, but now you can trace it down. There were two zpools on host2: tank and rpool. Most of the backup space -- 49.8G of the 54.9G -- is used by tank, and only 5.12G by rpool. And in tank, 42.4G is used by vm. Tracing it down, of that 42.4G used by vm, 32G is in vm1 and 10.4G in vm2. Notice how the values at each level of the tree include their descendents. .PP So in this example, vm1 and vm2 are zvols corresponding to virtual machines, and clearly take up a lot of space. Notice how vm1 says it uses 32.0G but in the refer column, it only refers to 29.7G? That means that the latest backup for vm2 used 29.7G, but when you add in the snapshots for that dataset, the total space consumed is 32.0G. .PP Let's look at an alternative view that will make the size consumed by snapshots more clear: .nf # zfs list -o space -r tank/store/host2 NAME AVAIL USED USEDSNAP USEDDS USEDCHILD \&.../host2 867G 54.9G 0 32K 54.9G \&.../host2/tank 867G 49.8G 0 32K 49.8G \&.../host2/tank/home 867G 7.39G 474M 6.93G 0 \&.../host2/tank/vm 867G 42.4G 50K 30K 42.4G \&.../host2/tank/vm/vm1 867G 32.0G 2.35G 29.7G 0 \&.../host2/tank/vm/vm1 867G 10.4G 49K 10.4G 0 \&.../host2/rpool 867G 5.12G 0 32K 5.12G \&.../host2/rpool/misc 867G 521M 51K 521M 0 \&.../host2/rpool/host2-1 867G 4.61G 51K 33K 4.61G \&.../host2/rpool/host2-1/ROOT 867G 317M 5.44M 312M 0 \&.../host2/rpool/host2-1/usr 867G 3.76G 208K 3.76G 0 \&.../host2/rpool/host2-1/var 867G 554M 153M 401M 0 .fi .PP (Again, I've trimmed some irrelevant columns from this output.) .PP The AVAIL and USED columns are the same as before, but now you have a breakdown of what makes up the USED column. USEDSNAP is the space used by the snapshots of that particular dataset. USEDDS is the space used by that dataset directly -- the same value as was in REFER before. And USEDCHILD is the space used by descendents of that dataset. .PP The USEDSNAP column is the easiest way to see the impact your retention policies have on your backup space consumption. .SS "VIEWING SNAPSHOTS OF A DATASET" .PP Let's take one example from before -- the 153M of snapshots in host2-1/var, and see what we can find. .nf # zfs list -t snap -r tank/store/host2/rpool/host2-1/var NAME USED AVAIL REFER \&... \&.../var@host2-hourly-2014-02-11_05.17.02--2d 76K - 402M \&.../var@host2-hourly-2014-02-11_06.17.01--2d 77K - 402M \&.../var@host2-hourly-2014-02-11_07.17.01--2d 18.8M - 402M \&.../var@host2-daily-2014-02-11_07.17.25--1w 79K - 402M \&.../var@host2-hourly-2014-02-11_08.17.01--2d 156K - 402M \&.../var@host2-monthly-2014-02-11_09.01.36--1m 114K - 402M \&... .fi .PP In this output, the REFER column is the amount of data pointed to by that snapshot -- that is, the size of /var at the moment the snapshot is made. And the USED column is the amount of space that would be freed if just that snapshot were deleted. .PP Note this important point: it is normal for the sum of the values in the USED column to be less than the space consumed by the snapshots of the datasets as reported by USEDSNAP in the previous example. The reason is that the USED column is the data unique to that one snapshot. If, for instance, 100MB of data existed on the system being backed up for three hours yesterday, each snapshot could very well show less than 100KB used, because that 100MB isn't unique to a particular snapshot. Until, that is, two of the three snapshots referncing the 100MB data are destroyed; then the USED value of the last one referencing it will suddenly jump to 100MB higher because now it references unique data. .PP One other point -- an indication that the last backup was successfully transmitted is the presence of a __simplesnap_...__ snapshot at the end of the list. Do not delete it. .SS "FINDING WHAT CHANGED OVER TIME" .PP The \fBzfs diff\fR command can let you see what changed over time -- either across a single snapshot, or across many. Let's take a look. .nf # zfs diff .../var@host2-hourly-2014-02-11_05.17.02--2d \\ \&.../var@host2-hourly-2014-02-11_06.17.01--2d \\ | sort -k2 | less M /tank/store/host2/rpool/host2-1/var/log/Xorg.0.log M /tank/store/host2/rpool/host2-1/var/log/auth.log M /tank/store/host2/rpool/host2-1/var/log/daemon.log \&... M /tank/store/host2/rpool/host2-1/var/spool/anacron/cron.daily M /tank/store/host2/rpool/host2-1/var/spool/anacron/cron.monthly M /tank/store/host2/rpool/host2-1/var/spool/anacron/cron.weekly M /tank/store/host2/rpool/host2-1/var/tmp .fi .PP Here you can see why there was just a few KB of changes in that snapshot: mostly just a little bit of logging was happening on the system. Now let's inspect the larger snapshot: .nf # zfs diff .../var@host2-hourly-2014-02-11_07.17.01--2d \\ \&.../var@host2-daily-2014-02-11_07.17.25--1w \\ | sort -k2 | less M /tank/store/host2/rpool/host2-1/var/backups + /tank/store/host2/rpool/host2-1/var/backups/dpkg.status.0 - /tank/store/host2/rpool/host2-1/var/backups/dpkg.status.0 + /tank/store/host2/rpool/host2-1/var/backups/dpkg.status.1.gz R /tank/store/host2/rpool/host2-1/var/backups/dpkg.status.1.gz -> /tank/store/host2/rpool/host2-1/var/backups/dpkg.status.2.gz R /tank/store/host2/rpool/host2-1/var/backups/dpkg.status.2.gz -> /tank/store/host2/rpool/host2-1/var/backups/dpkg.status.3.gz \&... M /tank/store/host2/rpool/host2-1/var/cache/apt R /tank/store/host2/rpool/host2-1/var/cache/apt/pkgcache.bin.KdsMLu -> /tank/store/host2/rpool/host2-1/var/cache/apt/pkgcache.bin .fi .PP Here you can see some file rotation going on, and a temporary file being renamed to permanent. Normal daily activity on a system, but now you know what was taking up space. .SH "WARNINGS, CAUTIONS, AND GOOD PRACTICES" .SS "IMPORTANCE OF TESTING" .PP Any backup scheme should be tested carefully before being relied upon to serve its intended purpose. This item is not \fBsimplesnap\fR-specific, but pertains to every backup solution: test that you are backing up the data you expect to before you need it. .SS "USE OF ZFS RECEIVE -F" .PP In order to account for various situations that could lead to divergence of filesystems, including the simple act of mounting them, \fBsimplesnap\fR always uses \fBzfs receive -F\fR\&. Any local changes you make to the \fBsimplesnap\fR store datasets will be lost at any time. If you need to make local changes there, it is best to copy them elsewhere. .SS "EXTRANEOUS SNAPSHOT BUILDUP" .PP Since \fBsimplesnap\fR sends all snapshots, it is possible that locally-created snapshots made outside of your rotation scheme will also be sent to your backuphost. These may not be automatically reaped there, and may stick around. An example at the end of the \fIcron.daily.simplesnap.backuphost\fR file included with \fBsimplesnap\fR is one way to check for these. They could automatically be reaped with \fBzfs destroy\fR as well, but this must be carefully tuned to local requirements, so an example of doign that is intentionally not supplied with the distribution. .SS "INTERNAL SIMPLESNAP SNAPSHOTS" .PP \fBsimplesnap\fR creates snapshots beginning with __simplesnap_ followed by your \fISETNAME\fR\&. Do not create, remove, or alter these snapshots in any way, either on the activehost or the backuphost. Doing so may lead to unpredictable side-effects. .SH "BUGS" .PP Ordinarily, an interrupted transfer is no problem for \fBsimplesnap\fR\&. However, the very first transfer of a dataset poses a bit of a problem, since the \fBsimplesnap\fR wrapper can't detect failure in this one special case. If your first transfer gets interrupted, simply zfs destroy the __simplesnap_...__ snapshot on the activehost and rerun. NEVER DESTROY __simplesnap SNAPSHOTS IN ANY OTHER SITUATION! .SH "SEE ALSO" .PP zfSnap (1), zfs (8). .PP The \fBsimplesnap\fR homepage: .PP The examples included with the \fBsimplesnap\fR distribution, or on its homepage. .PP The zfSnap package compliments \fBsimplesnap\fR perfectly. Find it at \&. .SH "AUTHOR" .PP This software and manual page was written by John Goerzen \&. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 3 any later version published by the Free Software Foundation. The complete text of the GNU General Public License is included in the file COPYING in the source distribution. simplesnap-1.0.3/doc/Makefile0000644000000000000000000000041012276501225012756 0ustar all: simplesnap.8 simplesnap.html simplesnap.8: simplesnap.sgml docbook2man simplesnap.sgml docbook2man simplesnap.sgml docbook2man simplesnap.sgml simplesnap.html: simplesnap.sgml docbook2html -u simplesnap.sgml clean: rm -f simplesnap.html simplesnap.8 simplesnap-1.0.3/doc/manpage.refs0000644000000000000000000000003312277151521013611 0ustar { '' => '', '' => '' }