mirror of
https://github.com/bashclub/bashclub-zfs-push-pull.git
synced 2024-11-07 21:01:58 +01:00
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
This commit is contained in:
parent
21f780de69
commit
8fb9106826
20
backup-zfs
20
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
|
||||
|
||||
###
|
||||
|
Loading…
Reference in New Issue
Block a user