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