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
|
src the source fs, specified as [host:]pool/path/to/fs
|
||||||
dest the destination fs parent, 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)
|
(the final path component of src will be appended to dest)
|
||||||
|
-p ssh port
|
||||||
-h help
|
-h help
|
||||||
-v verbose mode
|
-v verbose mode
|
||||||
-q quiet mode
|
-q quiet mode
|
||||||
@ -53,10 +53,10 @@ ZFS() {
|
|||||||
shift
|
shift
|
||||||
if [[ -n $host ]] ; then
|
if [[ -n $host ]] ; then
|
||||||
log "remote ($host): zfs $@"
|
log "remote ($host): zfs $@"
|
||||||
ssh "$host" sudo zfs "$@"
|
ssh -C -p $port "$host" zfs "$@"
|
||||||
else
|
else
|
||||||
log "local: zfs $@"
|
log "local: zfs $@"
|
||||||
sudo zfs "$@"
|
zfs "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,11 +70,12 @@ verbose=false
|
|||||||
quiet=false
|
quiet=false
|
||||||
tossh=false
|
tossh=false
|
||||||
fromssh=false
|
fromssh=false
|
||||||
|
port=22
|
||||||
|
|
||||||
###
|
###
|
||||||
### parse options
|
### parse options
|
||||||
###
|
###
|
||||||
while getopts "hvqk:t:d:srg:" opt ; do
|
while getopts "hvqk:p:t:d:srg:" opt ; do
|
||||||
case $opt in
|
case $opt in
|
||||||
h) usage 0 ;;
|
h) usage 0 ;;
|
||||||
v)
|
v)
|
||||||
@ -84,6 +85,7 @@ while getopts "hvqk:t:d:srg:" opt ; do
|
|||||||
;;
|
;;
|
||||||
q) quiet=true ;;
|
q) quiet=true ;;
|
||||||
k) keep=$OPTARG ;;
|
k) keep=$OPTARG ;;
|
||||||
|
p) port=$OPTARG ;;
|
||||||
t) tag=$OPTARG ;;
|
t) tag=$OPTARG ;;
|
||||||
d) dateopts=$OPTARG ;;
|
d) dateopts=$OPTARG ;;
|
||||||
s) tossh=true ;;
|
s) tossh=true ;;
|
||||||
@ -162,15 +164,15 @@ if $tossh ; then
|
|||||||
# normal case: send incremental
|
# normal case: send incremental
|
||||||
else
|
else
|
||||||
log "sending $([[ -n $gpgid ]] && echo "encrypted ")incremental snapshot from $src to $dest (${last#${tag}_}..${cur#*@${tag}_})"
|
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
|
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" \
|
| gpg --trust-model always --encrypt --recipient "$gpgid" \
|
||||||
| ssh "$desthost" zfswrite "${tag}_$date.zfssnap.gpg" \
|
| ssh "$desthost" zfswrite "${tag}_$date.zfssnap.gpg" \
|
||||||
|| die $? "zfs incremental send failed"
|
|| die $? "zfs incremental send failed"
|
||||||
ssh "$desthost" zfslast "$snap"
|
ssh "$desthost" zfslast "$snap"
|
||||||
else
|
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" \
|
| ssh "$desthost" zfswrite "${tag}_$date.zfssnap" \
|
||||||
|| die $? "zfs incremental send failed"
|
|| die $? "zfs incremental send failed"
|
||||||
ssh "$desthost" zfslast "$snap"
|
ssh "$desthost" zfslast "$snap"
|
||||||
@ -200,7 +202,7 @@ elif $fromssh ; then
|
|||||||
### receive
|
### receive
|
||||||
###
|
###
|
||||||
log "receiving incremental snapshot from $src to $dest"
|
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
|
for file in $(ssh "$srchost" zfsfind | sort) ; do
|
||||||
log "receiving $file from $srchost"
|
log "receiving $file from $srchost"
|
||||||
if [[ $file =~ \.gpg$ ]] ; then
|
if [[ $file =~ \.gpg$ ]] ; then
|
||||||
@ -255,7 +257,7 @@ elif ! ZFS "$srchost" list $srcfs@$last &>/dev/null ; then
|
|||||||
# normal case: send incremental
|
# normal case: send incremental
|
||||||
else
|
else
|
||||||
log "sending incremental snapshot from $src to $dest (${last#${tag}_}..${cur#*@${tag}_})"
|
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
|
fi
|
||||||
|
|
||||||
###
|
###
|
||||||
|
Loading…
Reference in New Issue
Block a user