dsnap-sync: run_finalize() - cleanup handling of metadata tagging
This commit is contained in:
@@ -947,7 +947,7 @@ run_finalize () {
|
|||||||
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)
|
||||||
|
|
||||||
# It's important not to change the values of the key/value pairs ($userdata)
|
# It's important not to change the values of the snapper key/value pairs ($userdata)
|
||||||
# which is stored in snappers info.xml file of the source snapshot.
|
# which is stored in snappers info.xml file of the source snapshot.
|
||||||
# This is how we find the parent.
|
# This is how we find the parent.
|
||||||
|
|
||||||
@@ -958,41 +958,44 @@ run_finalize () {
|
|||||||
target_userdata="subvolid=$src_subvolid, uuid=$src_uuid, host=$src_host"
|
target_userdata="subvolid=$src_subvolid, uuid=$src_uuid, host=$src_host"
|
||||||
|
|
||||||
# Tag new snapshots key/value parameter
|
# Tag new snapshots key/value parameter
|
||||||
|
if [ "$verbose" ]; then
|
||||||
|
printf "Tagging snapper metadata for config '%s' on source.\n" "$selected_config"
|
||||||
|
#fi
|
||||||
|
fi
|
||||||
if [ ! "$dryrun" ]; then
|
if [ ! "$dryrun" ]; then
|
||||||
# source snapshot
|
|
||||||
if [ "$verbose" ]; then
|
|
||||||
printf "Tagging snapper metadata on source for configuration '%s' ...\n" "$selected_config"
|
|
||||||
fi
|
|
||||||
cmd="snapper --verbose --config \"$selected_config\" modify --description \"$snap_description_synced\" --userdata \"$userdata\" \"$snapper_new_id\""
|
|
||||||
ret=$(eval $cmd)
|
|
||||||
#printf "return: '%s'\n" "$ret"
|
|
||||||
sync
|
|
||||||
|
|
||||||
# target snapshot
|
# target snapshot
|
||||||
if [ "$verbose" ]; then
|
# 1) wait for target snapshot to show up in snapper list
|
||||||
printf "Tagging snapper metadata on target for configuration '%s' ...\n" "$selected_config"
|
# find "$snapper_new_id" -> marked as "$snap_descrition_running"
|
||||||
fi
|
# 2) toggle metadata -> mark as "$snap_description_finished", reference "$target_userdata" (subvolid, uuid, host)
|
||||||
|
|
||||||
|
# !!! ugly hack !!!: wait for snapper to list target snapshot in database.
|
||||||
|
# Problem: how to trigger that database is synced? -> a feature request is send to snapper upstream source
|
||||||
|
# Solution: right now, it is no-deterministic, when the entry in the listing will show up .... wait max 10 min ...
|
||||||
ii=1
|
ii=1
|
||||||
ii_max=20
|
ii_max=20
|
||||||
cmd="snapper --verbose --config \"$snapper_target_config\" list --type single | awk '/'\"$snap_description_running\"'/' | awk -F '|' '\$1 == "$snapper_new_id" {print \$1}'"
|
cmd="$ssh snapper --verbose --config $snapper_target_config list --type single | awk ' \"$snap_description_running\" ' | awk -F '|' ' \$1 == "$snapper_new_id" {print \$1} ' "
|
||||||
# !!! ugly hack !!!: wait for snapper to list target snapshot in database. how to trigger database resync?
|
if [ "$verbose" ]; then
|
||||||
# it is not deterministic, when the entry in the listing will show up .... for now, wait max 10 min ...
|
printf "Identify snapper id '%s' on target for configuration '%s' ...\n" "$snapper_new_id" "$snapper_config"
|
||||||
|
fi
|
||||||
while [ "$ii" -le "$ii_max" ]; do
|
while [ "$ii" -le "$ii_max" ]; do
|
||||||
if [ -n "$remote" ]; then
|
# WIP: verbose
|
||||||
ret=$($ssh $cmd)
|
if [ "$verbose" ]; then
|
||||||
else
|
printf "calling: '%s'\n" "$cmd"
|
||||||
ret=$(eval $cmd)
|
|
||||||
fi
|
fi
|
||||||
#printf "return: '%s'\n" "$ret"
|
|
||||||
|
ret=$(eval $cmd)
|
||||||
|
printf "return: '%s'\n" "$ret"
|
||||||
if [ -n "$ret" ]; then
|
if [ -n "$ret" ]; then
|
||||||
if [ "$ret" -eq "$snapper_new_id" ]; then
|
if [ "$ret" -eq "$snapper_new_id" ]; then
|
||||||
cmd="snapper --verbose --config \"$snapper_target_config\" modify --description \"$snap_description_finished\" --userdata \"$target_userdata\" \"$snapper_new_id\""
|
cmd="$ssh snapper --verbose --config \"$snapper_target_config\" modify --description \"$snap_description_finished\" --userdata \"$target_userdata\" \"$snapper_new_id\""
|
||||||
if [ -n "$remote" ]; then
|
# WIP: verbose
|
||||||
ret=$($ssh "$cmd")
|
if [ "$verbose" ]; then
|
||||||
else
|
printf "Update metadata for snapper id '%s' on target for configuration '%s' ...\n" "$snapper_new_id" "$snapper_config"
|
||||||
ret=$(eval $cmd)
|
printf "calling: '%s'\n" "$cmd"
|
||||||
fi
|
fi
|
||||||
#printf "return: '%s'\n" "$ret"
|
|
||||||
|
ret=$(eval $cmd)
|
||||||
|
printf "return: '%s'\n" "$ret"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -1002,11 +1005,20 @@ run_finalize () {
|
|||||||
sleep 30
|
sleep 30
|
||||||
ii=$(($ii + 1))
|
ii=$(($ii + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# source snapshot
|
||||||
|
cmd="snapper --verbose --config \"$selected_config\" modify --description \"$snap_description_synced\" --userdata '\"$userdata\"' \"$snapper_new_id\""
|
||||||
|
if [ "$verbose" ]; then
|
||||||
|
printf "Tagging snapper metadata on source for configuration '%s' ...\n" "$selected_config"
|
||||||
|
printf "calling: '%s'\n" "$cmd"
|
||||||
|
fi
|
||||||
|
eval $cmd
|
||||||
|
sync
|
||||||
else
|
else
|
||||||
cmd="snapper --verbose --config $selected_config modify --description $snap_description_synced --userdata $userdata $snapper_new_id"
|
|
||||||
printf "dryrun: %s\n" "$cmd"
|
|
||||||
cmd="$ssh snapper --verbose --config $snapper_target_config modify -description $snap_description_finished --userdata $target_userdata $snapper_new_id"
|
cmd="$ssh snapper --verbose --config $snapper_target_config modify -description $snap_description_finished --userdata $target_userdata $snapper_new_id"
|
||||||
printf "dryrun: %s\n" "$cmd"
|
printf "dryrun: %s\n" "$cmd"
|
||||||
|
cmd="snapper --verbose --config $selected_config modify --description $snap_description_synced --userdata $userdata $snapper_new_id"
|
||||||
|
printf "dryrun: %s\n" "$cmd"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Cleanup synced source snapshots
|
# Cleanup synced source snapshots
|
||||||
|
|||||||
Reference in New Issue
Block a user