dsnap-sync: code cleanup
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -1604,7 +1604,7 @@ run_backup () {
|
|||||||
if [ $snapper_common_sync_id -eq 0 ]; then
|
if [ $snapper_common_sync_id -eq 0 ]; then
|
||||||
if [ ${snapper_source_sync_id} != ${snapper_target_sync_id} ]; then
|
if [ ${snapper_source_sync_id} != ${snapper_target_sync_id} ]; then
|
||||||
if [ $snapper_target_sync_id -lt $snapper_target_id ]; then
|
if [ $snapper_target_sync_id -lt $snapper_target_id ]; then
|
||||||
# select commen sync id
|
# try to find last target_sync_id in source_config
|
||||||
get_snapper_sync_id "snapper_config=${snapper_source_config}" "remote="
|
get_snapper_sync_id "snapper_config=${snapper_source_config}" "remote="
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
snapper_source_sync_snapshot=$SUBVOLUME/.snapshots/$snapper_sync_id/snapshot
|
snapper_source_sync_snapshot=$SUBVOLUME/.snapshots/$snapper_sync_id/snapshot
|
||||||
@@ -1648,9 +1648,11 @@ run_backup () {
|
|||||||
$cmd_ionice $ssh cat >$snapper_target_snapshot/$snapper_target_stream 2>$BTRFS_PIPE"
|
$cmd_ionice $ssh cat >$snapper_target_snapshot/$snapper_target_stream 2>$BTRFS_PIPE"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
if [ $verbose -ge 2 ]; then
|
||||||
|
printf "${GREEN}btrfs send${NO_COLOR} is using \n parent snapshot id: ${GREEN}'%s'${NO_COLOR} (path: ${GREEN}'%s'${NO_COLOR}) and\n snapshot id: ${GREEN}'%s'${NO_COLOR} (path: ${GREEN}'%s'${NO_COLOR})\n constructing incremental data-stream ...\n" \
|
||||||
|
"$snapper_common_sync_id" "$snapper_common_sync_snapshot" "$snapper_source_id" "$snapper_source_snapshot"
|
||||||
|
fi
|
||||||
if [ $verbose -ge 3 ]; then
|
if [ $verbose -ge 3 ]; then
|
||||||
printf "${GREEN}btrfs send${NO_COLOR} is using snapshot ${GREEN}'%s'${NO_COLOR} from ${GREEN}source${NO_COLOR} to sync metadata for new snapshot ${GREEN}'%s'${NO_COLOR} ...\n" \
|
|
||||||
"$snapper_source_sync_snapshot" "$snapper_source_snapshot"
|
|
||||||
printf "${GREEN}btrfs command:${NO_COLOR} '%s'\n" "$cmd"
|
printf "${GREEN}btrfs command:${NO_COLOR} '%s'\n" "$cmd"
|
||||||
fi
|
fi
|
||||||
eval $cmd 1>/dev/null
|
eval $cmd 1>/dev/null
|
||||||
@@ -1662,7 +1664,7 @@ run_backup () {
|
|||||||
# is this clause possible?
|
# is this clause possible?
|
||||||
if [ $verbose -ge 3 ]; then
|
if [ $verbose -ge 3 ]; then
|
||||||
printf "${RED}Error: ${NO_COLOR}No commen sync snapshot ${GREEN}'%s'${NO_COLOR} on ${GREEN}source${NO_COLOR} to sync metadata ...\n" \
|
printf "${RED}Error: ${NO_COLOR}No commen sync snapshot ${GREEN}'%s'${NO_COLOR} on ${GREEN}source${NO_COLOR} to sync metadata ...\n" \
|
||||||
"$snapper_source_sync_snapshot"
|
"$snapper_common_sync_snapshot"
|
||||||
die "btrfs send/recieve error."
|
die "btrfs send/recieve error."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -1696,6 +1698,11 @@ run_backup () {
|
|||||||
run_finalize ${selected_config}
|
run_finalize ${selected_config}
|
||||||
run_cleanup ${selected_config}
|
run_cleanup ${selected_config}
|
||||||
|
|
||||||
|
if [ $verbose -ge 1 ]; then
|
||||||
|
printf "${MAGENTA}Backup complete:${NOCOLOR} id=${GREEN}'%s'${NO_COLOR}, config=${GREEN}'%s'${NO_COLOR}\n" \
|
||||||
|
"$snapper_source_id" "$selected_config"
|
||||||
|
fi
|
||||||
|
|
||||||
i=$(($i+1))
|
i=$(($i+1))
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -1730,10 +1737,6 @@ run_finalize () {
|
|||||||
${selected_config}
|
${selected_config}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#i=-1
|
|
||||||
#for selected_config in $selected_configs; do
|
|
||||||
# i=$(($i+1))
|
|
||||||
|
|
||||||
SNAP_SYNC_EXCLUDE=no
|
SNAP_SYNC_EXCLUDE=no
|
||||||
|
|
||||||
if [ -f "/etc/snapper/configs/$selected_config" ]; then
|
if [ -f "/etc/snapper/configs/$selected_config" ]; then
|
||||||
@@ -1865,13 +1868,11 @@ run_finalize () {
|
|||||||
printf "${MAGENTA}Found${NO_COLOR} snapper id ${GREEN}'%s'${NO_COLOR} on target for configuration ${GREEN}'%s'${NO_COLOR}\n" \
|
printf "${MAGENTA}Found${NO_COLOR} snapper id ${GREEN}'%s'${NO_COLOR} on target for configuration ${GREEN}'%s'${NO_COLOR}\n" \
|
||||||
"$snapper_target_id" "$snapper_target_config"
|
"$snapper_target_id" "$snapper_target_config"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $verbose -ge 3 ]; then
|
if [ $verbose -ge 3 ]; then
|
||||||
printf "${MAGENTA}Tagging metadata${NO_COLOR} for snapper id ${GREEN}'%s'${NO_COLOR} on target for configuration ${GREEN}'%s'${NO_COLOR} ...\n" \
|
printf "${MAGENTA}Tagging metadata${NO_COLOR} for snapper id ${GREEN}'%s'${NO_COLOR} on target for configuration ${GREEN}'%s'${NO_COLOR} ...\n" \
|
||||||
"$snapper_target_id" "$snapper_target_config"
|
"$snapper_target_id" "$snapper_target_config"
|
||||||
#printf "calling: '%s'\n" "$($cmd)"
|
#printf "calling: '%s'\n" "$($cmd)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# call command (respect needed quotes)
|
# call command (respect needed quotes)
|
||||||
if [ $remote ]; then
|
if [ $remote ]; then
|
||||||
ret=$(eval $ssh snapper --config \\\'$snapper_target_config\\\' modify \
|
ret=$(eval $ssh snapper --config \\\'$snapper_target_config\\\' modify \
|
||||||
@@ -1904,7 +1905,6 @@ run_finalize () {
|
|||||||
if [ $verbose -ge 2 ]; then
|
if [ $verbose -ge 2 ]; then
|
||||||
printf "${MAGENTA}Tagging source ...${NO_COLOR}\n"
|
printf "${MAGENTA}Tagging source ...${NO_COLOR}\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $snapper_source_id -gt 0 ]; then
|
if [ $snapper_source_id -gt 0 ]; then
|
||||||
cmd="snapper --config $selected_config modify \
|
cmd="snapper --config $selected_config modify \
|
||||||
--description \"$snap_description_synced\" \
|
--description \"$snap_description_synced\" \
|
||||||
@@ -1950,12 +1950,6 @@ run_finalize () {
|
|||||||
cmd="snapper --config $selected_config modify --description $snap_description_finished $snapper_source_sync_id"
|
cmd="snapper --config $selected_config modify --description $snap_description_finished $snapper_source_sync_id"
|
||||||
printf "${MAGENTA}dryrun${NO_COLOR}: %s\n" "$cmd"
|
printf "${MAGENTA}dryrun${NO_COLOR}: %s\n" "$cmd"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $verbose -ge 1 ]; then
|
|
||||||
printf "Backup complete: id=${GREEN}'%s'${NO_COLOR}, config=${GREEN}'%s'${NO_COLOR}\n" \
|
|
||||||
"$snapper_source_id" "$selected_config"
|
|
||||||
fi
|
|
||||||
#done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
select_target () {
|
select_target () {
|
||||||
|
|||||||
Reference in New Issue
Block a user