Fix paths of executables
This commit is contained in:
parent
dd3a6a2fdc
commit
b7e480db73
@ -9,6 +9,12 @@ prog="$(basename $0)"
|
||||
zfs=$(which zfs)
|
||||
ssh=$(which ssh)
|
||||
grep=$(which grep)
|
||||
uniq=$(which uniq)
|
||||
cut=$(which cut)
|
||||
tail=$(which tail)
|
||||
wc=$(which wc)
|
||||
tr=$(which tr)
|
||||
sed=$(which sed)
|
||||
debug=
|
||||
|
||||
#### default config file, can be changed with parameter -c
|
||||
@ -97,13 +103,13 @@ else
|
||||
log "Configuration:\n\ttarget=$target\n\tsource=$source\n\tsshport=$sshport\n\ttag=$tag\n\tsnapshot_filter=$snapshot_filter\n\tmin_keep=$min_keep\n"
|
||||
fi
|
||||
|
||||
local_os_id=$($grep -E "^ID=" /etc/os-release | cut -d'=' -f2)
|
||||
local_os_id=$($grep -E "^ID=" /etc/os-release | $cut -d'=' -f2)
|
||||
remote_os_id=$($ssh $source $sshport "grep -E \"^ID=\" /etc/os-release | cut -d'=' -f2")
|
||||
|
||||
if [[ $local_os_id == "freebsd" ]]; then
|
||||
local_aes=$($grep -o AES /var/run/dmesg.boot | uniq)
|
||||
local_aes=$($grep -o AES /var/run/dmesg.boot | $uniq)
|
||||
else
|
||||
local_aes=$($grep -m1 -o aes /proc/cpuinfo | uniq)
|
||||
local_aes=$($grep -m1 -o aes /proc/cpuinfo | $uniq)
|
||||
fi
|
||||
|
||||
if [[ $remote_os_id == "freebsd" ]]; then
|
||||
@ -124,11 +130,11 @@ include_list="Included datasets:\n"
|
||||
exclude_list="Excluded datasets:\n"
|
||||
IFS=$'\n'
|
||||
for zvol in $($ssh $sshcipher $sshport $source "zfs get -H -o name,value,source -t filesystem,volume $tag"); do
|
||||
name=$(echo $zvol | cut -f1)
|
||||
if [[ "$(echo $zvol | cut -f2)" == "subvols" ]] && [[ $(echo $zvol | $grep -vE "local|received") ]]; then
|
||||
name=$(echo $zvol | $cut -f1)
|
||||
if [[ "$(echo $zvol | $cut -f2)" == "subvols" ]] && [[ $(echo $zvol | $grep -vE "local|received") ]]; then
|
||||
include_list="${include_list}\t${name}\n"
|
||||
syncvols=("${syncvols[@]}" "$name")
|
||||
elif [[ "$(echo $zvol | cut -f2)" == "all" ]] && [[ $(echo $zvol | $grep -v received) ]];then
|
||||
elif [[ "$(echo $zvol | $cut -f2)" == "all" ]] && [[ $(echo $zvol | $grep -v received) ]];then
|
||||
include_list="${include_list}\t${name}\n"
|
||||
syncvols=("${syncvols[@]}" "$name")
|
||||
else
|
||||
@ -173,7 +179,7 @@ for name in "${syncvols[@]}"; do
|
||||
if ! $zfs list -H $target/$name > /dev/null 2>&1 ; then
|
||||
if [[ $debug == "-v" ]]; then log "[DEBUG] $target/$name does not exist"; fi
|
||||
prefix=""
|
||||
for part in $(echo $target/$(echo $name | cut -d'/' -f1) | sed "s/\// /g"); do
|
||||
for part in $(echo $target/$(echo $name | $cut -d'/' -f1) | $sed "s/\// /g"); do
|
||||
if [ $($zfs list $prefix$part > /dev/null 2>&1 ; echo $?) -gt 0 ]; then
|
||||
if [[ $debug == "-v" ]]; then log "[DEBUG] $prefix$part does not exist"; fi
|
||||
log "Creating $prefix$part"
|
||||
@ -185,17 +191,17 @@ for name in "${syncvols[@]}"; do
|
||||
if [[ $debug == "-v" ]]; then log "[DEBUG] $name - Start initial replication"; fi
|
||||
IFS=$'\n'
|
||||
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)"
|
||||
$ssh $ssh_ipher $sshport $source "zfs send -w -p $debug $snap" | $zfs receive $mp $cm -x $tag -x com.sun:auto-snapshot $debug -dF $target/$(echo $name | cut -d'/' -f1)
|
||||
log "Start initial replication: $snap => $target/$(echo $name | $cut -d'/' -f1)"
|
||||
$ssh $sshcipher $sshport $source "zfs send -w -p $debug $snap" | $zfs receive $mp $cm -x $tag -x com.sun:auto-snapshot $debug -dF $target/$(echo $name | $cut -d'/' -f1)
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ $debug == "-v" ]]; then log "[DEBUG] $name - Start incremental replication"; fi
|
||||
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 $sshcipher $sshport $source "zfs list -H -o name,guid -t snapshot $name | grep $guid | tail -1 | cut -f1")
|
||||
IFS=$'\n'
|
||||
if [[ $(zfs get -H -o value canmount $target/$name) != "noauto" ]]; then
|
||||
zfs set canmount=noauto $target/$name
|
||||
if [[ $($zfs get -H -o value canmount $target/$name) != "noauto" ]]; then
|
||||
$zfs set canmount=noauto $target/$name
|
||||
fi
|
||||
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"
|
||||
@ -210,8 +216,8 @@ for name in "${syncvols[@]}"; do
|
||||
if [[ $debug == "-v" ]]; then log "[DEBUG] $name - Checking interval $interval"; fi
|
||||
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
|
||||
snaps_to_delete=$($zfs list -H -o name,guid -S creation -t snapshot $target/$name | $grep $interval | $grep --after-context=200 $guid | $grep -v $guid | cut -f1)
|
||||
snap_count=$($zfs list -H -o name,guid -S creation -t snapshot $target/$name | $grep $interval | wc -l | tr -d ' ')
|
||||
snaps_to_delete=$($zfs list -H -o name,guid -S creation -t snapshot $target/$name | $grep $interval | $grep --after-context=200 $guid | $grep -v $guid | $cut -f1)
|
||||
snap_count=$($zfs list -H -o name,guid -S creation -t snapshot $target/$name | $grep $interval | $wc -l | $tr -d ' ')
|
||||
|
||||
for snap in $snaps_to_delete; do
|
||||
if [[ $snap_count -gt $min_keep ]]; then
|
||||
|
Loading…
Reference in New Issue
Block a user