Fix backup storage creation
This commit is contained in:
parent
4c49199a35
commit
31d1843e88
@ -130,6 +130,16 @@ done
|
|||||||
log "$include_list"
|
log "$include_list"
|
||||||
log "$exclude_list"
|
log "$exclude_list"
|
||||||
|
|
||||||
|
if ! $zfs list $target > /dev/null 2>&1 ; then
|
||||||
|
log "[DEBUG] $target does not exist. Creating..."
|
||||||
|
$zfs create -o com.sun:auto-snapshot=false $target
|
||||||
|
else
|
||||||
|
log "[DEBUG] $target exists, check auto-snapshot..."
|
||||||
|
if [[ $($zfs get -H -o value,source com.sun:auto-snapshot $target) != "false local" ]]; then
|
||||||
|
$zfs set com.sun:auto-snapshot=false $target
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
for name in "${syncvols[@]}"; do
|
for name in "${syncvols[@]}"; do
|
||||||
log "Replicate $name"
|
log "Replicate $name"
|
||||||
@ -143,23 +153,14 @@ for name in "${syncvols[@]}"; do
|
|||||||
|
|
||||||
if [[ $($ssh $sshcipher $sshport $source "zfs list -H -t snapshot -o name -S creation $name 2>/dev/null | grep -E \"$snapshot_filter\" | wc -l | tr -d ' '") -gt 0 ]]; then
|
if [[ $($ssh $sshcipher $sshport $source "zfs list -H -t snapshot -o name -S creation $name 2>/dev/null | grep -E \"$snapshot_filter\" | wc -l | tr -d ' '") -gt 0 ]]; then
|
||||||
IFS=$' '
|
IFS=$' '
|
||||||
if [ $($zfs list -H $target/$name > /dev/null 2>&1 ; echo $?) -gt 0 ]; then
|
if ! $zfs list -H $target/$name > /dev/null 2>&1 ; then
|
||||||
if [[ $debug == "-v" ]]; then log "[DEBUG] $target/$name does not exist"; fi
|
if [[ $debug == "-v" ]]; then log "[DEBUG] $target/$name does not exist"; fi
|
||||||
prefix=""
|
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 [ $($zfs list $prefix$part > /dev/null 2>&1 ; echo $?) -gt 0 ]; then
|
||||||
if [[ $debug == "-v" ]]; then log "[DEBUG] $prefix$part does not exist"; fi
|
if [[ $debug == "-v" ]]; then log "[DEBUG] $prefix$part does not exist"; fi
|
||||||
log "Creating $prefix$part"
|
log "Creating $prefix$part"
|
||||||
if [[ $prefix/$part == $target ]]; then
|
|
||||||
if [[ $debug == "-v" ]]; then log "[DEBUG] Disabling com.sun:auto-snapshot on $prefix$part"; fi
|
|
||||||
autosnap=-ocom.sun:auto-snapshot=false
|
|
||||||
fi
|
|
||||||
$zfs create $autosnap -p $prefix$part
|
$zfs create $autosnap -p $prefix$part
|
||||||
else
|
|
||||||
if [[ $prefix/$part == $target ]] && [[ $(zfs get -H -o value,source com.sun:auto-snapshot $prefix/$part) != "false local" ]]; then
|
|
||||||
if [[ $debug == "-v" ]]; then log "[DEBUG] Disabling com.sun:auto-snapshot on $prefix$part"; fi
|
|
||||||
$zfs set com.sun:auto-snapshot=false $prefix/$part
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
prefix="$prefix$part/"
|
prefix="$prefix$part/"
|
||||||
done
|
done
|
||||||
@ -170,6 +171,12 @@ for name in "${syncvols[@]}"; do
|
|||||||
log "Start initial replication: $snap => $target/$(echo $name | cut -d'/' -f1)"
|
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)
|
$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)
|
||||||
done
|
done
|
||||||
|
else
|
||||||
|
log "[DEBUG] $target already exists, check if com.sun:auto-snapshot is disabled"
|
||||||
|
if [[ $($zfs get -H -o value,source com.sun:auto-snapshot $target) != "false local" ]]; then
|
||||||
|
log "[DEBUG] com.sun:auto-snapshot is enabled on $target - disabling..."
|
||||||
|
$zfs set com.sun:auto-snapshot=false $target
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $debug == "-v" ]]; then log "[DEBUG] $name - Start incremental replication"; fi
|
if [[ $debug == "-v" ]]; then log "[DEBUG] $name - Start incremental replication"; fi
|
||||||
|
Loading…
Reference in New Issue
Block a user