snap-sync: improve remote processing
- be more verbose advertising remote host - require existence of selected snapper config Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -470,10 +470,19 @@ run_config () {
|
|||||||
|
|
||||||
printf "\nVerify configuration...\n"
|
printf "\nVerify configuration...\n"
|
||||||
|
|
||||||
|
SNAP_SYNC_EXCLUDE=no
|
||||||
# loop though selected snapper configurations
|
# loop though selected snapper configurations
|
||||||
# Pseudo Arrays $i -> store associated elements of selected_config
|
# Pseudo Arrays $i -> store associated elements of selected_config
|
||||||
i=0
|
i=0
|
||||||
for selected_config in $selected_configs; do
|
for selected_config in $selected_configs; do
|
||||||
|
# only process existing snap-sync configurations
|
||||||
|
if [ ! -f "/etc/snapper/configs/$selected_config" ]; then
|
||||||
|
die "Selected snapper configuration '$selected_config' does not exist."
|
||||||
|
else
|
||||||
|
. /etc/snapper/configs/$selected_config
|
||||||
|
if [ "$SUBVOLUME" = "/" ]; then
|
||||||
|
SUBVOLUME=''
|
||||||
|
fi
|
||||||
count=$(eval snapper --config $selected_config list --type single | \
|
count=$(eval snapper --config $selected_config list --type single | \
|
||||||
awk '/'"$snap_description_synced"'/' | \
|
awk '/'"$snap_description_synced"'/' | \
|
||||||
awk '/subvolid='"$selected_subvol"'/, /uuid='"$selected_uuid"'/ {cnt++} END {print cnt}')
|
awk '/subvolid='"$selected_subvol"'/, /uuid='"$selected_uuid"'/ {cnt++} END {print cnt}')
|
||||||
@@ -487,20 +496,11 @@ run_config () {
|
|||||||
selected_configs=$(echo $selected_configs | sed -e "s/\($selected_config*\)//")
|
selected_configs=$(echo $selected_configs | sed -e "s/\($selected_config*\)//")
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# cleanup failed former runs
|
# cleanup failed former runs
|
||||||
check_snapper_failed_ids $batch
|
check_snapper_failed_ids $batch
|
||||||
|
|
||||||
SNAP_SYNC_EXCLUDE=no
|
|
||||||
if [ -f "/etc/snapper/configs/$selected_config" ]; then
|
|
||||||
. /etc/snapper/configs/$selected_config
|
|
||||||
if [ "$SUBVOLUME" = "/" ]; then
|
|
||||||
SUBVOLUME=''
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
die "Selected snapper configuration $selected_config does not exist."
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $SNAP_SYNC_EXCLUDE = "yes" ]; then
|
if [ $SNAP_SYNC_EXCLUDE = "yes" ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@@ -688,7 +688,7 @@ run_backup () {
|
|||||||
snapper_target_config=$(eval echo \$snapper_target_config_$i)
|
snapper_target_config=$(eval echo \$snapper_target_config_$i)
|
||||||
snapper_target_snapshot=$(eval echo \$snapper_target_snapshot_$i)
|
snapper_target_snapshot=$(eval echo \$snapper_target_snapshot_$i)
|
||||||
|
|
||||||
verify_snapper_structure "backup_root=$backup_root" "snapper_target_config=$snapper_target_config" "snapper_new_id=$snapper_new_id"
|
verify_snapper_structure "backup_root=$backup_root" "snapper_target_config=$snapper_target_config" "snapper_new_id=$snapper_new_id" "remote=$remote"
|
||||||
|
|
||||||
snapper_target_snapshot_size=$(du --sum $snapper_new_snapshot 2>/dev/null | awk -F ' ' '{print $1}')
|
snapper_target_snapshot_size=$(du --sum $snapper_new_snapshot 2>/dev/null | awk -F ' ' '{print $1}')
|
||||||
|
|
||||||
@@ -1056,20 +1056,21 @@ verify_snapper_structure () {
|
|||||||
local backup_root=${1##backup_root=}
|
local backup_root=${1##backup_root=}
|
||||||
local snapper_config=${2##snapper_target_config=}
|
local snapper_config=${2##snapper_target_config=}
|
||||||
local snapper_id=${3##snapper_new_id=}
|
local snapper_id=${3##snapper_new_id=}
|
||||||
|
local remote_host=${4##remote=}
|
||||||
|
|
||||||
if [ "$verbose" ]; then
|
if [ "$verbose" ]; then
|
||||||
printf "Verify snapper filesystem structure on target ...\n"
|
printf "Verify snapper filesystem structure on target %s...\n" "$remote"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if not accessible, create backup-path
|
# if not accessible, create backup-path
|
||||||
if $ssh [ ! -d $backup_root ]; then
|
if $ssh [ ! -d $backup_root ]; then
|
||||||
if [ ! "$dryrun" ]; then
|
if [ ! "$dryrun" ]; then
|
||||||
if [ "$verbose" ]; then
|
if [ "$verbose" ]; then
|
||||||
printf "Create backup-path %s ...\n" "$backup_root"
|
printf "Create backup-path %s:%s ...\n" "$remote_host" "$backup_root"
|
||||||
fi
|
fi
|
||||||
$ssh mkdir --mode=0700 --parents $backup_root
|
$ssh mkdir --mode=0700 --parents $backup_root
|
||||||
else
|
else
|
||||||
printf "dryrun: Would create backup-path $backup_root %s ...\n" "$backup_root"
|
printf "dryrun: Would create backup-path %s:%s ...\n" "$remote_host" "$backup_root"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user