From 8fb9106826b9c343fc50fd7e4b771024911ce5de Mon Sep 17 00:00:00 2001 From: cpzengel Date: Mon, 11 Nov 2019 15:19:24 +0100 Subject: [PATCH] Add files via upload No Sudo Added -p Parameter for SSH Port Changed from -I to -i for no intermediate Snapshots Enabled SSH Compression -C --- backup-zfs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/backup-zfs b/backup-zfs index 0d1887a..b97b1d0 100755 --- a/backup-zfs +++ b/backup-zfs @@ -10,7 +10,7 @@ usage() { src the source fs, specified as [host:]pool/path/to/fs dest the destination fs parent, specified as [host:]pool/path/to/fs (the final path component of src will be appended to dest) - + -p ssh port -h help -v verbose mode -q quiet mode @@ -53,10 +53,10 @@ ZFS() { shift if [[ -n $host ]] ; then log "remote ($host): zfs $@" - ssh "$host" sudo zfs "$@" + ssh -C -p $port "$host" zfs "$@" else log "local: zfs $@" - sudo zfs "$@" + zfs "$@" fi } @@ -70,11 +70,12 @@ verbose=false quiet=false tossh=false fromssh=false +port=22 ### ### parse options ### -while getopts "hvqk:t:d:srg:" opt ; do +while getopts "hvqk:p:t:d:srg:" opt ; do case $opt in h) usage 0 ;; v) @@ -84,6 +85,7 @@ while getopts "hvqk:t:d:srg:" opt ; do ;; q) quiet=true ;; k) keep=$OPTARG ;; + p) port=$OPTARG ;; t) tag=$OPTARG ;; d) dateopts=$OPTARG ;; s) tossh=true ;; @@ -162,15 +164,15 @@ if $tossh ; then # normal case: send incremental else log "sending $([[ -n $gpgid ]] && echo "encrypted ")incremental snapshot from $src to $dest (${last#${tag}_}..${cur#*@${tag}_})" - #ZFS "$srchost" send $send_opts -R -I "$last" "$cur" | ZFS "$desthost" receive $recv_opts -Fue "$destfs" || die $? "zfs incremental send failed" + #ZFS "$srchost" send $send_opts -R -i "$last" "$cur" | ZFS "$desthost" receive $recv_opts -Fue "$destfs" || die $? "zfs incremental send failed" if [[ -n $gpgid ]] ; then - ZFS "$srchost" send $send_opts -R -I "$last" "$cur" \ + ZFS "$srchost" send $send_opts -R -i "$last" "$cur" \ | gpg --trust-model always --encrypt --recipient "$gpgid" \ | ssh "$desthost" zfswrite "${tag}_$date.zfssnap.gpg" \ || die $? "zfs incremental send failed" ssh "$desthost" zfslast "$snap" else - ZFS "$srchost" send $send_opts -R -I "$last" "$cur" \ + ZFS "$srchost" send $send_opts -R -i "$last" "$cur" \ | ssh "$desthost" zfswrite "${tag}_$date.zfssnap" \ || die $? "zfs incremental send failed" ssh "$desthost" zfslast "$snap" @@ -200,7 +202,7 @@ elif $fromssh ; then ### receive ### log "receiving incremental snapshot from $src to $dest" - #ZFS "$srchost" send $send_opts -R -I "$last" "$cur" | ZFS "$desthost" receive $recv_opts -Fue "$destfs" || die $? "zfs incremental send failed" + #ZFS "$srchost" send $send_opts -R -i "$last" "$cur" | ZFS "$desthost" receive $recv_opts -Fue "$destfs" || die $? "zfs incremental send failed" for file in $(ssh "$srchost" zfsfind | sort) ; do log "receiving $file from $srchost" if [[ $file =~ \.gpg$ ]] ; then @@ -255,7 +257,7 @@ elif ! ZFS "$srchost" list $srcfs@$last &>/dev/null ; then # normal case: send incremental else log "sending incremental snapshot from $src to $dest (${last#${tag}_}..${cur#*@${tag}_})" - ZFS "$srchost" send $send_opts -R -I "$last" "$cur" | ZFS "$desthost" receive $recv_opts -Fue "$destfs" || die $? "zfs incremental send failed" + ZFS "$srchost" send $send_opts -R -i "$last" "$cur" | ZFS "$desthost" receive $recv_opts -Fue "$destfs" || die $? "zfs incremental send failed" fi ###