From 5ef6063fad5e6fbbfadc657ff7bfd610c539c8f8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 13 Jun 2006 12:04:36 +0200 Subject: [PATCH] Pre_exec problem, resorting Pre_exec has to be executed first, because it may create other configuration options (including mounting the destination!) (the problem was reported by Tonnerre Lombard). Also added more beautiful comments. --- ccollect.sh | 74 +++++++++++++++++++++++++++++++++-------------------- doc/CHANGES | 1 + 2 files changed, 47 insertions(+), 28 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 8178b17..d8e09a1 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -227,6 +227,15 @@ while [ "$i" -lt "$no_sources" ]; do begin=$($DDATE) begin_s=$(date +%s) + # + # unset possible options + # + EXCLUDE="" + RSYNC_EXTRA="" + SUMMARY="" + VERBOSE="" + VVERBOSE="" + echo "$begin Beginning to backup" # @@ -236,11 +245,30 @@ while [ "$i" -lt "$no_sources" ]; do echo "Source does not exist." exit 1 fi + + # + # configuration _must_ be a directory + # if [ ! -d "$backup" ]; then echo "\"$name\" is not a cconfig-directory. Skipping." exit 1 fi + # + # first execute pre_exec, which may generate destination or other + # parameters + # + if [ -x "$c_pre_exec" ]; then + echo "Executing $c_pre_exec ..." + "$c_pre_exec" + echo "Finished ${c_pre_exec}." + + if [ $? -ne 0 ]; then + echo "$c_pre_exec failed, aborting backup." + exit 1 + fi + fi + # # interval definition: First try source specific, fallback to default # @@ -256,16 +284,7 @@ while [ "$i" -lt "$no_sources" ]; do fi # - # unset possible options - # - EXCLUDE="" - RSYNC_EXTRA="" - SUMMARY="" - VERBOSE="" - VVERBOSE="" - - # - # next configuration checks + # Source checks # if [ ! -f "$c_source" ]; then echo "Source description $c_source is not a file. Skipping." @@ -278,46 +297,45 @@ while [ "$i" -lt "$no_sources" ]; do fi fi + # + # destination _must_ be a directory + # if [ ! -d "$c_dest" ]; then echo "Destination $c_dest does not link to a directory. Skipping" exit 1 fi - - # - # pre_exec - # - if [ -x "$c_pre_exec" ]; then - echo "Executing $c_pre_exec ..." - "$c_pre_exec" - echo "Finished ${c_pre_exec}." - if [ $? -ne 0 ]; then - echo "$c_pre_exec failed, aborting backup." - exit 1 - fi - fi - - # exclude + # + # exclude list + # if [ -f "$c_exclude" ]; then EXCLUDE="--exclude-from=$c_exclude" fi - + + # # extra options for rsync + # if [ -f "$c_rsync_extra" ]; then RSYNC_EXTRA="$(cat "$c_rsync_extra")" fi + # # Output a summary + # if [ -f "$c_summary" ]; then SUMMARY="--stats" fi - + + # # Verbosity for rsync + # if [ -f "$c_verbose" ]; then VERBOSE="-v" fi + # # MORE verbosity, includes standard verbosity + # if [ -f "$c_vverbose" ]; then VERBOSE="-v" VVERBOSE="-v" @@ -327,7 +345,7 @@ while [ "$i" -lt "$no_sources" ]; do # check if maximum number of backups is reached, if so remove # - # the created directories are named $INTERVAL.$DA + # the created directories are named $INTERVAL-$DATE-$TIME.$PID count=$(ls -d "$c_dest/${INTERVAL}."?* 2>/dev/null | wc -l | sed 's/^ *//g') echo -n "Currently $count backup(s) exist(s)," echo " total keeping $c_interval backup(s)." diff --git a/doc/CHANGES b/doc/CHANGES index 6ae6606..785fb1d 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,6 +1,7 @@ 0.4 to 0.4.1: * updated documentation * created new document formats: Texinfo and manpage + * fixed problem with 'make install' (strip was used) 0.3.3 to 0.4: * `pax` (Posix) is now required, `cp -al` (GNU specific) is removed