snap-sync: bug backupdir

This commit is contained in:
2017-11-29 01:48:48 +01:00
parent 660f3734c6
commit 6f05af8620

View File

@@ -48,7 +48,7 @@ BTRFS_PIPE=$TMPDIR_PIPE/btrfs.out
exec 3>$PIPE 4>$BTRFS_PIPE
# global variables
donotify=0
donotify=no
answer=no
disk_count=-1
disk_uuid_match_count=0
@@ -77,7 +77,7 @@ check_prerequisites () {
which wc >/dev/null 2>&1 || { printf "'wc' is not installed." && exit 1; }
# optional binaries:
which notify-send >/dev/null 2>&1 && { donotify=1; }
which notify-send >/dev/null 2>&1 && { donotify=yes; }
which pv >/dev/null 2>&1 && { do_pv_cmd=1; }
if [ $(id -u) -ne 0 ] ; then printf "Script must be run as root\n" ; exit 1 ; fi
@@ -220,21 +220,21 @@ get_config(){
local config=${1:-/etc/snapper/config-templates/snap-sync}
local config_key=${2:-SUBVOLUME}
IFS="="
while read -r name value
do
if [ "$name" = "$config_key" ]; then
value="$value"
SUBVOLUME="$value"
break
fi
done < $config
# IFS="="
# while read -r name value
# do
# if [ "$name" = "$config_key" ]; then
# value="$value"
# SUBVOLUME="$value"
# break
# fi
# done < $config
}
notify () {
# estimation: batch calls should just log
if [ $donotify ]; then
if [ "$donotify" = "yes" ]; then
for u in $(users | sed 's/ /\n/' | sort -u); do
sudo -u $u DISPLAY=:0 \
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(sudo -u $u id -u)/bus \
@@ -310,12 +310,12 @@ parse_params () {
;;
-i|--interactive)
interactive=1
donotify=1
donotify=yes
shift
;;
-n|--noconfirm|--batch)
batch=1
donotify=0
donotify=no
shift
;;
--remote)
@@ -544,7 +544,7 @@ run_config () {
printf "Last syncronized Snapshot-Path for '%s': %s\n" "$selected_config" "$snapper_sync_snapshot"
fi
backupdir=$(snapper --config "$selected_config" list --type single | awk -F "|" '/subvolid='"$selected_subvol"'/, /uuid='"$selected_uuid"'/ {print $5}' | awk -F "," '/backupdir/ {print $1}' | awk -F"=" '{print $2}')
backupdir=$(snapper --config "$selected_config" list --type single | awk -F "|" '/'"$snap_description_synced"'/' | awk -F "|" '/subvolid='"$selected_subvol"'/, /uuid='"$selected_uuid"'/ {print $5}' | awk -F "," '/backupdir/ {print $1}' | awk -F"=" '{print $2}')
if [ "$interactive" ]; then
if [ -z "$backupdir"]; then
answer=yes
@@ -1091,7 +1091,7 @@ verify_snapper_structure () {
$ssh snapper --config $snapper_config create-config --template snap-sync $backup_root/$snapper_config
else
# if changed, adapt targets SUBVOLUME in given config
get_config "/etc/snapper/configs/$snapper_config" "SUBVOLUME"
#get_config "/etc/snapper/configs/$snapper_config" "SUBVOLUME"
if $ssh [ "$SUBVOLUME" != \"$backup_root/$snapper_config\" ]; then
SUBVOLUME="$backup_root/$snapper_config"
set_config "/etc/snapper/configs/$snapper_config" "SUBVOLUME" "$SUBVOLUME"
@@ -1115,11 +1115,11 @@ verify_snapper_structure () {
fi
# if changed, adapt SUBVOLUME in given config
#$ssh $(. /etc/snapper/configs/$snapper_config)
get_config "/etc/snapper/configs/$snapper_config" "SUBVOLUME"
if $ssh [ "$SUBVOLUME" != \"$backup_root/$snapper_config\" ]; then
SUBVOLUME="$backup_root/$snapper_config"
set_config "/etc/snapper/configs/$snapper_config" "SUBVOLUME" "$SUBVOLUME"
fi
#get_config "/etc/snapper/configs/$snapper_config" "SUBVOLUME"
#if $ssh [ "$SUBVOLUME" != \"$backup_root/$snapper_config\" ]; then
# SUBVOLUME="$backup_root/$snapper_config"
# set_config "/etc/snapper/configs/$snapper_config" "SUBVOLUME" "$SUBVOLUME"
#fi
if $ssh [ ! -d $backup_root/$snapper_config/$snapper_snapshots ]; then
cmd="btrfs subvolume create $backup_root/$snapper_config/$snapper_snapshots"
$ssh $cmd || die "Can't create subvolume %s in %s to hold target snapshots.\n" "$snapper_snapshots" "$backup_root/$snapper_config"