From 735353bd05048fe01a244b772ce708ffe572e11d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 25 Oct 2006 15:16:37 +0200 Subject: [PATCH] Prepare marking of incomplete backups --- TODO | 2 ++ ccollect.sh | 32 +++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index bb3a942..c4025a0 100644 --- a/TODO +++ b/TODO @@ -40,6 +40,8 @@ 09:40 < KillerFox> aber eigentlich logisch. -------------------------------------------------------------------------------- sven / markierung + - wie seht der Marker aus? + -> .ccollect-YEAR-MM-DD.HHmm.pid (like the directory) -------------------------------------------------------------------------------- Add ccollect-restore.sh (new project, perhaps coordinated with jchome's ccollect-config) diff --git a/ccollect.sh b/ccollect.sh index bf7e28b..b798fe1 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -225,6 +225,7 @@ while [ "$i" -lt "$no_sources" ]; do c_vverbose="$backup/very_verbose" c_rsync_extra="$backup/rsync_options" c_summary="$backup/summary" + c_incomplete="$backup/incomplete_remove" c_pre_exec="$backup/pre_exec" c_post_exec="$backup/post_exec" @@ -346,6 +347,25 @@ while [ "$i" -lt "$no_sources" ]; do VVERBOSE="-v" fi + # + # show if we shall remove partial backup, and whether the last one + # is incomplete or not + # + if [ -f "$c_incomplete" ]; then + last_dir=$(ls -d "$c_dest/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1) + + # check whether the last backup was incomplete + # STOPPED HERE + # todo: implement rm -rf, implement warning on non-cleaning + # implement the marknig and normal removing + if [ "$last_dir" ]; then + incomplete=$(cd "$last_dir" && ls .ccollect-????-??-) + if [ "$incomplete" ]; then + "Removing incomplete backup $last_dir ..." + fi + fi + fi + # # check if maximum number of backups is reached, if so remove # @@ -383,6 +403,11 @@ while [ "$i" -lt "$no_sources" ]; do echo "Creating $destination_dir ..." mkdir $VVERBOSE "$destination_dir" || exit 1 + # + # FIXME: add marking here + # touch c_marker + # + # # make an absolute path, perhaps $CCOLLECT_CONF is relative! # @@ -407,7 +432,7 @@ while [ "$i" -lt "$no_sources" ]; do # abs_last_dir="$(cd "$last_dir" && pwd -P)" if [ -z "$abs_last_dir" ]; then - echo "Changing to the backup destination failed. I skip this backup." + echo "Changing to the last backup directory failed. I skip this backup." exit 1 fi @@ -423,6 +448,11 @@ while [ "$i" -lt "$no_sources" ]; do echo "rsync reported error $ret. The backup may be broken (see rsync errors)." fi + # + # FIXME: remove marking here + # rm -f $c_marker + # + echo "$($DDATE) Finished backup" #