More fixes

This commit is contained in:
Thorsten Spille 2023-02-18 12:24:18 +01:00
parent e7b707bc47
commit 74465649a1

View File

@ -31,7 +31,7 @@ snapshot_filter="hourly|daily|weekly|monthly"
usage() { usage() {
cat >&2 <<-EOF cat >&2 <<-EOF
usage: $prog [-h] [-c CONFIG] usage: $prog [-h] [-d] [-c CONFIG]
creates a mirrored replication of configured zfs filesystems / volumes creates a mirrored replication of configured zfs filesystems / volumes
-c CONFIG Configuration file for this script -c CONFIG Configuration file for this script
-d Debug mode -d Debug mode
@ -43,7 +43,7 @@ usage() {
exit $1 exit $1
} }
while getopts "hc:" opt; do while getopts "hdc:" opt; do
case $opt in case $opt in
h) usage 0 ;; h) usage 0 ;;
c) conf=$OPTARG ;; c) conf=$OPTARG ;;
@ -126,7 +126,9 @@ for name in "${syncvols[@]}"; do
done done
# cleanup old snapshots # cleanup old snapshots
for interval in $(echo -e $snapshot_filter | sed "s/|/ /g") ; do filter=$(echo -e $snapshot_filter | sed "s/|/ /g")
IFS=$' '
for interval in $filter ; do
guid=$($ssh $source "zfs list -H -o guid,name -S creation -t snapshot $name | grep $interval | cut -f1 | tail -1") guid=$($ssh $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