Set
This commit is contained in:
parent
4326841b46
commit
754243de52
@ -88,9 +88,19 @@ else
|
|||||||
log "Configuration:\n\ttarget=$target\n\tsource=$source\n\tsshport=$sshport\n\ttag=$tag\n\tsubvol_source=$subvol_source\n\tsnapshot_filter=$snapshot_filter\n"
|
log "Configuration:\n\ttarget=$target\n\tsource=$source\n\tsshport=$sshport\n\ttag=$tag\n\tsubvol_source=$subvol_source\n\tsnapshot_filter=$snapshot_filter\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
local_aes=$(/usr/bin/grep -m1 -o aes /proc/cpuinfo)
|
||||||
|
remote_aes=$($ssh root@192.168.200.241 "/usr/bin/grep -m1 -o aes /proc/cpuinfo")
|
||||||
|
|
||||||
|
|
||||||
|
if [[ $local_aes == "aes" ]] && [[ $remote_aes == "aes" ]]; then
|
||||||
|
sshcipher=-Caes256-gcm@openssh.com
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# query source datasets/subvols to replicate
|
# query source datasets/subvols to replicate
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for zvol in $($ssh $sshport $source "zfs get -H -o name,value,source -t filesystem,volume $tag"); do
|
for zvol in $($ssh $sshcipher $sshport $source "zfs get -H -o name,value,source -t filesystem,volume $tag"); do
|
||||||
name=$(echo $zvol | cut -f1)
|
name=$(echo $zvol | cut -f1)
|
||||||
if [[ "$(echo $zvol | cut -f2)" == "subvols" ]] && [[ $(echo $zvol | grep -E $subvol_source) ]]; then
|
if [[ "$(echo $zvol | cut -f2)" == "subvols" ]] && [[ $(echo $zvol | grep -E $subvol_source) ]]; then
|
||||||
log "Including $name"
|
log "Including $name"
|
||||||
@ -119,19 +129,19 @@ for name in "${syncvols[@]}"; do
|
|||||||
|
|
||||||
# start initial replication
|
# start initial replication
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for snap in $($ssh $sshport $source "zfs list -H -t snapshot -o name -S creation $name | grep -E \"$snapshot_filter\" | tail -1"); do
|
for snap in $($ssh $sshcipher $sshport $source "zfs list -H -t snapshot -o name -S creation $name | grep -E \"$snapshot_filter\" | tail -1"); do
|
||||||
log "Start initial replication: $snap => $target/$(echo $name | cut -d'/' -f1)"
|
log "Start initial replication: $snap => $target/$(echo $name | cut -d'/' -f1)"
|
||||||
$ssh $sshport $source "zfs send -w -p $debug $snap" | $zfs receive -x mountpoint -x canmount -x $tag -x com.sun:auto-snapshot $debug -dF $target/$(echo $name | cut -d'/' -f1)
|
$ssh $ssh_ipher $sshport $source "zfs send -w -p $debug $snap" | $zfs receive -x mountpoint -x canmount -x $tag -x com.sun:auto-snapshot $debug -dF $target/$(echo $name | cut -d'/' -f1)
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# replicate incremental
|
# replicate incremental
|
||||||
guid=$($zfs list -H -o guid -s creation -t snapshot $target/$name | tail -1)
|
guid=$($zfs list -H -o guid -s creation -t snapshot $target/$name | tail -1)
|
||||||
last=$($ssh $sshport $source "zfs list -H -o name,guid -t snapshot $name | grep $guid | tail -1 | cut -f1")
|
last=$($ssh $sshcipher $sshport $source "zfs list -H -o name,guid -t snapshot $name | grep $guid | tail -1 | cut -f1")
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for snap in $($ssh $sshport $source "zfs list -H -o name,guid -s creation -t snapshot $name | grep -E \"$snapshot_filter\" | grep --after-context=200 $guid | grep -v $guid | cut -f1"); do
|
for snap in $($ssh $sshcipher $sshport $source "zfs list -H -o name,guid -s creation -t snapshot $name | grep -E \"$snapshot_filter\" | grep --after-context=200 $guid | grep -v $guid | cut -f1"); do
|
||||||
log "Replicating delta of $last => $snap to $target/$name"
|
log "Replicating delta of $last => $snap to $target/$name"
|
||||||
$ssh $sshport $source "zfs send -w $debug -i $last $snap" | zfs receive -x mountpoint -x canmount -x $tag -x com.sun:auto-snapshot -F $debug $target/$name
|
$ssh $sshcipher $sshport $source "zfs send -w $debug -i $last $snap" | zfs receive -x mountpoint -x canmount -x $tag -x com.sun:auto-snapshot -F $debug $target/$name
|
||||||
last=$snap
|
last=$snap
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -139,7 +149,7 @@ for name in "${syncvols[@]}"; do
|
|||||||
filter=$(echo -e $snapshot_filter | sed "s/|/\n/g")
|
filter=$(echo -e $snapshot_filter | sed "s/|/\n/g")
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for interval in $filter ; do
|
for interval in $filter ; do
|
||||||
guid=$($ssh $sshport $source "zfs list -H -o guid,name -S creation -t snapshot $name | grep $interval | cut -f1 | tail -1")
|
guid=$($ssh $sshcipher $sshport $source "zfs list -H -o guid,name -S creation -t snapshot $name | grep $interval | cut -f1 | tail -1")
|
||||||
if [[ "$(echo -e "$guid" | sed 's/\n//g')" != "" ]]; then
|
if [[ "$(echo -e "$guid" | sed 's/\n//g')" != "" ]]; then
|
||||||
for snap in $($zfs list -H -o name,guid -S creation -t snapshot $target/$name | grep $interval | grep --after-context=200 $guid | grep -v $guid | cut -f1); do
|
for snap in $($zfs list -H -o name,guid -S creation -t snapshot $target/$name | grep $interval | grep --after-context=200 $guid | grep -v $guid | cut -f1); do
|
||||||
log "Deleting $snap"
|
log "Deleting $snap"
|
||||||
|
Loading…
Reference in New Issue
Block a user