From 186b5bda6812012b8b56a22e5ee39155e5143fac Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 6 Dec 2005 16:20:43 +0100 Subject: [PATCH] Added log description, using old tests now --- README | 12 ++++++++++++ ccollect.sh | 44 +++++++++++++++++++++++++++++--------------- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/README b/README index 423a602..284f39d 100644 --- a/README +++ b/README @@ -14,6 +14,18 @@ $CCOLLECT_CONF/ intervalls/ - subdirectory of source or defaults Each file below this directory describe an intervalls. +-------------------------------------------------------------------------------- + log - link to file we should log to + If a backup source exists (the cconfig dir exists) all logs for this + source will be written to this file. General errors and errors of + non existent or broken configuration will be logged to stderr. + + I do not think it is senseful to have one logfile for all sources, as + the sources can be backuped in parallel and you would not be able to + distinguish the different log processes very good then. + + If you REALLY REALLY REALLY want to have all in one logfile, simply + link all "log" entries to the same file, output will be appended. -------------------------------------------------------------------------------- diff --git a/ccollect.sh b/ccollect.sh index 06b3ec8..be2d77c 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -14,8 +14,8 @@ CCOLLECT_CONF=$HOME/crsnapshot/conf # where to find our configuration and temporary file # CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} -CSOURCES=$CCOLLECT_CONF/sources/ -CDEFAULTS=$CCOLLECT_CONF/defaults/ +CSOURCES=$CCOLLECT_CONF/sources +CDEFAULTS=$CCOLLECT_CONF/defaults TMP=$(mktemp /tmp/$(basename $0).XXXXXX) # @@ -23,6 +23,14 @@ TMP=$(mktemp /tmp/$(basename $0).XXXXXX) # trap "rm -f \"$TMP\"" 1 2 15 +# +# errors! +# +errecho() +{ + echo "Error: $@" >&2 +} + # # Tell how to use us # @@ -98,7 +106,6 @@ if [ "$ALL" = 1 ]; then ls > "$TMP" while read tmp; do - echo ${tmp} eval share_${no_shares}=\"$tmp\" no_shares=$((no_shares+1)) done < "$TMP" @@ -111,36 +118,44 @@ if [ "$no_shares" -lt 1 ]; then usage fi -exit 1 +# +# Let's do the backup +# +i=0 +while [ "$i" -lt "$no_shares" ]; do -for backup in $CCOLLECT_CONF/*; do # # Standard locations # - + eval name=\$share_${i} + backup="$CSOURCES/$name" c_source="$backup/source" c_dest="$backup/destination" c_exclude="$backup/exclude" + + i=$((i+1)) + + echo "Beginning to backup \"$name\" ..." + if [ ! -d "$backup" ]; then + errecho "\"$name\" is not a cconfig-directory. Skipping." + continue + fi + # # Standard configuration checks # - if [ ! -d "$backup" ]; then - echo "Ignoring $backup, is not a directory" - continue - fi - if [ ! -f "$c_source" ]; then - echo "Skipping: Source $c_source is not a file" + echo "Source description $c_source is not a file. Skipping." continue else - source=$(cat $c_source) + source=$(cat "$c_source") if [ $? -ne 0 ]; then echo "Skipping: Source $c_source is not readable" continue fi fi - + if [ ! -d "$c_dest" ]; then echo "Skipping: Destination $c_dest does not link to a directory" continue @@ -150,7 +165,6 @@ for backup in $CCOLLECT_CONF/*; do echo "Skipping: Destination $c_dest does not link to a directory" continue fi - done rm -f "$TMP"