From 22465abdb536a5e2fc827794da0c20870ea6c371 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 17 Jun 2006 00:28:30 +0200 Subject: [PATCH 001/581] Added size comparing in quickstart --- doc/ccollect.text | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/ccollect.text b/doc/ccollect.text index 4313669..1608c89 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -108,6 +108,10 @@ touch miniconfig/sources/testsource/summary # do the backup, twice CCOLLECT_CONF=./miniconfig ./ccollect.sh testinterval testsource CCOLLECT_CONF=./miniconfig ./ccollect.sh testinterval testsource + +# Let's see how much space we used with two backups and compare it to /bin +du -s ~/DASI /bin + -------------------------------------------------------------------------------- By the way: Cut and paste of the complete section above into your From 165a7a93a500edc868cfb2042f901d5644da5ccf Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 24 Jun 2006 13:17:20 +0200 Subject: [PATCH 002/581] Added list_intervals.sh to show available intervals. --- tools/list_intervals.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 tools/list_intervals.sh diff --git a/tools/list_intervals.sh b/tools/list_intervals.sh new file mode 100755 index 0000000..463f9b4 --- /dev/null +++ b/tools/list_intervals.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# +# Nico Schottelius +# Date: 24-Jun-2006 +# Last Modified: - +# + +CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} +CCOLLECT_INTERVALS="$CCOLLECT_CONF/defaults/intervals" + +if [ ! -d "$CCOLLECT_INTERVALS" ]; then + echo "No intervals defined in $CCOLLECT_INTERVALS" + exit 23 +fi + +cd "$CCOLLECT_INTERVALS" + +for interval in *; do + eval int_$interval=$(cat $interval); + eval echo $interval: \$int_$interval; +done From c313ac8f494de4b91f71fff372a1bbf16df90322 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 25 Jun 2006 10:44:02 +0200 Subject: [PATCH 003/581] Report return code of rsync on failure. --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index 5cd5533..4845a06 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -408,7 +408,7 @@ while [ "$i" -lt "$no_sources" ]; do "$source" "$abs_destination_dir" if [ "$?" -ne 0 ]; then - echo "rsync reported an error. The backup may be broken (see rsync errors)" + echo "rsync reported error $?. The backup may be broken (see rsync errors)" fi echo "$($DDATE) Finished backup" From 0e075857728feaf66b914d076da6a99d19df250b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 5 Sep 2006 21:41:12 +0200 Subject: [PATCH 004/581] Allow overriding of rsync options Moving $RSYNC_EXTRA to the end of options, so users can override the default options. This hint was brought to me by Marcus Wagner. --- ccollect.sh | 10 +++++----- doc/CHANGES | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 4845a06..e94cb82 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -14,8 +14,8 @@ CPREEXEC="$CDEFAULTS/pre_exec" CPOSTEXEC="$CDEFAULTS/post_exec" TMP=$(mktemp /tmp/$(basename $0).XXXXXX) -VERSION=0.4.2 -RELEASE="2006-06-17" +VERSION=0.4.3 +RELEASE="2006-XX-XX" HALF_VERSION="ccollect $VERSION" FULL_VERSION="ccollect $VERSION ($RELEASE)" @@ -403,9 +403,9 @@ while [ "$i" -lt "$no_sources" ]; do echo "$($DDATE) Transferring files..." - rsync -a $VERBOSE $RSYNC_EXTRA $EXCLUDE $SUMMARY \ - --delete --numeric-ids --relative --delete-excluded \ - "$source" "$abs_destination_dir" + rsync -a --delete --numeric-ids --relative --delete-excluded \ + $VERBOSE $EXCLUDE $SUMMARY $RSYNC_EXTRA \ + "$source" "$abs_destination_dir" if [ "$?" -ne 0 ]; then echo "rsync reported error $?. The backup may be broken (see rsync errors)" diff --git a/doc/CHANGES b/doc/CHANGES index 1f1a23e..0a0b929 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,8 @@ +0.4.2 to 0.4.3: + * Display error code of rsync, if non-zero (for further analysis) + * Fix Makefile, so 'make install' works on others OS + * reorder $RSYNC_EXTRA, so it can be overriden by users + 0.4.1 to 0.4.2: * fixed bug when $CCOLLECT_CONF is relative * added Quickstart to documentation From 8c523dd0cf69a76a5ab0891cf02b165ff21f08e5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 13 Oct 2006 11:46:02 +0200 Subject: [PATCH 005/581] Add temporaer todo --- TODO | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 TODO diff --git a/TODO b/TODO new file mode 100644 index 0000000..26feb99 --- /dev/null +++ b/TODO @@ -0,0 +1,62 @@ +11:39 <~papo> was is der Unterschied zu rsync -a --delete + --link-dest=$snapshot/$lastdate /home/ $snapshot/$curdate +-------------------------------------------------------------------------------- +09:30 < KillerFox> -F bzw. --filter +09:30 < KillerFox> -F dir-merge .backuprules +09:30 < KillerFox> rsync ist ein Optionenmonster +09:31 < KillerFox> telmich: man rsync; / FILTER RULES +09:31 < KillerFox> telmich: es ist nur ein Vorschlag, der noch nett wäre :-). +09:32 < KillerFox> telmich: btw. mir ist noch was aufgefallen. Wenn du nur ein eine + Backupversion behalten willst, könnte man rsync etwas + effizienter nutzen. +09:32 < KillerFox> zur Zeit ist es ja so, dass das alte Verzeichnis gekillt wird + und dann wieder neu gespiegelt +09:32 < KillerFox> aber wenn man nur eine Backupversion besitzt könnte man einfach + rsync drüber laufen lassen. +09:33 < KillerFox> so würde dann nur immer die differenz übertragen. +09:34 < KillerFox> -F'dir-merge,.backuprules', das wäre die korrekte Option. +09:34 < telmich> KillerFox: ah, du meinst im spezialfall, wenn es nur ein + verzeichnis gibt? +09:35 < KillerFox> das würde dann pro Verzeichnis nach .backuprules suchen. +09:35 < KillerFox> telmich: genau. +09:35 < KillerFox> und die Regeln aus .backuprules befolgen. +09:35 < telmich> KillerFox: ich denke, das werde ich erstmal in die tipps mit + aufnehmen, denn man kann es ja via rsync_options aendern +09:35 < KillerFox> telmich: das stimmt. +09:35 < KillerFox> RSYNC_EXTRA +09:36 < KillerFox> die Syntax für .backuprules kann man dann in man rsync; /FILTER + RULES nachlesen. + +09:37 < KillerFox> telmich: okay. +09:37 < KillerFox> telmich: das ist nur ein Vorschlag was mir so aufgefallen ist. +09:38 < KillerFox> telmich: btw. der Vorschlag mit einem Verzeichnis kommt übrigens + von Frank. Ich hatte ihm gestern ccollect für die Spiegelung + seines System empfohlen (da ich wusste, dass rsync für ihn + alleine zu kompliziert ist) +09:38 < KillerFox> telmich: er hat da irgendwie echo '1' > daily gemacht und sich + dann gewundert, wieso er immer alles neu überträgt +09:38 < KillerFox> was bei einer angeschlossenen Platte mit USB 1.1 sehr lange + dauern kann +09:39 < KillerFox> da wäre die differenz Ideal. +09:40 < KillerFox> ich habe nur ccollect mit mehr als einer Version im Einsatz ;-) +09:40 < KillerFox> darum ist mir das nie aufgefallen. +09:40 < KillerFox> aber eigentlich logisch. + +-------------------------------------------------------------------------------- + -H, --hard-links preserve hard links + --> vielleicht in die doku fuer rsync_extra aufnehmen + --> teuer, aber platzsparend +-------------------------------------------------------------------------------- + -H, --hard-links preserve hard links + --> fuer das klonen von den backups!! --> doku +-------------------------------------------------------------------------------- +pax / grosse dateien +-------------------------------------------------------------------------------- +sven / markierung +-------------------------------------------------------------------------------- +13:20 rsync -a $VERBOSE $EXCLUDE $SUMMARY \ +13:20 --delete --numeric-ids --relative --delete-excluded + $RSYNC_EXTRA \ +13:20 "$source" "$abs_destination_dir" +13:21 dann greift auch mein --no-relative +-------------------------------------------------------------------------------- From bb7dd035b57a5af989e7050c44609ecdeacefd49 Mon Sep 17 00:00:00 2001 From: Lina Boelling Date: Fri, 13 Oct 2006 11:52:32 +0200 Subject: [PATCH 006/581] Fix broken English by Nico Thanks ettercat ;-) --- doc/ccollect.text | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 1608c89..8ed9dea 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -114,9 +114,10 @@ du -s ~/DASI /bin -------------------------------------------------------------------------------- -By the way: Cut and paste of the complete section above into your -shell will result in downloading ccollect, creating a sample configuration -and doing the backup two times. +Cutting and pasting the complete section above to your shell will result in +the download of ccollect, the creation of a sample configuration and the +execution of two backups. + Requirements ------------ From 2060baa71a20d3238db0610b51e6175db2e3c4dd Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 15 Oct 2006 14:16:20 +0200 Subject: [PATCH 007/581] Preperations for a version without pax --- TODO | 2 ++ ccollect.sh | 8 +++++--- conf/sources/testsource1/source | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 26feb99..0f6292e 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,5 @@ +12:25 [lugs] -!- papo [~mathias@192.168.14.164] +12:25 [lugs] -!- ircname : Mathias Weyland 11:39 <~papo> was is der Unterschied zu rsync -a --delete --link-dest=$snapshot/$lastdate /home/ $snapshot/$curdate -------------------------------------------------------------------------------- diff --git a/ccollect.sh b/ccollect.sh index e94cb82..9480246 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -14,7 +14,7 @@ CPREEXEC="$CDEFAULTS/pre_exec" CPOSTEXEC="$CDEFAULTS/post_exec" TMP=$(mktemp /tmp/$(basename $0).XXXXXX) -VERSION=0.4.3 +VERSION=0.5 RELEASE="2006-XX-XX" HALF_VERSION="ccollect $VERSION" FULL_VERSION="ccollect $VERSION ($RELEASE)" @@ -386,8 +386,9 @@ while [ "$i" -lt "$no_sources" ]; do # only copy if a directory exists if [ "$last_dir" ]; then echo "$($DDATE) Hard linking..." - cd "$last_dir" - pax -rwl -p e $VVERBOSE . "$abs_destination_dir" + #cd "$last_dir" + #pax -rwl -p e $VVERBOSE . "$abs_destination_dir" + rsync_hardlink="--link-dest=\"$last_dir\"" fi if [ $? -ne 0 ]; then @@ -404,6 +405,7 @@ while [ "$i" -lt "$no_sources" ]; do echo "$($DDATE) Transferring files..." rsync -a --delete --numeric-ids --relative --delete-excluded \ + $rsync_hardlink \ $VERBOSE $EXCLUDE $SUMMARY $RSYNC_EXTRA \ "$source" "$abs_destination_dir" diff --git a/conf/sources/testsource1/source b/conf/sources/testsource1/source index f8ea6e1..46b885f 100644 --- a/conf/sources/testsource1/source +++ b/conf/sources/testsource1/source @@ -1 +1 @@ -/home/nico/bilder +/home/user/nico/test2 From ec6bb69c75f9231168b56366bea72fbac8e854d2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 15 Oct 2006 16:31:16 +0200 Subject: [PATCH 008/581] More preparations for removal of pax Use pwd -P to get real path --- ccollect.sh | 16 +++++----------- conf/defaults/post_exec | 2 +- conf/defaults/pre_exec | 1 + conf/sources/testsource1/destination | 2 +- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 9480246..91675b3 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -381,22 +381,14 @@ while [ "$i" -lt "$no_sources" ]; do # # make an absolute path, perhaps $CCOLLECT_CONF is relative! # - abs_destination_dir=$(cd $destination_dir; pwd) + abs_destination_dir=$(cd $destination_dir; pwd -P) # only copy if a directory exists if [ "$last_dir" ]; then - echo "$($DDATE) Hard linking..." - #cd "$last_dir" - #pax -rwl -p e $VVERBOSE . "$abs_destination_dir" + last_dir=$(cd "$last_dir"; pwd -P) rsync_hardlink="--link-dest=\"$last_dir\"" fi - if [ $? -ne 0 ]; then - echo -n "$($DDATE) Creating/cloning backup directory failed." - echo " Skipping backup." - exit 1 - fi - # # the rsync part # options partly stolen from rsnapshot @@ -404,11 +396,13 @@ while [ "$i" -lt "$no_sources" ]; do echo "$($DDATE) Transferring files..." + set -x + rsync -a --delete --numeric-ids --relative --delete-excluded \ $rsync_hardlink \ $VERBOSE $EXCLUDE $SUMMARY $RSYNC_EXTRA \ "$source" "$abs_destination_dir" - + set +x if [ "$?" -ne 0 ]; then echo "rsync reported error $?. The backup may be broken (see rsync errors)" fi diff --git a/conf/defaults/post_exec b/conf/defaults/post_exec index 2192fec..2965574 100755 --- a/conf/defaults/post_exec +++ b/conf/defaults/post_exec @@ -1,5 +1,5 @@ #!/bin/cat ###################################################################### -If you see this content, post_exec was executed. +If you see this content, post_exec was executed. (general post_exec) ###################################################################### diff --git a/conf/defaults/pre_exec b/conf/defaults/pre_exec index eb983c8..09084a6 100755 --- a/conf/defaults/pre_exec +++ b/conf/defaults/pre_exec @@ -1,3 +1,4 @@ #!/bin/cat If you see this content, pre_exec was executed. +(general pre_exec, not source dependent) diff --git a/conf/sources/testsource1/destination b/conf/sources/testsource1/destination index 4d5c4a0..8de582a 120000 --- a/conf/sources/testsource1/destination +++ b/conf/sources/testsource1/destination @@ -1 +1 @@ -/home/nico/backupdir/testsource1 \ No newline at end of file +/home/user/nico/backupdir/testsource1 \ No newline at end of file From 0715932a44d9f1b1306cd93e8501208ec05dc7dd Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 15 Oct 2006 16:33:32 +0200 Subject: [PATCH 009/581] Create directory with absolute path --- ccollect.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 91675b3..fab21c1 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -381,13 +381,7 @@ while [ "$i" -lt "$no_sources" ]; do # # make an absolute path, perhaps $CCOLLECT_CONF is relative! # - abs_destination_dir=$(cd $destination_dir; pwd -P) - - # only copy if a directory exists - if [ "$last_dir" ]; then - last_dir=$(cd "$last_dir"; pwd -P) - rsync_hardlink="--link-dest=\"$last_dir\"" - fi + abs_destination_dir="$(cd $destination_dir; pwd -P)" # # the rsync part @@ -398,6 +392,12 @@ while [ "$i" -lt "$no_sources" ]; do set -x + # Clone from previous backup, if existing + if [ "$last_dir" ]; then + last_dir="$(cd "$last_dir"; pwd -P)" + rsync_hardlink="--link-dest=\"$last_dir\"" + fi + rsync -a --delete --numeric-ids --relative --delete-excluded \ $rsync_hardlink \ $VERBOSE $EXCLUDE $SUMMARY $RSYNC_EXTRA \ From 05f246d58697cc30037357482c4c5b86a82fef90 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 15 Oct 2006 16:37:07 +0200 Subject: [PATCH 010/581] Implement hardlinking in rsync --- ccollect.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index fab21c1..ed4696c 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -375,14 +375,14 @@ while [ "$i" -lt "$no_sources" ]; do # give some info echo "Beginning to backup, this may take some time..." - echo "Creating $destination_dir ..." - mkdir $VVERBOSE "$destination_dir" - # # make an absolute path, perhaps $CCOLLECT_CONF is relative! # abs_destination_dir="$(cd $destination_dir; pwd -P)" + echo "Creating $abs_destination_dir ..." + mkdir $VVERBOSE "$abs_destination_dir" + # # the rsync part # options partly stolen from rsnapshot @@ -392,19 +392,21 @@ while [ "$i" -lt "$no_sources" ]; do set -x + ouropts="-a --delete --numeric-ids --relative --delete-excluded" + useropts="$VERBOSE $EXCLUDE $SUMMARY $RSYNC_EXTRA" + # Clone from previous backup, if existing if [ "$last_dir" ]; then - last_dir="$(cd "$last_dir"; pwd -P)" - rsync_hardlink="--link-dest=\"$last_dir\"" + rsync_hardlink="--link-dest=$last_dir" + rsync $ouropts "$rsync_hardlink" $useropts "$source" "$abs_destination_dir" + else + rsync $ouropts $useropts "$source" "$abs_destination_dir" fi - rsync -a --delete --numeric-ids --relative --delete-excluded \ - $rsync_hardlink \ - $VERBOSE $EXCLUDE $SUMMARY $RSYNC_EXTRA \ - "$source" "$abs_destination_dir" set +x + if [ "$?" -ne 0 ]; then - echo "rsync reported error $?. The backup may be broken (see rsync errors)" + echo "rsync reported error $?. The backup may be broken (see rsync errors)." fi echo "$($DDATE) Finished backup" From 1e1000f1930220f5fa09bbdded81904a6a70981c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 15 Oct 2006 16:48:51 +0200 Subject: [PATCH 011/581] Fix some broken English. Again, add pwd -P instead of pwd. --- ccollect.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index ed4696c..22a46bd 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -77,7 +77,7 @@ fi # if [ ! -d "$CCOLLECT_CONF" ]; then echo "No configuration found in \"$CCOLLECT_CONF\"" \ - " (set \$CCOLLECT_CONF corectly?)" + " (is \$CCOLLECT_CONF properly set?)" exit 1 fi @@ -122,7 +122,7 @@ while [ $i -le $# ]; do done # -# be really really really verbose +# be really, really, really verbose # if [ "$VERBOSE" = 1 ]; then set -x @@ -137,7 +137,7 @@ if [ -x "$CPREEXEC" ]; then echo "Finished ${CPREEXEC}." if [ $? -ne 0 ]; then - echo "$CPREEXEC failed, aborting backup." + echo "$CPREEXEC failed, not starting backup." exit 1 fi fi @@ -152,7 +152,7 @@ if [ "$ALL" = 1 ]; then # # get entries from sources # - cwd=$(pwd) + cwd=$(pwd -P) cd "$CSOURCES"; ls > "$TMP" @@ -378,7 +378,10 @@ while [ "$i" -lt "$no_sources" ]; do # # make an absolute path, perhaps $CCOLLECT_CONF is relative! # - abs_destination_dir="$(cd $destination_dir; pwd -P)" + abs_destination_dir="$(cd $destination_dir && pwd -P)" + + if [ ! "abs_destination_dir" ]; then + echo "Could echo "Creating $abs_destination_dir ..." mkdir $VVERBOSE "$abs_destination_dir" From e6614294c2e0fd7669c8a0eaad76480a7823e85c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 15 Oct 2006 16:50:12 +0200 Subject: [PATCH 012/581] Add checking of result of ls --- ccollect.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ccollect.sh b/ccollect.sh index 22a46bd..403bf79 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -155,6 +155,11 @@ if [ "$ALL" = 1 ]; then cwd=$(pwd -P) cd "$CSOURCES"; ls > "$TMP" + + if [ "$?" -ne 0 ]; then + echo "Listing of sources failed. Aborting." + exit 1 + fi while read tmp; do eval source_${no_sources}=\"$tmp\" From 342b5bf488badb1112f2e5521126196202f50528 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 15 Oct 2006 17:12:39 +0200 Subject: [PATCH 013/581] Fix newly introduced bug (absdir/destination) add absolute directory for --link-dest, because rsync does chdir() before beginnig backup --- ccollect.sh | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 403bf79..e87f637 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -15,7 +15,7 @@ CPOSTEXEC="$CDEFAULTS/post_exec" TMP=$(mktemp /tmp/$(basename $0).XXXXXX) VERSION=0.5 -RELEASE="2006-XX-XX" +RELEASE="2006-10-15" HALF_VERSION="ccollect $VERSION" FULL_VERSION="ccollect $VERSION ($RELEASE)" @@ -380,17 +380,14 @@ while [ "$i" -lt "$no_sources" ]; do # give some info echo "Beginning to backup, this may take some time..." + echo "Creating $destination_dir ..." + mkdir $VVERBOSE "$destination_dir" + # # make an absolute path, perhaps $CCOLLECT_CONF is relative! # abs_destination_dir="$(cd $destination_dir && pwd -P)" - if [ ! "abs_destination_dir" ]; then - echo "Could - - echo "Creating $abs_destination_dir ..." - mkdir $VVERBOSE "$abs_destination_dir" - # # the rsync part # options partly stolen from rsnapshot @@ -398,19 +395,28 @@ while [ "$i" -lt "$no_sources" ]; do echo "$($DDATE) Transferring files..." - set -x - ouropts="-a --delete --numeric-ids --relative --delete-excluded" useropts="$VERBOSE $EXCLUDE $SUMMARY $RSYNC_EXTRA" # Clone from previous backup, if existing + set -x if [ "$last_dir" ]; then - rsync_hardlink="--link-dest=$last_dir" + + # + # This directory MUST be absolute, because rsync does chdir() + # before beginning backup! + # + 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." + exit 1 + fi + + rsync_hardlink="--link-dest=$abs_last_dir" rsync $ouropts "$rsync_hardlink" $useropts "$source" "$abs_destination_dir" else rsync $ouropts $useropts "$source" "$abs_destination_dir" fi - set +x if [ "$?" -ne 0 ]; then From d2369c19639ef936a60382a3cea052637964d21e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 15 Oct 2006 21:01:28 +0200 Subject: [PATCH 014/581] Remove bc --- ccollect.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index e87f637..1e93a65 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -356,8 +356,8 @@ while [ "$i" -lt "$no_sources" ]; do echo " total keeping $c_interval backup(s)." if [ "$count" -ge "$c_interval" ]; then - substract=$(echo $c_interval - 1 | bc) - remove=$(echo $count - $substract | bc) + substract=$((${c_interval} - 1)) + remove=$(($count - $substract)) echo "Removing $remove backup(s)..." ls -d "$c_dest/${INTERVAL}."?* | sort -n | head -n $remove > "$TMP" @@ -440,11 +440,11 @@ while [ "$i" -lt "$no_sources" ]; do end_s=$(date +%s) - full_seconds=$(echo "$end_s - $begin_s" | bc -l) - hours=$(echo $full_seconds / 3600 | bc) - seconds=$(echo "$full_seconds - ($hours * 3600)" | bc) - minutes=$(echo $seconds / 60 | bc) - seconds=$(echo "$seconds - ($minutes * 60)" | bc) + full_seconds=$((${end_s} - ${begin_s})) + hours=$(($full_seconds / 3600)) + seconds=$(($full_seconds - ($hours * 3600))) + minutes=$(($seconds / 60)) + seconds=$((${seconds} - (${minutes} * 60))) echo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" From c19dfcca1d7d2e295e7e9f192f0d9159462bdd90 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 15 Oct 2006 21:02:41 +0200 Subject: [PATCH 015/581] Changes for 0.5 --- doc/CHANGES | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/CHANGES b/doc/CHANGES index 0a0b929..c604c64 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,7 @@ +0.4.3 to 0.5: + * Removed requirement PaX + * Removed requirement bc + 0.4.2 to 0.4.3: * Display error code of rsync, if non-zero (for further analysis) * Fix Makefile, so 'make install' works on others OS From 79445b333b5f56a78365e1002965042f1b8145f3 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 15 Oct 2006 21:27:29 +0200 Subject: [PATCH 016/581] New host --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index ae98eb1..72b1a0a 100644 --- a/Makefile +++ b/Makefile @@ -18,8 +18,8 @@ path_dir=/usr/local/bin path_destination=$(path_dir)/$(CCOLLECT) # where to publish -host=creme.schottelius.org -dir=www/org/schottelius/linux/ccollect +host=home.schottelius.org +dir=www/org/schottelius/unix/www/ccollect/ docdir=$(dir)/doc # @@ -67,10 +67,10 @@ install-script: # Developer targets # update: - @cg-update creme + @cg-update home push-work: - @cg-push creme + @cg-push home @cg-push sygroup publish-doc: documentation From 5b62a92aadfef49a28cbedf82a6e0865a911b983 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 15 Oct 2006 21:28:10 +0200 Subject: [PATCH 017/581] Changes for 0.5 --- conf/sources/testsource1/verbose | 0 doc/ccollect.text | 26 +++++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 conf/sources/testsource1/verbose diff --git a/conf/sources/testsource1/verbose b/conf/sources/testsource1/verbose new file mode 100644 index 0000000..e69de29 diff --git a/doc/ccollect.text b/doc/ccollect.text index 8ed9dea..6626530 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -0.4.2, for ccollect 0.4-0.4.2, Initial Version from 2006-01-13 +0.5, for ccollect 0.4-0.5, Initial Version from 2006-01-13 :Author Initials: NS (pseudo) incremental backup @@ -49,6 +49,16 @@ All other backups are still secure. Incompatibilities ~~~~~~~~~~~~~~~~~ +Versions 0.4 and 0.5 +^^^^^^^^^^^^^^^^^^^^^ +Not a real incompatibilty, but seems to fit in this section: + +.0.5 does *NOT* require +- PaX +- bc + +anymore! + Versions < 0.4 and 0.4 ^^^^^^^^^^^^^^^^^^^^^^ @@ -78,7 +88,7 @@ For those who do not want to read the whole long document: -------------------------------------------------------------------------------- # get latest ccollect tarball from http://unix.schottelius.org/ccollect/ # replace 0.4.2 with the current version -export CCV=0.4.2 +export CCV=0.5 wget http://unix.schottelius.org/ccollect/ccollect-${CCV}.tar.bz2 # extract the tarball, change to the newly created directory @@ -135,8 +145,6 @@ For the installation you need at least Using ccollect ~~~~~~~~~~~~~~ .Running ccollect requires the following tools to be installed: - - `bc` - - `pax` *NEW* (since ccollect 0.4, replaces previously used `cp -al`) - `date` - `rsync` - `ssh` (if you want to use rsync over ssh, which is recommened for security) @@ -240,7 +248,7 @@ Each source contains at least the following files: Additionally a source may have the following files: - `verbose` whether to be verbose (passes -v to `rsync`) - - `very_verbose` be very verbose (-v also for `mkdir`, `pax`, `rm`) + - `very_verbose` be very verbose (-v also for `mkdir`, `rm`) - `summary` create a transfer summary when `rsync` finished - `exclude` exclude list for `rsync`. newline ('\n') seperates list. @@ -300,7 +308,7 @@ Detailed description of "very_verbose" `very_verbose` tells `ccollect` that it should log very verbosely. If this file exists in the source specification *-v* will be passed to -`rsync`, `pax`, `rm` and `mkdir`. +`rsync`, `rm` and `mkdir`. Example: @@ -755,7 +763,7 @@ woechentlich.2006-02-12-11:51.2514 woechentlich.2006-03-16-23:00.4218 ------------------------------------------------------------------------- And this incremental backup and the archive are copied to an external -usb harddisk: +usb harddisk (attention: you *should* really use -H to backup the backup): ------------------------------------------------------------------------- [9:23] eiche:backup# df -h @@ -775,7 +783,7 @@ tmpfs 110M 4.0K 110M 1% /dev/shm [9:24] eiche:backup# cat ~/bin/sync-to-usb DDIR=/mnt/usb/backup -rsync -av --delete /mnt/schwarzesloch/ "$DDIR/schwarzesloch/" +rsync -av -H --delete /mnt/schwarzesloch/ "$DDIR/schwarzesloch/" -rsync -av --delete /mnt/archiv/ "$DDIR/archiv/" +rsync -av -H --delete /mnt/archiv/ "$DDIR/archiv/" ------------------------------------------------------------------------- From 5bfa439ae5f6b42dbaea9838f2c7ed296b06c7f0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 15 Oct 2006 21:38:51 +0200 Subject: [PATCH 018/581] Less todo --- TODO | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/TODO b/TODO index 0f6292e..260d07a 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,3 @@ -12:25 [lugs] -!- papo [~mathias@192.168.14.164] -12:25 [lugs] -!- ircname : Mathias Weyland -11:39 <~papo> was is der Unterschied zu rsync -a --delete - --link-dest=$snapshot/$lastdate /home/ $snapshot/$curdate --------------------------------------------------------------------------------- 09:30 < KillerFox> -F bzw. --filter 09:30 < KillerFox> -F dir-merge .backuprules 09:30 < KillerFox> rsync ist ein Optionenmonster @@ -43,22 +38,5 @@ 09:40 < KillerFox> ich habe nur ccollect mit mehr als einer Version im Einsatz ;-) 09:40 < KillerFox> darum ist mir das nie aufgefallen. 09:40 < KillerFox> aber eigentlich logisch. - --------------------------------------------------------------------------------- - -H, --hard-links preserve hard links - --> vielleicht in die doku fuer rsync_extra aufnehmen - --> teuer, aber platzsparend --------------------------------------------------------------------------------- - -H, --hard-links preserve hard links - --> fuer das klonen von den backups!! --> doku --------------------------------------------------------------------------------- -pax / grosse dateien -------------------------------------------------------------------------------- sven / markierung --------------------------------------------------------------------------------- -13:20 rsync -a $VERBOSE $EXCLUDE $SUMMARY \ -13:20 --delete --numeric-ids --relative --delete-excluded - $RSYNC_EXTRA \ -13:20 "$source" "$abs_destination_dir" -13:21 dann greift auch mein --no-relative --------------------------------------------------------------------------------- From 13585a8c3bab9990824b1a33853c39761ca3a867 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 15 Oct 2006 21:41:24 +0200 Subject: [PATCH 019/581] Release to new location --- release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release.sh b/release.sh index b352e3c..d93f1f9 100755 --- a/release.sh +++ b/release.sh @@ -14,8 +14,8 @@ read bla NAME=$1 TARNAME=${NAME}.tar.bz2 -DHOST=nico@creme.schottelius.org -DDIR=www/org/schottelius/linux/ccollect/ +DHOST=nico@home.schottelius.org +DDIR=www/org/schottelius/unix/www/ccollect/ DESTINATION="$DHOST:$DDIR" tar cvfj "$TARNAME" \ From 817ca9c9c66cd52c5bc68e83b1c6a6fc2993bd47 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 15 Oct 2006 21:42:44 +0200 Subject: [PATCH 020/581] New URL --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 7bd7c8d..a4f6038 100644 --- a/README +++ b/README @@ -27,6 +27,6 @@ doc/man/ccollect.text Manpage in text format doc/man/ccollect.man Manpage in manpage format (generated) -------------------------------------------------------------------------------- -[0]: ccollect: http://linux.schottelius.org/ccollect/ +[0]: ccollect: http://unix.schottelius.org/ccollect/ [1]: rsnapshot: http://www.rsnapshot.org/ [2]: cconfig: http://nico.schotteli.us/papers/linux/cconfig/ From 3ba090093009d584908457a716d57601a889de77 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 15 Oct 2006 21:56:55 +0200 Subject: [PATCH 021/581] Change url --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index 1e93a65..3c56f71 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -61,7 +61,7 @@ usage() echo " This is version $VERSION, released on ${RELEASE}" echo " (the first version was written on 2005-12-05 by Nico Schottelius)." echo "" - echo " Retrieve latest ccollect at http://linux.schottelius.org/ccollect/" + echo " Retrieve latest ccollect at http://unix.schottelius.org/ccollect/" exit 0 } From e64e2655de38fb0241393a36a06e22f8df8ce6af Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 15 Oct 2006 23:39:43 +0200 Subject: [PATCH 022/581] Remove the 0.4.2 note also begin to integrate systems without wget --- doc/ccollect.text | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 6626530..71492e8 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -87,9 +87,14 @@ For those who do not want to read the whole long document: -------------------------------------------------------------------------------- # get latest ccollect tarball from http://unix.schottelius.org/ccollect/ -# replace 0.4.2 with the current version +# replace 0.5 with the current version export CCV=0.5 -wget http://unix.schottelius.org/ccollect/ccollect-${CCV}.tar.bz2 + +# +# replace 'wget' with fetch on bsd +# +holen=wget +"$holen" http://unix.schottelius.org/ccollect/ccollect-${CCV}.tar.bz2 # extract the tarball, change to the newly created directory tar -xvjf ccollect-${CCV}.tar.bz2 From a288efd671e0d5ddde46409c070bde27e1555d3a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 17 Oct 2006 00:38:00 +0200 Subject: [PATCH 023/581] Remove debugging --- ccollect.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 3c56f71..ad3e644 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -399,7 +399,6 @@ while [ "$i" -lt "$no_sources" ]; do useropts="$VERBOSE $EXCLUDE $SUMMARY $RSYNC_EXTRA" # Clone from previous backup, if existing - set -x if [ "$last_dir" ]; then # @@ -417,7 +416,6 @@ while [ "$i" -lt "$no_sources" ]; do else rsync $ouropts $useropts "$source" "$abs_destination_dir" fi - set +x if [ "$?" -ne 0 ]; then echo "rsync reported error $?. The backup may be broken (see rsync errors)." From 635f32af228d69cf89281c76763d2cc6ba078edb Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 19 Oct 2006 14:49:41 +0200 Subject: [PATCH 024/581] Version bumb --- ccollect.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index ad3e644..093213e 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -14,8 +14,8 @@ CPREEXEC="$CDEFAULTS/pre_exec" CPOSTEXEC="$CDEFAULTS/post_exec" TMP=$(mktemp /tmp/$(basename $0).XXXXXX) -VERSION=0.5 -RELEASE="2006-10-15" +VERSION=0.5.1 +RELEASE="2006-10-19" HALF_VERSION="ccollect $VERSION" FULL_VERSION="ccollect $VERSION ($RELEASE)" From 673d46ce3958bb4f2c9d23c04ffbc25deaba84c3 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 19 Oct 2006 14:52:06 +0200 Subject: [PATCH 025/581] Changes for release --- doc/CHANGES | 3 +++ doc/ccollect.text | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/CHANGES b/doc/CHANGES index c604c64..838e0a4 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,6 @@ +0.5 to 0.5.1: + * Remove always printed debug information + 0.4.3 to 0.5: * Removed requirement PaX * Removed requirement bc diff --git a/doc/ccollect.text b/doc/ccollect.text index 71492e8..3cf6b28 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -0.5, for ccollect 0.4-0.5, Initial Version from 2006-01-13 +0.5, for ccollect 0.4-0.5.1, Initial Version from 2006-01-13 :Author Initials: NS (pseudo) incremental backup From 98c65ccf5a32e76c56f79d0e7de1e238f8d79ccc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 19 Oct 2006 14:53:45 +0200 Subject: [PATCH 026/581] I am getting old So there is now a release checklist for me --- doc/release-checklist | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 doc/release-checklist diff --git a/doc/release-checklist b/doc/release-checklist new file mode 100644 index 0000000..c4ed7aa --- /dev/null +++ b/doc/release-checklist @@ -0,0 +1,9 @@ +* Change version in ccollect.sh +* Change version in documentation/ccollect.text +* Regenerate documentation +* Create tarball +* Transfer to home.schottelius.org +* Extract files +* Update website +* Announce on freshmeat +* Announce on announce@ From 5cf8cb74bc47c1984364f988a52e0a697b9d45ae Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 19 Oct 2006 15:25:11 +0200 Subject: [PATCH 027/581] More todo --- TODO | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TODO b/TODO index 260d07a..4ce204f 100644 --- a/TODO +++ b/TODO @@ -40,3 +40,7 @@ 09:40 < KillerFox> aber eigentlich logisch. -------------------------------------------------------------------------------- sven / markierung +-------------------------------------------------------------------------------- +Add ccollect-restore.sh (new project, perhaps coordinated with jchome's +ccollect-config) +-------------------------------------------------------------------------------- From 41669d794bbf2213245cb9bd3f0bc465b9b9b4ce Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 20 Oct 2006 00:05:10 +0200 Subject: [PATCH 028/581] plus date --- doc/release-checklist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/release-checklist b/doc/release-checklist index c4ed7aa..7cba30c 100644 --- a/doc/release-checklist +++ b/doc/release-checklist @@ -1,4 +1,4 @@ -* Change version in ccollect.sh +* Change version and date in ccollect.sh * Change version in documentation/ccollect.text * Regenerate documentation * Create tarball From e759b04a92abda906555d2cc6ba05e18c3edfac5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 20 Oct 2006 00:25:06 +0200 Subject: [PATCH 029/581] Add Makefile for freebsd forts --- ccollect.sh | 4 ++-- external/freebsd-port/Makefile | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 external/freebsd-port/Makefile diff --git a/ccollect.sh b/ccollect.sh index 093213e..fca0a92 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -14,8 +14,8 @@ CPREEXEC="$CDEFAULTS/pre_exec" CPOSTEXEC="$CDEFAULTS/post_exec" TMP=$(mktemp /tmp/$(basename $0).XXXXXX) -VERSION=0.5.1 -RELEASE="2006-10-19" +VERSION=0.5.X +RELEASE="2006-XXXXX" HALF_VERSION="ccollect $VERSION" FULL_VERSION="ccollect $VERSION ($RELEASE)" diff --git a/external/freebsd-port/Makefile b/external/freebsd-port/Makefile new file mode 100644 index 0000000..81a1277 --- /dev/null +++ b/external/freebsd-port/Makefile @@ -0,0 +1,20 @@ +# Makefile for ports - Nico Schottelius +# Date created: 2006-10-20 +# Whom: asami +# +# $FreeBSD$ +# + +PORTNAME= ccollect +PORTVERSION= 0.5.1 +CATEGORIES= games +MASTER_SITES= ftp://ftp.cs.columbia.edu/archives/X11R5/contrib/ + +MAINTAINER= nico-fbsd-ccollect@schottelius.org +COMMENT= (pseudo) incremental (parallel) backup + +MAN1= ccollect.sh.1 +MANCOMPRESSED= yes +USE_IMAKE= yes + +.include From 906ff53b23fee6c69db94757bc3710c55afa8858 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 20 Oct 2006 00:27:53 +0200 Subject: [PATCH 030/581] freebsd: pkg-descr --- external/freebsd-port/pkg-descr | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 external/freebsd-port/pkg-descr diff --git a/external/freebsd-port/pkg-descr b/external/freebsd-port/pkg-descr new file mode 100644 index 0000000..c822c6e --- /dev/null +++ b/external/freebsd-port/pkg-descr @@ -0,0 +1,4 @@ +This is a port of ccollect, a backup utility which creates +fullbackups with the space needed of incremental backups. + +WWW: http://unix.schottelius.org/ccollect/ From 5dfdfa0af01ec058ca7d562b309f7ff6646f4b9c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 20 Oct 2006 00:28:57 +0200 Subject: [PATCH 031/581] freebsd: pkg-list --- external/freebsd-port/pkg-list | 1 + 1 file changed, 1 insertion(+) create mode 100644 external/freebsd-port/pkg-list diff --git a/external/freebsd-port/pkg-list b/external/freebsd-port/pkg-list new file mode 100644 index 0000000..c1d82f9 --- /dev/null +++ b/external/freebsd-port/pkg-list @@ -0,0 +1 @@ +bin/ccollect.sh From 1722576c3e9b0749c332e2dff8d3377e885e68e5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 20 Oct 2006 00:50:30 +0200 Subject: [PATCH 032/581] add categories, remove imake, use bzip2 --- external/freebsd-port/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/external/freebsd-port/Makefile b/external/freebsd-port/Makefile index 81a1277..1b2ff0e 100644 --- a/external/freebsd-port/Makefile +++ b/external/freebsd-port/Makefile @@ -5,16 +5,16 @@ # $FreeBSD$ # +USE_BZIP2= yes PORTNAME= ccollect PORTVERSION= 0.5.1 -CATEGORIES= games -MASTER_SITES= ftp://ftp.cs.columbia.edu/archives/X11R5/contrib/ +CATEGORIES= sysutils archivers +MASTER_SITES= http://unix.schottelius.org/ccollect/ MAINTAINER= nico-fbsd-ccollect@schottelius.org COMMENT= (pseudo) incremental (parallel) backup MAN1= ccollect.sh.1 MANCOMPRESSED= yes -USE_IMAKE= yes .include From 5f6a314749fe0916a3ffce4efac1e505c316b56c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 20 Oct 2006 11:22:32 +0200 Subject: [PATCH 033/581] added testscript --- test/return-value.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 test/return-value.sh diff --git a/test/return-value.sh b/test/return-value.sh new file mode 100755 index 0000000..e91de9a --- /dev/null +++ b/test/return-value.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +ls /surely-not-existent$$ 2>/dev/null + +if [ "$?" -ne 0 ]; then + echo "$?" +fi + +ls /surely-not-existent$$ 2>/dev/null + +ret=$? + +if [ "$ret" -ne 0 ]; then + echo "$ret" +fi + From 8698e47a590cc76497c44c98ea7eda23a0ba5568 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 20 Oct 2006 11:22:57 +0200 Subject: [PATCH 034/581] Some cleanups for the Makefile --- external/freebsd-port/Makefile | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/external/freebsd-port/Makefile b/external/freebsd-port/Makefile index 1b2ff0e..c14c77d 100644 --- a/external/freebsd-port/Makefile +++ b/external/freebsd-port/Makefile @@ -1,11 +1,11 @@ -# Makefile for ports - Nico Schottelius +# New ports collection makefile for: oneko +# New ports collection makefile for: ccollect # Date created: 2006-10-20 -# Whom: asami +# Whom: Nico Schottelius # # $FreeBSD$ # - -USE_BZIP2= yes + PORTNAME= ccollect PORTVERSION= 0.5.1 CATEGORIES= sysutils archivers @@ -15,6 +15,9 @@ MAINTAINER= nico-fbsd-ccollect@schottelius.org COMMENT= (pseudo) incremental (parallel) backup MAN1= ccollect.sh.1 -MANCOMPRESSED= yes +MANCOMPRESSED= no +USE_BZIP2= yes + +RUN_DEPENDS= rsync:${PORTSDIR}/net/rsync .include From 605408d61980966ebc388358a714918f0a2a7ef1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 20 Oct 2006 11:23:20 +0200 Subject: [PATCH 035/581] Add fbsd/distinfo --- external/freebsd-port/distinfo | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 external/freebsd-port/distinfo diff --git a/external/freebsd-port/distinfo b/external/freebsd-port/distinfo new file mode 100644 index 0000000..9e1b6fe --- /dev/null +++ b/external/freebsd-port/distinfo @@ -0,0 +1,2 @@ +MD5 (ccollect-0.5.1.tar.bz2) = 8601a6d6de52ba839768e2804ca57499 +SIZE (ccollect-0.5.1.tar.bz2) = 37397 From 141f9bd535eb6b2501ccfe18a7034e9cbaa514d1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 20 Oct 2006 11:27:09 +0200 Subject: [PATCH 036/581] Display correct return code --- ccollect.sh | 6 ++++-- test/return-value.sh | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index fca0a92..490f6e4 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -417,8 +417,10 @@ while [ "$i" -lt "$no_sources" ]; do rsync $ouropts $useropts "$source" "$abs_destination_dir" fi - if [ "$?" -ne 0 ]; then - echo "rsync reported error $?. The backup may be broken (see rsync errors)." + ret=$? + + if [ "$ret" -ne 0 ]; then + echo "rsync reported error $ret. The backup may be broken (see rsync errors)." fi echo "$($DDATE) Finished backup" diff --git a/test/return-value.sh b/test/return-value.sh index e91de9a..554def0 100755 --- a/test/return-value.sh +++ b/test/return-value.sh @@ -14,3 +14,10 @@ if [ "$ret" -ne 0 ]; then echo "$ret" fi +# if is true, ls is fales +if [ "foo" = "foo" ]; then + ls /surely-not-existent$$ 2>/dev/null +fi + +# but that's still the return of ls and not of fi +echo $? From 82a6e8df8d6d9943d2e27c5eb2ecc3181de8bf8c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 22 Oct 2006 00:11:21 +0200 Subject: [PATCH 037/581] Document changes for 0.5.2 Update example section in documentation --- doc/CHANGES | 3 +++ doc/ccollect.text | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/CHANGES b/doc/CHANGES index 838e0a4..93a51fa 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,6 @@ +0.5.1 to 0.5.2: + * Display correct error code, if rsync returns non-zero + 0.5 to 0.5.1: * Remove always printed debug information diff --git a/doc/ccollect.text b/doc/ccollect.text index 3cf6b28..d11814c 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -87,8 +87,8 @@ For those who do not want to read the whole long document: -------------------------------------------------------------------------------- # get latest ccollect tarball from http://unix.schottelius.org/ccollect/ -# replace 0.5 with the current version -export CCV=0.5 +# replace value for CCV with the current version +export CCV=0.5.1 # # replace 'wget' with fetch on bsd From c7e4bb72a1e53e948827cdf582ff6ff3b930f979 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 24 Oct 2006 00:35:55 +0200 Subject: [PATCH 038/581] Tell the user WHICH interval he/she/it specified for people mixing up options and interval order --- TODO | 1 + ccollect.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 4ce204f..bb3a942 100644 --- a/TODO +++ b/TODO @@ -44,3 +44,4 @@ sven / markierung Add ccollect-restore.sh (new project, perhaps coordinated with jchome's ccollect-config) -------------------------------------------------------------------------------- +clonen von anderen existierenden backups? diff --git a/ccollect.sh b/ccollect.sh index 490f6e4..c89e428 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -283,7 +283,7 @@ while [ "$i" -lt "$no_sources" ]; do c_interval=$D_INTERVAL if [ -z "$c_interval" ]; then - echo "Default and source specific interval missing. Skipping." + echo "No definition for interval \"$INTERVAL\" found. Skipping." exit 1 fi fi From feaf5c141311122ea030893af0046e04aeae479b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 25 Oct 2006 00:56:46 +0200 Subject: [PATCH 039/581] Small comparision table --- README | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README b/README index a4f6038..572d431 100644 --- a/README +++ b/README @@ -12,9 +12,39 @@ ccollect was inspired by rsnapshot [1], which has some problems: - you can not specify per source exclude lists - no per source pre/post execution support - no parallel execution + - does unecessary moving of backup directories - I didn't like the configuration at all, so I used the cconfig style [2]. +A small try to visualize the differnces in a table: + ++---------------+-------------------------------------------------------------+ ++ What? | rsnapshot | ccollect | ++---------------+-------------------------------------------------------------+ +| Configuration | tab separated, needs | plain cconfig-style | +| | parsing | | ++---------------+-------------------------------------------------------------+ +| Per source | | | +| post-/pre- | no | yes | +| execution | | | ++---------------+-------------------------------------------------------------+ +| Per source | | | +| exclude lists | no | yes | ++---------------+-------------------------------------------------------------+ +| Parallel | | | +| execution | | | +| of multiple | no | yes | +| backups | | | ++---------------+-------------------------------------------------------------+ +| Programming | perl | sh | +| language | | (posix compatible) | ++---------------+-------------------------------------------------------------+ +| Lines of code | 6636 | 476 | +| (2006-10-25) | | | ++---------------+-------------------------------------------------------------+ +| Age | Available since 2002/2003 | Written at 2005-11-14 | ++---------------+-------------------------------------------------------------+ + Included documentation: doc/ccollect.text Manual in text format From caa11c5626da6c1fe15d03ad8cbe887d914fb039 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 25 Oct 2006 08:10:02 +0200 Subject: [PATCH 040/581] Minor indentions --- README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README b/README index 572d431..ad6a181 100644 --- a/README +++ b/README @@ -19,9 +19,9 @@ ccollect was inspired by rsnapshot [1], which has some problems: A small try to visualize the differnces in a table: +---------------+-------------------------------------------------------------+ -+ What? | rsnapshot | ccollect | +| What? | rsnapshot | ccollect | +---------------+-------------------------------------------------------------+ -| Configuration | tab separated, needs | plain cconfig-style | +| Configuration | tab separated, needs | plain cconfig-style | | | parsing | | +---------------+-------------------------------------------------------------+ | Per source | | | From 952adc32f2033256624facf5b0c9ee668ff3ec29 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 25 Oct 2006 08:10:21 +0200 Subject: [PATCH 041/581] Instantly exit, when creating the destination fails --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index c89e428..c521a0c 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -381,7 +381,7 @@ while [ "$i" -lt "$no_sources" ]; do echo "Beginning to backup, this may take some time..." echo "Creating $destination_dir ..." - mkdir $VVERBOSE "$destination_dir" + mkdir $VVERBOSE "$destination_dir" || exit 1 # # make an absolute path, perhaps $CCOLLECT_CONF is relative! From b31989c476ed1e574134bbc15ac63ba34c3c041b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 25 Oct 2006 14:48:48 +0200 Subject: [PATCH 042/581] Whitespace cleanup --- ccollect.sh | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index c521a0c..bf7e28b 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -90,7 +90,7 @@ no_sources=0 while [ $i -le $# ]; do eval arg=\$$i - + if [ "$NO_MORE_ARGS" = 1 ]; then eval source_${no_sources}=\"$arg\" no_sources=$(($no_sources+1)) @@ -148,7 +148,7 @@ fi if [ "$ALL" = 1 ]; then # reset everything specified before no_sources=0 - + # # get entries from sources # @@ -160,7 +160,7 @@ if [ "$ALL" = 1 ]; then echo "Listing of sources failed. Aborting." exit 1 fi - + while read tmp; do eval source_${no_sources}=\"$tmp\" no_sources=$(($no_sources+1)) @@ -171,7 +171,7 @@ fi # Need at least ONE source to backup # if [ "$no_sources" -lt 1 ]; then - usage + usage else echo "==> $HALF_VERSION: Beginning backup using interval $INTERVAL <==" fi @@ -250,7 +250,7 @@ while [ "$i" -lt "$no_sources" ]; do echo "Source does not exist." exit 1 fi - + # # configuration _must_ be a directory # @@ -316,28 +316,28 @@ while [ "$i" -lt "$no_sources" ]; do 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 # @@ -345,16 +345,16 @@ while [ "$i" -lt "$no_sources" ]; do VERBOSE="-v" VVERBOSE="-v" fi - + # # check if maximum number of backups is reached, if so remove # - + # 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)." - + if [ "$count" -ge "$c_interval" ]; then substract=$((${c_interval} - 1)) remove=$(($count - $substract)) @@ -367,16 +367,16 @@ while [ "$i" -lt "$no_sources" ]; do rm $VVERBOSE -rf "$dir" done < "$TMP" fi - + # # clone the old directory with hardlinks # destination_date=$($CDATE) destination_dir="$c_dest/${INTERVAL}.${destination_date}.$$" - + last_dir=$(ls -d "$c_dest/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1) - + # give some info echo "Beginning to backup, this may take some time..." @@ -392,7 +392,7 @@ while [ "$i" -lt "$no_sources" ]; do # the rsync part # options partly stolen from rsnapshot # - + echo "$($DDATE) Transferring files..." ouropts="-a --delete --numeric-ids --relative --delete-excluded" @@ -400,7 +400,7 @@ while [ "$i" -lt "$no_sources" ]; do # Clone from previous backup, if existing if [ "$last_dir" ]; then - + # # This directory MUST be absolute, because rsync does chdir() # before beginning backup! @@ -466,7 +466,7 @@ if [ -x "$CPOSTEXEC" ]; then echo "$($DDATE) Executing $CPOSTEXEC ..." "$CPOSTEXEC" echo "$($DDATE) Finished ${CPOSTEXEC}." - + if [ $? -ne 0 ]; then echo "$CPOSTEXEC failed." fi From 735353bd05048fe01a244b772ce708ffe572e11d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 25 Oct 2006 15:16:37 +0200 Subject: [PATCH 043/581] 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" # From bf4433ad63081051941bf8a1e08ce521d17af6a5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 26 Oct 2006 10:30:14 +0200 Subject: [PATCH 044/581] Hint: source specific intervals --- ccollect.sh | 3 ++- doc/ccollect.text | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index b798fe1..6cbca47 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" @@ -405,7 +406,7 @@ while [ "$i" -lt "$no_sources" ]; do # # FIXME: add marking here - # touch c_marker + # touch $c_marker # # diff --git a/doc/ccollect.text b/doc/ccollect.text index d11814c..d1741e2 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -537,6 +537,22 @@ use a link to The only requirement is that it is executable. + +Using source specific interval definitions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +When you are backing up multiple hosts via cron each night, it may be +a problem that host "big_server" may only have 4 daily backups, because +otherwise its backup device will be full. But for all other hosts +you want to keep 20 daily backups. In this case you would create +`/etc/ccollect/default/intervals/daily` containing "20" and +`/etc/ccollect/sources/big_server/intervals/daily` containing "4". + +Source specific intervals always overwrite the default values. +If you have to specify it individually for every host, because +of different requirements, you can even omit creating +`/etc/ccollect/default/intervals/daily`. + + F.A.Q. ------ From 8b2bda8c403dd1db90e4713f2b9adb30f161c31b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 26 Oct 2006 11:55:16 +0200 Subject: [PATCH 045/581] Add html generated by docbook --- .gitignore | 1 + Makefile | 57 +++++++++++++++++++++++++++++++----------------------- TODO | 2 ++ 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 2292884..d1a77cc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ conf/sources/*/destination/* doc/old doc/*.html +doc/*.htm doc/*.docbook doc/*.texi doc/man/*.html diff --git a/Makefile b/Makefile index 72b1a0a..4a0e871 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,8 @@ LN=ln -sf ASCIIDOC=asciidoc DOCBOOKTOTEXI=docbook2x-texi DOCBOOKTOMAN=docbook2x-man +XSLTPROC=xsltproc +XSL=/usr/share/xml/docbook/stylesheet/nwalsh/html/docbook.xsl prefix=/usr/packages/ccollect-git bindir=$(prefix)/bin @@ -28,6 +30,26 @@ docdir=$(dir)/doc MANDOCS = doc/man/ccollect.text DOCS = $(MANDOCS) doc/ccollect.text doc/ccollect-DE.text +# +# Doku +# +HTMLDOCS = $(DOCS:.text=.html) +DBHTMLDOCS = $(DOCS:.text=.htm) + +TEXIDOCS = $(DOCS:.text=.texi) + +MANPDOCS = $(MANDOCS:.text=.man) + +DOCBDOCS = $(DOCS:.text=.docbook) + +DOC_ALL = $(HTMLDOCS) $(DBHTMLDOCS) $(TEXIDOCS) $(MANPDOCS) + +html: $(HTMLDOCS) +htm: $(DBHTMLDOCS) +info: $(TEXIDOCS) +man: $(MANPDOCS) +documentation: $(DOC_ALL) + # # End user targets # @@ -48,6 +70,13 @@ install-script: $(INSTALL) -D -m 0755 $(CCOLLECT) $(destination) +# docbook gets .htm, asciidoc directly .html +%.htm: %.docbook + ${XSLTPROC} -o $@ ${XSL} $< + +%.html: %.text %.docbook + ${ASCIIDOC} -n -o $@ $< + %.html: %.text ${ASCIIDOC} -n -o $@ $< @@ -75,35 +104,15 @@ push-work: publish-doc: documentation @echo "Transferring files to $(host)" - @chmod a+r doc/*.html doc/*.text - @scp doc/*.text doc/*.html doc/*.texi doc/man/*.man $(host):$(docdir) - @ssh $(host) "cd $(docdir); chmod a+r *" - -# -# Doku -# -HTMLDOCS = $(DOCS:.text=.html) - -TEXIDOCS = $(DOCS:.text=.texi) - -MANPDOCS = $(MANDOCS:.text=.man) - -DOCBDOCS = $(DOCS:.text=.docbook) - - -html: $(HTMLDOCS) - -info: $(TEXIDOCS) - -man: $(MANPDOCS) - -documentation: html info man + @chmod a+r $(DOCS) $(DOC_ALL) + @tar c $(DOCS) $(DOC_ALL) | ssh $(host) "cd $(dir); tar xv" +# @ssh $(host) "cd $(docdir); chmod -R a+r *" # # Distribution # allclean: - rm -f $(TEXIDOCS) $(HTMLDOCS) $(MANPDOCS) $(DOCBDOCS) + rm -f $(DOC_ALL) distclean: rm -f $(DOCBDOCS) diff --git a/TODO b/TODO index c4025a0..b8ab0d9 100644 --- a/TODO +++ b/TODO @@ -42,6 +42,8 @@ sven / markierung - wie seht der Marker aus? -> .ccollect-YEAR-MM-DD.HHmm.pid (like the directory) + --> assume incomplete, when we did not finish. + --> means it's complete,when rsync was successful -------------------------------------------------------------------------------- Add ccollect-restore.sh (new project, perhaps coordinated with jchome's ccollect-config) From 50c75ccf43811bdea45b894b57bd6149d2201bc8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 31 Oct 2006 07:58:00 +0100 Subject: [PATCH 046/581] Several minor changes --- Makefile | 1 - ccollect.sh | 15 ++++++++------ doc/ccollect.text | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 4a0e871..6b48063 100644 --- a/Makefile +++ b/Makefile @@ -106,7 +106,6 @@ publish-doc: documentation @echo "Transferring files to $(host)" @chmod a+r $(DOCS) $(DOC_ALL) @tar c $(DOCS) $(DOC_ALL) | ssh $(host) "cd $(dir); tar xv" -# @ssh $(host) "cd $(docdir); chmod -R a+r *" # # Distribution diff --git a/ccollect.sh b/ccollect.sh index 6cbca47..39f48c0 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -227,6 +227,7 @@ while [ "$i" -lt "$no_sources" ]; do c_summary="$backup/summary" c_incomplete="$backup/incomplete_remove" + c_marker=".ccollect-${CDATE}.$$" c_pre_exec="$backup/pre_exec" c_post_exec="$backup/post_exec" @@ -266,7 +267,7 @@ while [ "$i" -lt "$no_sources" ]; do # parameters # if [ -x "$c_pre_exec" ]; then - echo "Executing $c_pre_exec ..." + echo "Executing ${c_pre_exec} ..." "$c_pre_exec" echo "Finished ${c_pre_exec}." @@ -352,6 +353,7 @@ while [ "$i" -lt "$no_sources" ]; do # show if we shall remove partial backup, and whether the last one # is incomplete or not # + # FIXME: test general for incomplete and decide only for warn|delete based on option? if [ -f "$c_incomplete" ]; then last_dir=$(ls -d "$c_dest/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1) @@ -363,6 +365,7 @@ while [ "$i" -lt "$no_sources" ]; do incomplete=$(cd "$last_dir" && ls .ccollect-????-??-) if [ "$incomplete" ]; then "Removing incomplete backup $last_dir ..." + echo rm -rf $VVERBOSE "$last_dir" fi fi fi @@ -404,16 +407,16 @@ 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! # abs_destination_dir="$(cd $destination_dir && pwd -P)" + # + # add mark + # + touch "${abs_destination_dir}/${c_marker}" + # # the rsync part # options partly stolen from rsnapshot diff --git a/doc/ccollect.text b/doc/ccollect.text index d1741e2..1999e65 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -808,3 +808,53 @@ rsync -av -H --delete /mnt/schwarzesloch/ "$DDIR/schwarzesloch/" rsync -av -H --delete /mnt/archiv/ "$DDIR/archiv/" ------------------------------------------------------------------------- + + +Processes running when doing ccollect -p +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Truncated output from `ps axuwwwf`: + +------------------------------------------------------------------------- + S+ 11:40 0:00 | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily -p ddba034 ddba045 ddba046 ddba047 ddba049 ddna010 ddna011 + S+ 11:40 0:00 | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddba034 + S+ 11:40 0:00 | | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddba034 + R+ 11:40 23:40 | | | | | \_ rsync -a --delete --numeric-ids --relative --delete-excluded --link-dest=/home/server/backup/ddba034 + S+ 11:40 0:00 | | | | | \_ ssh -l root ddba034.netstream.ch rsync --server --sender -vlogDtprR --numeric-ids . / + S+ 11:41 0:11 | | | | | \_ rsync -a --delete --numeric-ids --relative --delete-excluded --link-dest=/home/server/backup/ddb + S+ 11:40 0:00 | | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddba034 + S+ 11:40 0:00 | | | | \_ sed s:^:\[ddba034\] : + S+ 11:40 0:00 | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddba045 + S+ 11:40 0:00 | | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddba045 + R+ 11:40 0:02 | | | | | \_ rm -rf /etc/ccollect/sources/ddba045/destination/daily.2006-10-19-1807.6934 + S+ 11:40 0:00 | | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddba045 + S+ 11:40 0:00 | | | | \_ sed s:^:\[ddba045\] : + S+ 11:40 0:00 | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddba046 + S+ 11:40 0:00 | | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddba046 + R+ 11:40 0:02 | | | | | \_ rm -rf /etc/ccollect/sources/ddba046/destination/daily.2006-10-19-1810.7072 + S+ 11:40 0:00 | | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddba046 + S+ 11:40 0:00 | | | | \_ sed s:^:\[ddba046\] : + S+ 11:40 0:00 | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddba047 + S+ 11:40 0:00 | | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddba047 + R+ 11:40 0:03 | | | | | \_ rm -rf /etc/ccollect/sources/ddba047/destination/daily.2006-10-19-1816.7268 + S+ 11:40 0:00 | | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddba047 + S+ 11:40 0:00 | | | | \_ sed s:^:\[ddba047\] : + S+ 11:40 0:00 | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddba049 + S+ 11:40 0:00 | | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddba049 + D+ 11:40 0:03 | | | | | \_ rm -rf /etc/ccollect/sources/ddba049/destination/daily.2006-10-19-1821.7504 + S+ 11:40 0:00 | | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddba049 + S+ 11:40 0:00 | | | | \_ sed s:^:\[ddba049\] : + S+ 11:40 0:00 | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddna010 + S+ 11:40 0:00 | | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddna010 + R+ 11:40 0:03 | | | | | \_ rm -rf /etc/ccollect/sources/ddna010/destination/daily.2006-10-19-1805.6849 + S+ 11:40 0:00 | | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddna010 + S+ 11:40 0:00 | | | | \_ sed s:^:\[ddna010\] : + S+ 11:40 0:00 | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddna011 + S+ 11:40 0:00 | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddna011 + R+ 12:08 0:00 | | | | \_ rm -rf /etc/ccollect/sources/ddna011/destination/daily.2006-10-20-1502.7824 + S+ 11:40 0:00 | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddna011 + S+ 11:40 0:00 | | | \_ sed s:^:\[ddna011\] : + +------------------------------------------------------------------------- +As you can see, six processes are deleting old backups, while one backup +(ddba034) is already copying data. + From b78a48917e6f4d344fdf386f7cc80d92637cc742 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 31 Oct 2006 07:58:54 +0100 Subject: [PATCH 047/581] [bugfix] Wrong return value check Found by Alexey Maximov --- ccollect.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index 39f48c0..aecdbf5 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -269,9 +269,10 @@ while [ "$i" -lt "$no_sources" ]; do if [ -x "$c_pre_exec" ]; then echo "Executing ${c_pre_exec} ..." "$c_pre_exec" + ret=$? echo "Finished ${c_pre_exec}." - if [ $? -ne 0 ]; then + if [ $ret -ne 0 ]; then echo "$c_pre_exec failed, aborting backup." exit 1 fi From e4c63dec6caa90305e434a25c7fe3ae6f4942906 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 31 Oct 2006 08:12:49 +0100 Subject: [PATCH 048/581] +CREDITS --- CREDITS | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CREDITS diff --git a/CREDITS b/CREDITS new file mode 100644 index 0000000..3f36270 --- /dev/null +++ b/CREDITS @@ -0,0 +1,5 @@ +Thanks go to the following people: + + - the whole #cLinux channel for testing and debugging + (those I mean should know ;-) + - Alexey Maximov for finding return-value and shell limitation bugs From 5c74195f20e8322095a6a90a4cddbc476ec81b97 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 31 Oct 2006 08:18:58 +0100 Subject: [PATCH 049/581] More return value checking fixes --- ccollect.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index aecdbf5..f780091 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -134,9 +134,10 @@ fi if [ -x "$CPREEXEC" ]; then echo "Executing $CPREEXEC ..." "$CPREEXEC" + ret=$? echo "Finished ${CPREEXEC}." - if [ $? -ne 0 ]; then + if [ $ret -ne 0 ]; then echo "$CPREEXEC failed, not starting backup." exit 1 fi @@ -466,9 +467,10 @@ while [ "$i" -lt "$no_sources" ]; do if [ -x "$c_post_exec" ]; then echo "$($DDATE) Executing $c_post_exec ..." "$c_post_exec" + ret=$? echo "$($DDATE) Finished ${c_post_exec}." - if [ $? -ne 0 ]; then + if [ $ret -ne 0 ]; then echo "$c_post_exec failed." fi fi @@ -500,9 +502,10 @@ fi if [ -x "$CPOSTEXEC" ]; then echo "$($DDATE) Executing $CPOSTEXEC ..." "$CPOSTEXEC" + ret=$? echo "$($DDATE) Finished ${CPOSTEXEC}." - if [ $? -ne 0 ]; then + if [ $ret -ne 0 ]; then echo "$CPOSTEXEC failed." fi fi From b9314edb78205eeeba6b71b2f953471e6c425c19 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 14 Nov 2006 23:35:10 +0100 Subject: [PATCH 050/581] Some count tests --- ccollect.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index f780091..9ad3e86 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -14,7 +14,7 @@ CPREEXEC="$CDEFAULTS/pre_exec" CPOSTEXEC="$CDEFAULTS/post_exec" TMP=$(mktemp /tmp/$(basename $0).XXXXXX) -VERSION=0.5.X +VERSION=0.5.2 RELEASE="2006-XXXXX" HALF_VERSION="ccollect $VERSION" FULL_VERSION="ccollect $VERSION ($RELEASE)" @@ -377,7 +377,7 @@ while [ "$i" -lt "$no_sources" ]; do # # the created directories are named $INTERVAL-$DATE-$TIME.$PID - count=$(ls -d "$c_dest/${INTERVAL}."?* 2>/dev/null | wc -l | sed 's/^ *//g') + count=$(cd "$c_dest" && ls -p1 | grep "^${INTERVAL}\..*/\$" | wc -l | sed 's/^ *//g') echo -n "Currently $count backup(s) exist(s)," echo " total keeping $c_interval backup(s)." @@ -387,6 +387,7 @@ while [ "$i" -lt "$no_sources" ]; do echo "Removing $remove backup(s)..." ls -d "$c_dest/${INTERVAL}."?* | sort -n | head -n $remove > "$TMP" + #( cd "$c_dest" && ls -p1 | grep "^${INTERVAL}\..*/\$" | sort -n | head -n $remove > "$TMP" while read to_remove; do dir="$to_remove" echo "Removing $dir ..." From be9d93c997039930dcb8c9ccf4b5708b95d24d0f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 14 Nov 2006 23:37:16 +0100 Subject: [PATCH 051/581] Possible problem with spaces in interval names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 23:36 < dev-zero> telmich: abs_destination_dir="$(cd $destination_dir && pwd -P)" 23:36 < dev-zero> telmich: wenn das interval spaces enthält, dann auch destination_dir --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index 9ad3e86..27c70ce 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -413,7 +413,7 @@ while [ "$i" -lt "$no_sources" ]; do # # make an absolute path, perhaps $CCOLLECT_CONF is relative! # - abs_destination_dir="$(cd $destination_dir && pwd -P)" + abs_destination_dir="$(cd "$destination_dir" && pwd -P)" # # add mark From 9c2b38bd17e73852f9bed3fffe534139bcfc6631 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 14 Nov 2006 23:51:17 +0100 Subject: [PATCH 052/581] Fix possible problem due to not checked success of cd --- ccollect.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 27c70ce..1e4312f 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -103,7 +103,7 @@ while [ $i -le $# ]; do VERBOSE=1 ;; -p|--parallel) - PARALLEL="1" + PARALLEL=1 ;; -h|--help) usage @@ -154,8 +154,7 @@ if [ "$ALL" = 1 ]; then # get entries from sources # cwd=$(pwd -P) - cd "$CSOURCES"; - ls > "$TMP" + ( cd "$CSOURCES" && ls > "$TMP" ) if [ "$?" -ne 0 ]; then echo "Listing of sources failed. Aborting." From 7e27ca0f3dcb7e7cb7fafa321d7a38a4a21dac58 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 15 Nov 2006 00:01:19 +0100 Subject: [PATCH 053/581] More quote changes --- ccollect.sh | 8 ++++---- .../{testsource1 => source with spaces}/destination | 0 conf/sources/{testsource1 => source with spaces}/exclude | 0 .../{testsource1 => source with spaces}/intervalls/daily | 0 conf/sources/{testsource1 => source with spaces}/source | 0 conf/sources/{testsource1 => source with spaces}/verbose | 0 6 files changed, 4 insertions(+), 4 deletions(-) rename conf/sources/{testsource1 => source with spaces}/destination (100%) rename conf/sources/{testsource1 => source with spaces}/exclude (100%) rename conf/sources/{testsource1 => source with spaces}/intervalls/daily (100%) rename conf/sources/{testsource1 => source with spaces}/source (100%) rename conf/sources/{testsource1 => source with spaces}/verbose (100%) diff --git a/ccollect.sh b/ccollect.sh index 1e4312f..f21e430 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -192,7 +192,7 @@ while [ "$i" -lt "$no_sources" ]; do # # Get current source # - eval name=\$source_${i} + eval name=\"\$source_${i}\" i=$(($i+1)) export name @@ -269,11 +269,11 @@ while [ "$i" -lt "$no_sources" ]; do if [ -x "$c_pre_exec" ]; then echo "Executing ${c_pre_exec} ..." "$c_pre_exec" - ret=$? + ret="$?" echo "Finished ${c_pre_exec}." - if [ $ret -ne 0 ]; then - echo "$c_pre_exec failed, aborting backup." + if [ "$ret" -ne 0 ]; then + echo "$c_pre_exec failed. Skipping" exit 1 fi fi diff --git a/conf/sources/testsource1/destination b/conf/sources/source with spaces/destination similarity index 100% rename from conf/sources/testsource1/destination rename to conf/sources/source with spaces/destination diff --git a/conf/sources/testsource1/exclude b/conf/sources/source with spaces/exclude similarity index 100% rename from conf/sources/testsource1/exclude rename to conf/sources/source with spaces/exclude diff --git a/conf/sources/testsource1/intervalls/daily b/conf/sources/source with spaces/intervalls/daily similarity index 100% rename from conf/sources/testsource1/intervalls/daily rename to conf/sources/source with spaces/intervalls/daily diff --git a/conf/sources/testsource1/source b/conf/sources/source with spaces/source similarity index 100% rename from conf/sources/testsource1/source rename to conf/sources/source with spaces/source diff --git a/conf/sources/testsource1/verbose b/conf/sources/source with spaces/verbose similarity index 100% rename from conf/sources/testsource1/verbose rename to conf/sources/source with spaces/verbose From e9bcdc72f0117b9af0786a56f90a856161ae0754 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Nov 2006 11:00:13 +0100 Subject: [PATCH 054/581] Clean todo --- TODO | 48 ++++++++---------------------------------------- 1 file changed, 8 insertions(+), 40 deletions(-) diff --git a/TODO b/TODO index b8ab0d9..a813184 100644 --- a/TODO +++ b/TODO @@ -1,43 +1,3 @@ -09:30 < KillerFox> -F bzw. --filter -09:30 < KillerFox> -F dir-merge .backuprules -09:30 < KillerFox> rsync ist ein Optionenmonster -09:31 < KillerFox> telmich: man rsync; / FILTER RULES -09:31 < KillerFox> telmich: es ist nur ein Vorschlag, der noch nett wäre :-). -09:32 < KillerFox> telmich: btw. mir ist noch was aufgefallen. Wenn du nur ein eine - Backupversion behalten willst, könnte man rsync etwas - effizienter nutzen. -09:32 < KillerFox> zur Zeit ist es ja so, dass das alte Verzeichnis gekillt wird - und dann wieder neu gespiegelt -09:32 < KillerFox> aber wenn man nur eine Backupversion besitzt könnte man einfach - rsync drüber laufen lassen. -09:33 < KillerFox> so würde dann nur immer die differenz übertragen. -09:34 < KillerFox> -F'dir-merge,.backuprules', das wäre die korrekte Option. -09:34 < telmich> KillerFox: ah, du meinst im spezialfall, wenn es nur ein - verzeichnis gibt? -09:35 < KillerFox> das würde dann pro Verzeichnis nach .backuprules suchen. -09:35 < KillerFox> telmich: genau. -09:35 < KillerFox> und die Regeln aus .backuprules befolgen. -09:35 < telmich> KillerFox: ich denke, das werde ich erstmal in die tipps mit - aufnehmen, denn man kann es ja via rsync_options aendern -09:35 < KillerFox> telmich: das stimmt. -09:35 < KillerFox> RSYNC_EXTRA -09:36 < KillerFox> die Syntax für .backuprules kann man dann in man rsync; /FILTER - RULES nachlesen. - -09:37 < KillerFox> telmich: okay. -09:37 < KillerFox> telmich: das ist nur ein Vorschlag was mir so aufgefallen ist. -09:38 < KillerFox> telmich: btw. der Vorschlag mit einem Verzeichnis kommt übrigens - von Frank. Ich hatte ihm gestern ccollect für die Spiegelung - seines System empfohlen (da ich wusste, dass rsync für ihn - alleine zu kompliziert ist) -09:38 < KillerFox> telmich: er hat da irgendwie echo '1' > daily gemacht und sich - dann gewundert, wieso er immer alles neu überträgt -09:38 < KillerFox> was bei einer angeschlossenen Platte mit USB 1.1 sehr lange - dauern kann -09:39 < KillerFox> da wäre die differenz Ideal. -09:40 < KillerFox> ich habe nur ccollect mit mehr als einer Version im Einsatz ;-) -09:40 < KillerFox> darum ist mir das nie aufgefallen. -09:40 < KillerFox> aber eigentlich logisch. -------------------------------------------------------------------------------- sven / markierung - wie seht der Marker aus? @@ -49,3 +9,11 @@ Add ccollect-restore.sh (new project, perhaps coordinated with jchome's ccollect-config) -------------------------------------------------------------------------------- clonen von anderen existierenden backups? +-------------------------------------------------------------------------------- +Anhaengen von der -F / --filter Doku von Killerfox +-------------------------------------------------------------------------------- +ccollect Zeitausgabe verbessern + - Wofuer wie lange gebraucht + * rm + * klonen (gibt es so ja nicht) +Wenn Summary angegeben ist am Ende ausgeben From e917546ad194bf11be3c2825909bf472698e9a14 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 17 Jan 2007 09:39:23 +0100 Subject: [PATCH 055/581] introduce old backup matching But this is definitly the WRONG way. We cannot, we need not and we MUST NOT try to catch dumb users. Instead we are the program, we may give the rules. And if we add a fancy feature and the user is too dumb to use it, it is HER/HIS fault. Just to remind my self: Add use of other backup intervals as source for this interval with the following behaviour: - locate all possible intervals in * default configuration * source specific configuration - locate all backups for each interval, record only the timestamp: * taeglich.2007-01-23-0042 -> possible_old_sources += taeglich -> taeglich_last=2007-01-23-0042 - NO READ NEED for this! other method: * sort by time, ALL possible backup: - does posix-ls support this? CHECK! - ( cd $C_SOURCE/destination/; ls --sort-by-time "$interval1".* "$interval2".* | tail -n1 ) - catches all possible intervals - add optional behaviour: * prefer other interval (newer) over this one --- ccollect.sh | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index f21e430..f580d60 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -20,13 +20,33 @@ HALF_VERSION="ccollect $VERSION" FULL_VERSION="ccollect $VERSION ($RELEASE)" # -# Date +# Date + Markup # CDATE: how we use it for naming of the archives # DDATE: how the user should see it in our output +# MDATE: how to match (shell expression) the date # CDATE="date +%Y-%m-%d-%H%M" DDATE="date" +# FIXME: match only numbers! +MDATE="*-*-*-*" +MSUFFIX="${MDATE}.*" +echo $MSUFFIX "$MSUFFIX" +exit 1 + +# +# Fur future releases... +# Date matching: +# +# [1-9][0-9][0-9][0-9] - allow years from 1000 until 9999 - the human race will +# die earlier than this value is reached +# +# - +# [0-1][0-9] ... +# +# + + # # unset parallel execution # @@ -273,7 +293,7 @@ while [ "$i" -lt "$no_sources" ]; do echo "Finished ${c_pre_exec}." if [ "$ret" -ne 0 ]; then - echo "$c_pre_exec failed. Skipping" + echo "$c_pre_exec failed. Skipping." exit 1 fi fi @@ -284,7 +304,7 @@ while [ "$i" -lt "$no_sources" ]; do c_interval="$(cat "$backup/intervals/$INTERVAL" 2>/dev/null)" if [ -z "$c_interval" ]; then - c_interval=$D_INTERVAL + c_interval="$D_INTERVAL" if [ -z "$c_interval" ]; then echo "No definition for interval \"$INTERVAL\" found. Skipping." @@ -301,7 +321,7 @@ while [ "$i" -lt "$no_sources" ]; do else source=$(cat "$c_source") if [ $? -ne 0 ]; then - echo "Skipping: Source $c_source is not readable" + echo "Source $c_source is not readable. Skipping." exit 1 fi fi @@ -355,6 +375,8 @@ while [ "$i" -lt "$no_sources" ]; do # is incomplete or not # # FIXME: test general for incomplete and decide only for warn|delete based on option? + # FIXME: Define which is the last dir before? Or put this thing into + # a while loop? Is it senseful to remove _ALL_ backups if non is complete? if [ -f "$c_incomplete" ]; then last_dir=$(ls -d "$c_dest/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1) From 2db6d79735f6d1f524c91ccf844f39175d017f54 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 17 Jan 2007 09:41:47 +0100 Subject: [PATCH 056/581] Even more todo in the early morning. 6 minutes left until the bus arrives at work. --- TODO | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index a813184..cd404ab 100644 --- a/TODO +++ b/TODO @@ -1,16 +1,28 @@ -------------------------------------------------------------------------------- +1. export more variables for scripts + or check when they are automatically exported +-------------------------------------------------------------------------------- +1.1. +Anhaengen von der -F / --filter Doku von Killerfox +-------------------------------------------------------------------------------- +1.2. replace sed? +compare timing: + _echo () { echo "$name $msg" } + _techo () { echo "$timestamp $name $msg" } +-------------------------------------------------------------------------------- +2. clonen von anderen existierenden backups? +-------------------------------------------------------------------------------- +3. detect unfinished backups sven / markierung - wie seht der Marker aus? -> .ccollect-YEAR-MM-DD.HHmm.pid (like the directory) --> assume incomplete, when we did not finish. --> means it's complete,when rsync was successful -------------------------------------------------------------------------------- -Add ccollect-restore.sh (new project, perhaps coordinated with jchome's -ccollect-config) --------------------------------------------------------------------------------- -clonen von anderen existierenden backups? --------------------------------------------------------------------------------- -Anhaengen von der -F / --filter Doku von Killerfox +4. Add ccollect-restore.sh + (new project, perhaps coordinated with jchome's ccollect-config) + + Who will do that? -------------------------------------------------------------------------------- ccollect Zeitausgabe verbessern - Wofuer wie lange gebraucht From 44c80899fe2312a869cfef76a53faebc6e476e3c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 17 Jan 2007 18:45:13 +0100 Subject: [PATCH 057/581] Cosmetic changase --- TODO | 3 +++ ccollect.sh | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index cd404ab..a11dba9 100644 --- a/TODO +++ b/TODO @@ -8,7 +8,10 @@ Anhaengen von der -F / --filter Doku von Killerfox 1.2. replace sed? compare timing: _echo () { echo "$name $msg" } +and create _techo () { echo "$timestamp $name $msg" } +perhaps create + _eecho () { _techo "ERROR $msg" } -------------------------------------------------------------------------------- 2. clonen von anderen existierenden backups? -------------------------------------------------------------------------------- diff --git a/ccollect.sh b/ccollect.sh index f580d60..92d096f 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -330,7 +330,7 @@ while [ "$i" -lt "$no_sources" ]; do # destination _must_ be a directory # if [ ! -d "$c_dest" ]; then - echo "Destination $c_dest does not link to a directory. Skipping" + echo "Destination $c_dest neither links to nor is a directory. Skipping." exit 1 fi @@ -338,6 +338,8 @@ while [ "$i" -lt "$no_sources" ]; do # exclude list # if [ -f "$c_exclude" ]; then + # FIXME: check how quoting at the end looks like + # perhaps our source contains spaces! EXCLUDE="--exclude-from=$c_exclude" fi @@ -449,6 +451,11 @@ while [ "$i" -lt "$no_sources" ]; do echo "$($DDATE) Transferring files..." ouropts="-a --delete --numeric-ids --relative --delete-excluded" + + # + # FIXME: check, whether this is broken with spaces... + # most likely it should be broken... + # useropts="$VERBOSE $EXCLUDE $SUMMARY $RSYNC_EXTRA" # Clone from previous backup, if existing @@ -458,9 +465,10 @@ while [ "$i" -lt "$no_sources" ]; do # This directory MUST be absolute, because rsync does chdir() # before beginning backup! # + abs_last_dir="$(cd "$last_dir" && pwd -P)" if [ -z "$abs_last_dir" ]; then - echo "Changing to the last backup directory failed. I skip this backup." + echo "Changing to the last backup directory failed. Skipping." exit 1 fi From 07cb3473dbb8dfe32aed69bc04f435e72c328cc8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 17 Jan 2007 19:18:42 +0100 Subject: [PATCH 058/581] More comments --- TODO | 1 + ccollect.sh | 8 +++++++- doc/TODO | 2 -- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index a11dba9..b016b90 100644 --- a/TODO +++ b/TODO @@ -12,6 +12,7 @@ and create _techo () { echo "$timestamp $name $msg" } perhaps create _eecho () { _techo "ERROR $msg" } +? -------------------------------------------------------------------------------- 2. clonen von anderen existierenden backups? -------------------------------------------------------------------------------- diff --git a/ccollect.sh b/ccollect.sh index 92d096f..3fc0772 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -454,10 +454,16 @@ while [ "$i" -lt "$no_sources" ]; do # # FIXME: check, whether this is broken with spaces... - # most likely it should be broken... + # most likely it should be broken...MUST be... + # expanding depens on shell (zsh = 1, dash = 3 arguments in test case) # useropts="$VERBOSE $EXCLUDE $SUMMARY $RSYNC_EXTRA" + # + # FIXME:useropts / rsync extra: one parameter per line! + # 0.5.3! + # + # Clone from previous backup, if existing if [ "$last_dir" ]; then diff --git a/doc/TODO b/doc/TODO index 497a448..6cb1f72 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,5 +1,3 @@ -- ssh / rsync problem - -> ssh noch nie genutzt - add --version, -V - hint: : in path / sed / general problem - hint: backuping backup From 7c53c28c5d97e5d838d94570762ee5b29e622fef Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 17 Jan 2007 19:32:21 +0100 Subject: [PATCH 059/581] Remove experiemental --- ccollect.sh | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 3fc0772..60c647a 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -372,29 +372,29 @@ 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 - # - # FIXME: test general for incomplete and decide only for warn|delete based on option? - # FIXME: Define which is the last dir before? Or put this thing into - # a while loop? Is it senseful to remove _ALL_ backups if non is complete? - 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 ..." - echo rm -rf $VVERBOSE "$last_dir" - fi - fi - fi - +# # +# # show if we shall remove partial backup, and whether the last one +# # is incomplete or not +# # +# # FIXME: test general for incomplete and decide only for warn|delete based on option? +# # FIXME: Define which is the last dir before? Or put this thing into +# # a while loop? Is it senseful to remove _ALL_ backups if non is complete? +# 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 ..." +# echo rm -rf $VVERBOSE "$last_dir" +# fi +# fi +# fi +# # # check if maximum number of backups is reached, if so remove # @@ -409,7 +409,7 @@ while [ "$i" -lt "$no_sources" ]; do remove=$(($count - $substract)) echo "Removing $remove backup(s)..." - ls -d "$c_dest/${INTERVAL}."?* | sort -n | head -n $remove > "$TMP" + ls -d "$c_dest/${INTERVAL}."?* | sort -n | head -n "$remove" > "$TMP" #( cd "$c_dest" && ls -p1 | grep "^${INTERVAL}\..*/\$" | sort -n | head -n $remove > "$TMP" while read to_remove; do dir="$to_remove" @@ -422,6 +422,8 @@ while [ "$i" -lt "$no_sources" ]; do # clone the old directory with hardlinks # + # FIXME: STOPPED + destination_date=$($CDATE) destination_dir="$c_dest/${INTERVAL}.${destination_date}.$$" From d95861c81c70f78562940de05cf6278c58f0be69 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 19 Jan 2007 20:01:53 +0100 Subject: [PATCH 060/581] Add new todos --- ccollect.sh | 3 +++ doc/todo/0.5.2 | 3 +++ doc/todo/0.5.3 | 6 ++++++ doc/todo/0.6 | 9 +++++++++ 4 files changed, 21 insertions(+) create mode 100644 doc/todo/0.5.2 create mode 100644 doc/todo/0.5.3 create mode 100644 doc/todo/0.6 diff --git a/ccollect.sh b/ccollect.sh index 60c647a..e6ff131 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -427,6 +427,9 @@ while [ "$i" -lt "$no_sources" ]; do destination_date=$($CDATE) destination_dir="$c_dest/${INTERVAL}.${destination_date}.$$" + # + # FIXME: + # last_dir=$(ls -d "$c_dest/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1) # give some info diff --git a/doc/todo/0.5.2 b/doc/todo/0.5.2 new file mode 100644 index 0000000..9dc15b6 --- /dev/null +++ b/doc/todo/0.5.2 @@ -0,0 +1,3 @@ +x Fix $? problem +- Check last dir searching +- Check general functionality (remove testing) diff --git a/doc/todo/0.5.3 b/doc/todo/0.5.3 new file mode 100644 index 0000000..2ecfdc6 --- /dev/null +++ b/doc/todo/0.5.3 @@ -0,0 +1,6 @@ +- join todos +- fix possible quoting problems + * rsync_extra (redefine format) + * exclude + * other + * create _rsync, filtering args, creating new $@ diff --git a/doc/todo/0.6 b/doc/todo/0.6 new file mode 100644 index 0000000..4bcdb1b --- /dev/null +++ b/doc/todo/0.6 @@ -0,0 +1,9 @@ +- implement use of different intervals as source for cloning + * use 'woechentlich' if available and no backup exists for 'daily' + * add 'prefer_latest' to prefer different interval, that's newer than + ours + * or add 'prefer_same_interval' instead? +- implement detection of partial backups +- do not check by name, but by time + * is ls -t posix? + * also check: -p -1 From cd21d9c072c67a90beb374c8c131fdf35f0924b9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 19 Jan 2007 20:07:34 +0100 Subject: [PATCH 061/581] Merge todos Cleanup 0.5.2 for release --- TODO | 24 ------------------------ ccollect.sh | 6 +++--- doc/todo/0.5.3 | 2 ++ doc/todo/0.6 | 17 +++++++++++++++++ 4 files changed, 22 insertions(+), 27 deletions(-) diff --git a/TODO b/TODO index b016b90..486e76d 100644 --- a/TODO +++ b/TODO @@ -1,28 +1,4 @@ -------------------------------------------------------------------------------- -1. export more variables for scripts - or check when they are automatically exported --------------------------------------------------------------------------------- -1.1. -Anhaengen von der -F / --filter Doku von Killerfox --------------------------------------------------------------------------------- -1.2. replace sed? -compare timing: - _echo () { echo "$name $msg" } -and create - _techo () { echo "$timestamp $name $msg" } -perhaps create - _eecho () { _techo "ERROR $msg" } -? --------------------------------------------------------------------------------- -2. clonen von anderen existierenden backups? --------------------------------------------------------------------------------- -3. detect unfinished backups -sven / markierung - - wie seht der Marker aus? - -> .ccollect-YEAR-MM-DD.HHmm.pid (like the directory) - --> assume incomplete, when we did not finish. - --> means it's complete,when rsync was successful --------------------------------------------------------------------------------- 4. Add ccollect-restore.sh (new project, perhaps coordinated with jchome's ccollect-config) diff --git a/ccollect.sh b/ccollect.sh index e6ff131..7d85b6d 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -428,7 +428,7 @@ while [ "$i" -lt "$no_sources" ]; do destination_dir="$c_dest/${INTERVAL}.${destination_date}.$$" # - # FIXME: + # FIXME: In 0.6 add search for the latest available backup! # last_dir=$(ls -d "$c_dest/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1) @@ -444,9 +444,9 @@ while [ "$i" -lt "$no_sources" ]; do abs_destination_dir="$(cd "$destination_dir" && pwd -P)" # - # add mark + # FIXME: add mark in 0.6 (and remove if successful later! # - touch "${abs_destination_dir}/${c_marker}" + #touch "${abs_destination_dir}/${c_marker}" # # the rsync part diff --git a/doc/todo/0.5.3 b/doc/todo/0.5.3 index 2ecfdc6..b193f15 100644 --- a/doc/todo/0.5.3 +++ b/doc/todo/0.5.3 @@ -1,3 +1,5 @@ +- check and export variables for use in scripts! +- documentation: -F / --filter for rsync - join todos - fix possible quoting problems * rsync_extra (redefine format) diff --git a/doc/todo/0.6 b/doc/todo/0.6 index 4bcdb1b..0ce1bc2 100644 --- a/doc/todo/0.6 +++ b/doc/todo/0.6 @@ -4,6 +4,23 @@ ours * or add 'prefer_same_interval' instead? - implement detection of partial backups +3. detect unfinished backups +sven / markierung + - wie seht der Marker aus? + -> .ccollect-YEAR-MM-DD.HHmm.pid (like the directory) + --> assume incomplete, when we did not finish. + --> means it's complete,when rsync was successful +---> partial implemented in 0.5.2 (commented out) - do not check by name, but by time * is ls -t posix? * also check: -p -1 +- do sed-time check: +1.2. replace sed? +compare timing: +_echo () { echo "$name $msg" } +and create +_techo () { echo "$timestamp $name $msg" } +perhaps create +_eecho () { _techo "ERROR $msg" } +? + From 6e24829a68666b01ff96e176232b1c5fa003f4bb Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 19 Jan 2007 20:10:26 +0100 Subject: [PATCH 062/581] External todos --- doc/todo/extern | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 doc/todo/extern diff --git a/doc/todo/extern b/doc/todo/extern new file mode 100644 index 0000000..c8f97d0 --- /dev/null +++ b/doc/todo/extern @@ -0,0 +1,15 @@ +These todos are things that would be senseful todo, but are just nice +to have. This means I won't code them, so somebody can code them. +-------------------------------------------------------------------------------- + +- Add ccollect-restore.sh + (new project, perhaps coordinated with jchome's ccollect-config) + + Helper (in dialog?) to restore backups + + Perhaps create ccollect-gui.{whatever} instead, which does all the + end user staff? + + Including cronjob, creating configuration, displaying status of + backups, allowing manual remove, allowing manual trigger of ccollect + (with realtime message window?)? From ed452354cdc97b46a81c919a55f4a9820fd2c964 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 19 Jan 2007 20:11:29 +0100 Subject: [PATCH 063/581] Merged todos --- TODO | 11 ----------- doc/todo/0.5.3 | 2 +- doc/todo/0.6 | 7 +++++++ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index 486e76d..e69de29 100644 --- a/TODO +++ b/TODO @@ -1,11 +0,0 @@ --------------------------------------------------------------------------------- -4. Add ccollect-restore.sh - (new project, perhaps coordinated with jchome's ccollect-config) - - Who will do that? --------------------------------------------------------------------------------- -ccollect Zeitausgabe verbessern - - Wofuer wie lange gebraucht - * rm - * klonen (gibt es so ja nicht) -Wenn Summary angegeben ist am Ende ausgeben diff --git a/doc/todo/0.5.3 b/doc/todo/0.5.3 index b193f15..28f7cae 100644 --- a/doc/todo/0.5.3 +++ b/doc/todo/0.5.3 @@ -1,6 +1,6 @@ - check and export variables for use in scripts! - documentation: -F / --filter for rsync -- join todos +X join todos - fix possible quoting problems * rsync_extra (redefine format) * exclude diff --git a/doc/todo/0.6 b/doc/todo/0.6 index 0ce1bc2..5ba888f 100644 --- a/doc/todo/0.6 +++ b/doc/todo/0.6 @@ -15,6 +15,7 @@ sven / markierung * is ls -t posix? * also check: -p -1 - do sed-time check: + 1.2. replace sed? compare timing: _echo () { echo "$name $msg" } @@ -24,3 +25,9 @@ perhaps create _eecho () { _techo "ERROR $msg" } ? +- ccollect Zeitausgabe verbessern + - Wofuer wie lange gebraucht + * rm + * klonen (gibt es so ja nicht) + Wenn Summary angegeben ist am Ende ausgeben + From 1bd9e89689d077b33295def3d1f684e0e46c6b94 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 19 Jan 2007 20:11:40 +0100 Subject: [PATCH 064/581] Remove old TODO --- TODO | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 TODO diff --git a/TODO b/TODO deleted file mode 100644 index e69de29..0000000 From 30f9344cf88ac9a9b9e236b1d3b12f38443e667a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 19 Jan 2007 20:15:51 +0100 Subject: [PATCH 065/581] Narf, even more todo found. --- doc/TODO | 15 --------------- doc/todo/0.6 | 11 +++++++++++ doc/todo/extern | 8 ++++++++ 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/doc/TODO b/doc/TODO index 6cb1f72..e69de29 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,15 +0,0 @@ -- add --version, -V -- hint: : in path / sed / general problem -- hint: backuping backup -- do we want rsync -H by default? - -- update documentation: - - german doc? - - exit pre/post exec -> error codes (after implementation!) (in 0.4) - - write about fast changing fs -- write mkccollectconfig (for 0.5!) - o create source configuration - o another script for changing defaults - x intervalls - x pre-/post exec - o (X)dialog based diff --git a/doc/todo/0.6 b/doc/todo/0.6 index 5ba888f..4732ab6 100644 --- a/doc/todo/0.6 +++ b/doc/todo/0.6 @@ -30,4 +30,15 @@ _eecho () { _techo "ERROR $msg" } * rm * klonen (gibt es so ja nicht) Wenn Summary angegeben ist am Ende ausgeben +- add --version, -V +- do we want rsync -H by default? + + +Documentation: +- hint: backuping backup +- update documentation: + - german doc? + - exit pre/post exec -> error codes (after implementation!) (in 0.4) + - write about fast changing fs + diff --git a/doc/todo/extern b/doc/todo/extern index c8f97d0..9be8f2b 100644 --- a/doc/todo/extern +++ b/doc/todo/extern @@ -13,3 +13,11 @@ to have. This means I won't code them, so somebody can code them. Including cronjob, creating configuration, displaying status of backups, allowing manual remove, allowing manual trigger of ccollect (with realtime message window?)? + +- write mkccollectconfig (for 0.5!) + -> jchome works on it! + o create source configuration + o another script for changing defaults + x intervalls + x pre-/post exec + o (X)dialog based From b662b3245737ff40e7314b35cd4da20b7b0e3ebd Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 19 Jan 2007 20:16:09 +0100 Subject: [PATCH 066/581] Erase everyting todo --- doc/TODO | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 doc/TODO diff --git a/doc/TODO b/doc/TODO deleted file mode 100644 index e69de29..0000000 From 775a7e89a9a2071294834fb9e13577de9896860f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 20 Jan 2007 16:22:36 +0100 Subject: [PATCH 067/581] Remove testing --- ccollect.sh | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 7d85b6d..74154a0 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -28,25 +28,6 @@ FULL_VERSION="ccollect $VERSION ($RELEASE)" CDATE="date +%Y-%m-%d-%H%M" DDATE="date" -# FIXME: match only numbers! -MDATE="*-*-*-*" -MSUFFIX="${MDATE}.*" -echo $MSUFFIX "$MSUFFIX" -exit 1 - -# -# Fur future releases... -# Date matching: -# -# [1-9][0-9][0-9][0-9] - allow years from 1000 until 9999 - the human race will -# die earlier than this value is reached -# -# - -# [0-1][0-9] ... -# -# - - # # unset parallel execution # From 5d1e7f1efb7a5d0c835d1669c0d6dec2d7b071d3 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 20 Jan 2007 16:24:20 +0100 Subject: [PATCH 068/581] Ignore tests --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d1a77cc..8067652 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ doc/*.texi doc/man/*.html doc/man/*.texi doc/man/*.man +test/* From 19d84f65daffb75c847b87fed3a06e01aac327ca Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 20 Jan 2007 16:41:38 +0100 Subject: [PATCH 069/581] Add _exit_err --- ccollect.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 74154a0..d5d8467 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -40,6 +40,16 @@ PARALLEL="" trap "rm -f \"$TMP\"" 1 2 15 +# +# Functions +# + +_exit_err() +{ + echo "$@" + exit 1 +} + add_name() { sed "s:^:\[$name\] :" @@ -227,8 +237,11 @@ while [ "$i" -lt "$no_sources" ]; do c_rsync_extra="$backup/rsync_options" c_summary="$backup/summary" - c_incomplete="$backup/incomplete_remove" - c_marker=".ccollect-${CDATE}.$$" + # + # FIXME: enable in 0.6 + # + #c_incomplete="$backup/incomplete_remove" + #c_marker=".ccollect-${CDATE}.$$" c_pre_exec="$backup/pre_exec" c_post_exec="$backup/post_exec" From 9ec054053f8a05b0c6b73eaf31c5e096abd55832 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 20 Jan 2007 16:41:53 +0100 Subject: [PATCH 070/581] Todo / Changes --- doc/CHANGES | 2 ++ doc/todo/0.5.2 | 1 + 2 files changed, 3 insertions(+) diff --git a/doc/CHANGES b/doc/CHANGES index 93a51fa..e163708 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,5 +1,7 @@ 0.5.1 to 0.5.2: * Display correct error code, if rsync returns non-zero + * Unify messages + * Remove some potential quoting problems 0.5 to 0.5.1: * Remove always printed debug information diff --git a/doc/todo/0.5.2 b/doc/todo/0.5.2 index 9dc15b6..1d57bd2 100644 --- a/doc/todo/0.5.2 +++ b/doc/todo/0.5.2 @@ -1,3 +1,4 @@ x Fix $? problem - Check last dir searching +- Check count generation - Check general functionality (remove testing) From afbab564960625e9efd45f9c9076c22a248799f5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 27 Jan 2007 18:27:27 +0100 Subject: [PATCH 071/581] introduce _exit_err --- ccollect.sh | 21 +++++++++------------ doc/todo/0.5.3 | 3 +++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index d5d8467..fec5d00 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -15,15 +15,13 @@ CPOSTEXEC="$CDEFAULTS/post_exec" TMP=$(mktemp /tmp/$(basename $0).XXXXXX) VERSION=0.5.2 -RELEASE="2006-XXXXX" +RELEASE="2007-01-21" HALF_VERSION="ccollect $VERSION" FULL_VERSION="ccollect $VERSION ($RELEASE)" # -# Date + Markup # CDATE: how we use it for naming of the archives # DDATE: how the user should see it in our output -# MDATE: how to match (shell expression) the date # CDATE="date +%Y-%m-%d-%H%M" DDATE="date" @@ -33,13 +31,11 @@ DDATE="date" # PARALLEL="" - # # catch signals # trap "rm -f \"$TMP\"" 1 2 15 - # # Functions # @@ -47,6 +43,7 @@ trap "rm -f \"$TMP\"" 1 2 15 _exit_err() { echo "$@" + rm -f "$TMP" exit 1 } @@ -84,13 +81,10 @@ if [ $# -lt 2 ]; then fi # -# check for configuraton directory +# check for configuraton directory, FIXME: _exit_err # -if [ ! -d "$CCOLLECT_CONF" ]; then - echo "No configuration found in \"$CCOLLECT_CONF\"" \ - " (is \$CCOLLECT_CONF properly set?)" - exit 1 -fi +[ -d "$CCOLLECT_CONF" ] || _exit_err "No configuration found in " \ + "\"$CCOLLECT_CONF\" (is \$CCOLLECT_CONF properly set?)" # # Filter arguments @@ -148,6 +142,7 @@ if [ -x "$CPREEXEC" ]; then ret=$? echo "Finished ${CPREEXEC}." + # FIXME: _exit_err if [ $ret -ne 0 ]; then echo "$CPREEXEC failed, not starting backup." exit 1 @@ -167,6 +162,7 @@ if [ "$ALL" = 1 ]; then cwd=$(pwd -P) ( cd "$CSOURCES" && ls > "$TMP" ) + # FIXME: _exit_err if [ "$?" -ne 0 ]; then echo "Listing of sources failed. Aborting." exit 1 @@ -430,7 +426,8 @@ while [ "$i" -lt "$no_sources" ]; do echo "Beginning to backup, this may take some time..." echo "Creating $destination_dir ..." - mkdir $VVERBOSE "$destination_dir" || exit 1 + mkdir $VVERBOSE "$destination_dir" || \ + _exit_err "Creating $destination_dir failed. Skipping." # # make an absolute path, perhaps $CCOLLECT_CONF is relative! diff --git a/doc/todo/0.5.3 b/doc/todo/0.5.3 index 28f7cae..c843cdf 100644 --- a/doc/todo/0.5.3 +++ b/doc/todo/0.5.3 @@ -6,3 +6,6 @@ X join todos * exclude * other * create _rsync, filtering args, creating new $@ +- remove exit-calls + * will leave behind unused temporary file! + * use _exit_err From 9bc8d266f2f816fb84ef8e7ce2c4899b41bd10fa Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 27 Jan 2007 18:28:57 +0100 Subject: [PATCH 072/581] Minor docu update --- doc/ccollect.text | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 1999e65..5c31677 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ -Nico Schottelius -0.5, for ccollect 0.4-0.5.1, Initial Version from 2006-01-13 +Nico Schottelius +0.5, for ccollect 0.4-0.5.2, Initial Version from 2006-01-13 :Author Initials: NS (pseudo) incremental backup From 21956a33628d16e042c057dbb348b692d0d8d880 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 27 Jan 2007 18:55:56 +0100 Subject: [PATCH 073/581] Add test script number one. --- test/test-ccollect1.sh | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 test/test-ccollect1.sh diff --git a/test/test-ccollect1.sh b/test/test-ccollect1.sh new file mode 100755 index 0000000..c5acf54 --- /dev/null +++ b/test/test-ccollect1.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# +# Nico Schottelius +# Date: 27-Jan-2007 +# Last Modified: - +# Description: +# + +ccollect=../ccollect.sh +testdir="$(dirname $0)/test-backups" +confdir="$(dirname $0)/test-config" +source="$(hostname)" +source_source="/tmp" +interval="taeglich" + + +# backup destination +mkdir -p "$testdir" +source_dest="$(cd "$testdir"; pwd -P)" + +# configuration +mkdir -p "${confdir}/sources/${source}" +ln -s "$source_dest" "${confdir}/sources/${source}/destination" +echo "$source_source" > "${confdir}/sources/${source}/source" +touch "${confdir}/sources/${source}/summary" +touch "${confdir}/sources/${source}/verbose" + +mkdir -p "${confdir}/defaults/intervals/" +echo 3 > "${confdir}/defaults/intervals/$interval" + +# create backups + +CCOLLECT_CONF="$confdir" "$ccollect" "$interval" -p -a +touch "${source_source}/$(date +%s)-$$.1982" + +CCOLLECT_CONF="$confdir" "$ccollect" "$interval" -p -a +touch "${source_source}/$(date +%s)-$$.42" + +CCOLLECT_CONF="$confdir" "$ccollect" "$interval" -p -a + +du -sh "$testdir" +du -shl "$testdir" + +echo "Delete $testdir and $confdir after test" From 17fde8943d22440315dbfd8e1d53f3ca2bc12ff8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 27 Jan 2007 18:56:29 +0100 Subject: [PATCH 074/581] Release today --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index fec5d00..d8a3e0e 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -15,7 +15,7 @@ CPOSTEXEC="$CDEFAULTS/post_exec" TMP=$(mktemp /tmp/$(basename $0).XXXXXX) VERSION=0.5.2 -RELEASE="2007-01-21" +RELEASE="2007-01-27" HALF_VERSION="ccollect $VERSION" FULL_VERSION="ccollect $VERSION ($RELEASE)" From 7f204fda819009abf5ccec31725c767d249f250e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 27 Jan 2007 18:56:57 +0100 Subject: [PATCH 075/581] Seems to work --- doc/todo/0.5.2 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/todo/0.5.2 b/doc/todo/0.5.2 index 1d57bd2..0c1c225 100644 --- a/doc/todo/0.5.2 +++ b/doc/todo/0.5.2 @@ -1,4 +1,4 @@ x Fix $? problem -- Check last dir searching -- Check count generation -- Check general functionality (remove testing) +x Check last dir searching +x Check count generation +x Check general functionality (remove testing) From 3de1482bf3b625f2c08ffefbe6bb93e13f81bf7e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 27 Jan 2007 18:58:53 +0100 Subject: [PATCH 076/581] Ignore .htm in mandir --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8067652..c9c33f0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ doc/*.htm doc/*.docbook doc/*.texi doc/man/*.html +doc/man/*.htm doc/man/*.texi doc/man/*.man test/* From 6ca7848cf7fdd7c38435558838c5e5514cc8659d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 27 Jan 2007 19:19:11 +0100 Subject: [PATCH 077/581] More todo --- Makefile | 2 +- doc/todo/0.5.3 | 2 ++ release.sh | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6b48063..0b50e4e 100644 --- a/Makefile +++ b/Makefile @@ -113,7 +113,7 @@ publish-doc: documentation allclean: rm -f $(DOC_ALL) -distclean: +distclean: allclean rm -f $(DOCBDOCS) # diff --git a/doc/todo/0.5.3 b/doc/todo/0.5.3 index c843cdf..8d4fad7 100644 --- a/doc/todo/0.5.3 +++ b/doc/todo/0.5.3 @@ -9,3 +9,5 @@ X join todos - remove exit-calls * will leave behind unused temporary file! * use _exit_err +- replace nico-linux-ccollect with nico-ccollect + * ccollect is not Linux specific diff --git a/release.sh b/release.sh index d93f1f9..7a758bb 100755 --- a/release.sh +++ b/release.sh @@ -18,6 +18,13 @@ DHOST=nico@home.schottelius.org DDIR=www/org/schottelius/unix/www/ccollect/ DESTINATION="$DHOST:$DDIR" +# create documentation for the end user +( + cd "$NAME" + make dist + make publish-doc +) + tar cvfj "$TARNAME" \ --exclude=.git \ --exclude="conf/sources/*/destination/*" "$NAME" @@ -29,3 +36,5 @@ ssh "$DHOST" "( cd $DDIR; tar xfj \"$TARNAME\" )" echo "setting paranoid permissions to public..." ssh "$DHOST" "( cd $DDIR; find -type d -exec chmod 0755 {} \; )" ssh "$DHOST" "( cd $DDIR; find -type f -exec chmod 0644 {} \; )" + +cat "${NAME}/doc/release-checklist" From e2706e640317d96b6b346fb68c14a298d20ad230 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 25 Feb 2007 18:29:33 +0100 Subject: [PATCH 078/581] Add tested platforms --- doc/ccollect.text | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 5c31677..9250748 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,13 +1,14 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -0.5, for ccollect 0.4-0.5.2, Initial Version from 2006-01-13 +0.5, for ccollect 0.4-0.5.3, Initial Version from 2006-01-13 :Author Initials: NS (pseudo) incremental backup with different exclude lists using hardlinks and `rsync` + Introduction ------------ ccollect is a backup utility written in the sh-scripting language. @@ -15,6 +16,16 @@ It does not depend on a specific shell, only `/bin/sh` needs to be bourne shell compatible (like 'dash', 'ksh', 'zsh', 'bash', ...). +Supported and tested operating systems and architectures +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +ccollect was successfully tested on the following platforms: + +- OpenBSD on amd64 +- GNU/Linux on hppa/i386/amd64 + +It *should* run on any Unix that supports rsync and has a POSIX-compatible +bourne shell. + Why you can only backup from remote hosts, not to them ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ While considering the design of ccollect, I thought about enabling @@ -88,7 +99,7 @@ For those who do not want to read the whole long document: -------------------------------------------------------------------------------- # get latest ccollect tarball from http://unix.schottelius.org/ccollect/ # replace value for CCV with the current version -export CCV=0.5.1 +export CCV=0.5.2 # # replace 'wget' with fetch on bsd From f1d1d2b04845ce6cd52de5b9b51deec535afaab1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 25 Feb 2007 18:31:47 +0100 Subject: [PATCH 079/581] notify on unlisted platforms --- doc/ccollect.text | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 9250748..1962e32 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -24,7 +24,8 @@ ccollect was successfully tested on the following platforms: - GNU/Linux on hppa/i386/amd64 It *should* run on any Unix that supports rsync and has a POSIX-compatible -bourne shell. +bourne shell. If your platform is not listed above and you have it successfully +running, please drop me a mail. Why you can only backup from remote hosts, not to them ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 26d61c8c2c6a341d6c128bb0c5215c0e729cc593 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 13 Mar 2007 08:22:47 +0100 Subject: [PATCH 080/581] Cosmetic changes (I) --- doc/CHANGES | 3 +++ doc/todo/0.5.3 | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/CHANGES b/doc/CHANGES index e163708..d4dfe1b 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,6 @@ +0.5.2 to 0.5.3: + * add 'exec-after-rm' (source specific) configuration + 0.5.1 to 0.5.2: * Display correct error code, if rsync returns non-zero * Unify messages diff --git a/doc/todo/0.5.3 b/doc/todo/0.5.3 index 8d4fad7..411904d 100644 --- a/doc/todo/0.5.3 +++ b/doc/todo/0.5.3 @@ -1,5 +1,7 @@ - check and export variables for use in scripts! -- documentation: -F / --filter for rsync +- documentation + * -F / --filter for rsync + * integrate updated german documentation X join todos - fix possible quoting problems * rsync_extra (redefine format) @@ -11,3 +13,7 @@ X join todos * use _exit_err - replace nico-linux-ccollect with nico-ccollect * ccollect is not Linux specific +- beep-after-delete-hack? + -> tonnerre / #cLinux + +Done: From c291d4a8f5e71e3da796e2afb1c9923cd8a3dc97 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 13 Mar 2007 08:31:50 +0100 Subject: [PATCH 081/581] Cosmetic changes (II) plus integration of _exit_err --- ccollect.sh | 77 ++++++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 42 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index d8a3e0e..675ea4d 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -14,8 +14,8 @@ CPREEXEC="$CDEFAULTS/pre_exec" CPOSTEXEC="$CDEFAULTS/post_exec" TMP=$(mktemp /tmp/$(basename $0).XXXXXX) -VERSION=0.5.2 -RELEASE="2007-01-27" +VERSION=0.5.3 +RELEASE="2007-XX-XX" HALF_VERSION="ccollect $VERSION" FULL_VERSION="ccollect $VERSION ($RELEASE)" @@ -63,10 +63,10 @@ usage() echo "" echo " -h, --help: Show this help screen" echo " -p, --parallel: Parallelise backup processes" - echo " -a, --all: Backup all sources specified in $CSOURCES" + echo " -a, --all: Backup all sources specified in ${CSOURCES}" echo " -v, --verbose: Be very verbose (uses set -x)." echo "" - echo " This is version $VERSION, released on ${RELEASE}" + echo " This is version ${VERSION}, released on ${RELEASE}" echo " (the first version was written on 2005-12-05 by Nico Schottelius)." echo "" echo " Retrieve latest ccollect at http://unix.schottelius.org/ccollect/" @@ -81,26 +81,26 @@ if [ $# -lt 2 ]; then fi # -# check for configuraton directory, FIXME: _exit_err +# check for configuraton directory # -[ -d "$CCOLLECT_CONF" ] || _exit_err "No configuration found in " \ +[ -d "${CCOLLECT_CONF}" ] || _exit_err "No configuration found in " \ "\"$CCOLLECT_CONF\" (is \$CCOLLECT_CONF properly set?)" # # Filter arguments # -INTERVAL=$1; shift +INTERVAL="$1"; shift i=1 no_sources=0 -while [ $i -le $# ]; do - eval arg=\$$i +while [ "$i" -le $# ]; do + eval arg=\"\$$i\" if [ "$NO_MORE_ARGS" = 1 ]; then eval source_${no_sources}=\"$arg\" no_sources=$(($no_sources+1)) else - case $arg in + case "$arg" in -a|--all) ALL=1 ;; @@ -136,17 +136,12 @@ fi # # Look for pre-exec command (general) # -if [ -x "$CPREEXEC" ]; then - echo "Executing $CPREEXEC ..." - "$CPREEXEC" - ret=$? +if [ -x "${CPREEXEC}" ]; then + echo "Executing ${CPREEXEC} ..." + "${CPREEXEC}"; ret=$? echo "Finished ${CPREEXEC}." - # FIXME: _exit_err - if [ $ret -ne 0 ]; then - echo "$CPREEXEC failed, not starting backup." - exit 1 - fi + [ "${ret}" -eq 0 ] || _exit_err "${CPREEXEC} failed, not starting backup." fi # @@ -160,18 +155,14 @@ if [ "$ALL" = 1 ]; then # get entries from sources # cwd=$(pwd -P) - ( cd "$CSOURCES" && ls > "$TMP" ) + ( cd "${CSOURCES}" && ls > "${TMP}" ) - # FIXME: _exit_err - if [ "$?" -ne 0 ]; then - echo "Listing of sources failed. Aborting." - exit 1 - fi + [ "$?" -eq 0 ] || _exit_err "Listing of sources failed. Aborting." while read tmp; do eval source_${no_sources}=\"$tmp\" no_sources=$(($no_sources+1)) - done < "$TMP" + done < "${TMP}" fi # @@ -187,8 +178,8 @@ fi # check default configuration # -D_FILE_INTERVAL="$CDEFAULTS/intervals/$INTERVAL" -D_INTERVAL=$(cat "$D_FILE_INTERVAL" 2>/dev/null) +D_FILE_INTERVAL="${CDEFAULTS}/intervals/${INTERVAL}" +D_INTERVAL=$(cat "${D_FILE_INTERVAL}" 2>/dev/null) # # Let's do the backup @@ -207,8 +198,8 @@ while [ "$i" -lt "$no_sources" ]; do # # start ourself, if we want parallel execution # - if [ "$PARALLEL" ]; then - "$0" "$INTERVAL" "$name" & + if [ "${PARALLEL}" ]; then + "$0" "${INTERVAL}" "${name}" & continue fi @@ -224,24 +215,26 @@ while [ "$i" -lt "$no_sources" ]; do # # Standard locations # - backup="$CSOURCES/$name" - c_source="$backup/source" - c_dest="$backup/destination" - c_exclude="$backup/exclude" - c_verbose="$backup/verbose" - c_vverbose="$backup/very_verbose" - c_rsync_extra="$backup/rsync_options" - c_summary="$backup/summary" + backup="${CSOURCES}/${name}" + c_source="${backup}/source" + c_dest="${backup}/destination" + c_exclude="${backup}/exclude" + c_verbose="${backup}/verbose" + c_vverbose="${backup}/very_verbose" + c_rsync_extra="${backup}/rsync_options" + c_summary="${backup}/summary" + c_pre_exec="${backup}/pre_exec" + c_post_exec="${backup}/post_exec" + # # FIXME: enable in 0.6 + # Always execute, warn if it exists in normal case + # and rm -rf the old backup, if "delete_incomplete" is set # - #c_incomplete="$backup/incomplete_remove" + c_incomplete="$backup/delete_incomplete" #c_marker=".ccollect-${CDATE}.$$" - c_pre_exec="$backup/pre_exec" - c_post_exec="$backup/post_exec" - begin=$($DDATE) begin_s=$(date +%s) From 7678d4fb3f38a02b1094ae8db51dc25ad197ebfe Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 13 Mar 2007 08:41:51 +0100 Subject: [PATCH 082/581] Use small directory available everywhere for testing --- conf/sources/with_exec/source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/sources/with_exec/source b/conf/sources/with_exec/source index c76e288..5e56e04 100644 --- a/conf/sources/with_exec/source +++ b/conf/sources/with_exec/source @@ -1 +1 @@ -/home/user/nico/oeffentlich/computer/projekte/ccollect-0.3/ +/bin From c3312ea54d08354dc8f330b0406eeb6dd56fcaa0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 13 Mar 2007 08:47:04 +0100 Subject: [PATCH 083/581] Cosmetic changes (III) --- ccollect.sh | 66 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 675ea4d..bafab29 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -64,7 +64,7 @@ usage() echo " -h, --help: Show this help screen" echo " -p, --parallel: Parallelise backup processes" echo " -a, --all: Backup all sources specified in ${CSOURCES}" - echo " -v, --verbose: Be very verbose (uses set -x)." + echo " -v, --verbose: Be very verbose (uses set -x)" echo "" echo " This is version ${VERSION}, released on ${RELEASE}" echo " (the first version was written on 2005-12-05 by Nico Schottelius)." @@ -247,12 +247,12 @@ while [ "$i" -lt "$no_sources" ]; do VERBOSE="" VVERBOSE="" - echo "$begin Beginning to backup" + echo "${begin} Beginning to backup" # # Standard configuration checks # - if [ ! -e "$backup" ]; then + if [ ! -e "${backup}" ]; then echo "Source does not exist." exit 1 fi @@ -260,8 +260,8 @@ while [ "$i" -lt "$no_sources" ]; do # # configuration _must_ be a directory # - if [ ! -d "$backup" ]; then - echo "\"$name\" is not a cconfig-directory. Skipping." + if [ ! -d "${backup}" ]; then + echo "\"${name}\" is not a cconfig-directory. Skipping." exit 1 fi @@ -269,14 +269,14 @@ while [ "$i" -lt "$no_sources" ]; do # first execute pre_exec, which may generate destination or other # parameters # - if [ -x "$c_pre_exec" ]; then + if [ -x "${c_pre_exec}" ]; then echo "Executing ${c_pre_exec} ..." - "$c_pre_exec" - ret="$?" + "${c_pre_exec}"; ret="$?" echo "Finished ${c_pre_exec}." - if [ "$ret" -ne 0 ]; then - echo "$c_pre_exec failed. Skipping." + # FIXME: is _exit_err senseful here? + if [ "${ret}" -ne 0 ]; then + echo "${c_pre_exec} failed. Skipping." exit 1 fi fi @@ -284,13 +284,14 @@ while [ "$i" -lt "$no_sources" ]; do # # interval definition: First try source specific, fallback to default # - c_interval="$(cat "$backup/intervals/$INTERVAL" 2>/dev/null)" + c_interval="$(cat "${backup}/intervals/${INTERVAL}" 2>/dev/null)" - if [ -z "$c_interval" ]; then - c_interval="$D_INTERVAL" + if [ -z "${c_interval}" ]; then + c_interval="${D_INTERVAL}" - if [ -z "$c_interval" ]; then - echo "No definition for interval \"$INTERVAL\" found. Skipping." + # FIXME: is _exit_err senseful here? + if [ -z "${c_interval}" ]; then + echo "No definition for interval \"${INTERVAL}\" found. Skipping." exit 1 fi fi @@ -298,8 +299,9 @@ while [ "$i" -lt "$no_sources" ]; do # # Source checks # - if [ ! -f "$c_source" ]; then - echo "Source description $c_source is not a file. Skipping." + # FIXME: is _exit_err senseful here? + if [ ! -f "${c_source}" ]; then + echo "Source description ${c_source} is not a file. Skipping." exit 1 else source=$(cat "$c_source") @@ -312,8 +314,8 @@ while [ "$i" -lt "$no_sources" ]; do # # destination _must_ be a directory # - if [ ! -d "$c_dest" ]; then - echo "Destination $c_dest neither links to nor is a directory. Skipping." + if [ ! -d "${c_dest}" ]; then + echo "Destination ${c_dest} neither links to nor is a directory. Skipping." exit 1 fi @@ -329,28 +331,28 @@ while [ "$i" -lt "$no_sources" ]; do # # extra options for rsync # - if [ -f "$c_rsync_extra" ]; then - RSYNC_EXTRA="$(cat "$c_rsync_extra")" + if [ -f "${c_rsync_extra}" ]; then + RSYNC_EXTRA="$(cat "${c_rsync_extra}")" fi # # Output a summary # - if [ -f "$c_summary" ]; then + if [ -f "${c_summary}" ]; then SUMMARY="--stats" fi # # Verbosity for rsync # - if [ -f "$c_verbose" ]; then + if [ -f "${c_verbose}" ]; then VERBOSE="-v" fi # # MORE verbosity, includes standard verbosity # - if [ -f "$c_vverbose" ]; then + if [ -f "${c_vverbose}" ]; then VERBOSE="-v" VVERBOSE="-v" fi @@ -363,6 +365,7 @@ while [ "$i" -lt "$no_sources" ]; do # # FIXME: Define which is the last dir before? Or put this thing into # # a while loop? Is it senseful to remove _ALL_ backups if non is complete? # if [ -f "$c_incomplete" ]; then +# echo "Searching for incomplete backups..." # last_dir=$(ls -d "$c_dest/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1) # # # check whether the last backup was incomplete @@ -382,12 +385,17 @@ while [ "$i" -lt "$no_sources" ]; do # check if maximum number of backups is reached, if so remove # + # FIXME: really do fuzzy matching here? + # or simply declare "everything of that directory (which is a directory) is + # a ccollect-backiup directory"? # the created directories are named $INTERVAL-$DATE-$TIME.$PID - count=$(cd "$c_dest" && ls -p1 | grep "^${INTERVAL}\..*/\$" | wc -l | sed 's/^ *//g') - echo -n "Currently $count backup(s) exist(s)," - echo " total keeping $c_interval backup(s)." - - if [ "$count" -ge "$c_interval" ]; then + count=$(cd "${c_dest}" && ls -p1 | grep "^${INTERVAL}\..*/\$" | wc -l | sed 's/^ *//g') + # FIXME: check return value + echo -n "Currently ${count} backup(s) exist(s)," + echo " total keeping ${c_interval} backup(s)." + + # STOPPED! + if [ "${count}" -ge "${c_interval}" ]; then substract=$((${c_interval} - 1)) remove=$(($count - $substract)) echo "Removing $remove backup(s)..." From 13b47585a83652343c7acae65c20c7226bbb1374 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 31 May 2007 11:52:33 +0200 Subject: [PATCH 084/581] export interval --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index bafab29..3cbce84 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -89,7 +89,7 @@ fi # # Filter arguments # -INTERVAL="$1"; shift +export INTERVAL="$1"; shift i=1 no_sources=0 From 1d68408541f6e716c9f9fd4a5a6a073a3914f61f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 31 May 2007 11:55:37 +0200 Subject: [PATCH 085/581] export number of sources --- ccollect.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ccollect.sh b/ccollect.sh index 3cbce84..367006c 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -99,6 +99,9 @@ while [ "$i" -le $# ]; do if [ "$NO_MORE_ARGS" = 1 ]; then eval source_${no_sources}=\"$arg\" no_sources=$(($no_sources+1)) + + # make variable available for subscripts + eval export source_${no_sources} else case "$arg" in -a|--all) @@ -126,6 +129,9 @@ while [ "$i" -le $# ]; do i=$(($i+1)) done +# also export number of sources +export no_sources + # # be really, really, really verbose # From ca8918d2c0adf3fa80dab214ad0fe68cc17b8172 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 8 Jun 2007 10:42:18 +0200 Subject: [PATCH 086/581] Add initial logwrapper documentation --- doc/logwrapper.text | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 doc/logwrapper.text diff --git a/doc/logwrapper.text b/doc/logwrapper.text new file mode 100644 index 0000000..1ddae01 --- /dev/null +++ b/doc/logwrapper.text @@ -0,0 +1,23 @@ +ccollect-logwrapper: Logging backup output +=========================================== +Nico Schottelius +0.1, for ccollect-logwrapper 0.1, Initial Version from 2007-06-08 +:Author Initials: NS + +This wrapper makes it easy to have logs of ccollect output. + + +Introduction +------------ +/etc/ccollect/logwrapper/ (also uses $CCOLLECT_CONF). + + + pipe + staticfile: link to a file + datefile: + contains a string that is passed to date that returns + dynamicfile: + is a program, that returns some string that we + +The logger will output to which destinations it logs and with which +parameters it was started. From 10870c4ce1006b5143e3adeeda89a2e9228d9d14 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 22 Jun 2007 11:08:48 +0200 Subject: [PATCH 087/581] More doc on logwrapper --- doc/CHANGES | 1 + doc/logwrapper.text | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/CHANGES b/doc/CHANGES index d4dfe1b..fcfef5e 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,5 +1,6 @@ 0.5.2 to 0.5.3: * add 'exec-after-rm' (source specific) configuration + * added logwrapper 0.5.1 to 0.5.2: * Display correct error code, if rsync returns non-zero diff --git a/doc/logwrapper.text b/doc/logwrapper.text index 1ddae01..ec12db4 100644 --- a/doc/logwrapper.text +++ b/doc/logwrapper.text @@ -12,12 +12,18 @@ Introduction /etc/ccollect/logwrapper/ (also uses $CCOLLECT_CONF). - pipe + pipe: will pipe to a program staticfile: link to a file datefile: contains a string that is passed to date that returns dynamicfile: - is a program, that returns some string that we + is a program, that returns some string that we use as + a filename + syslog: + syslog-facility + syslog-level + only-stderr: + omit stdout output The logger will output to which destinations it logs and with which parameters it was started. From 242d3e62b9a2ab22a9fd71f7e645e9e3330c1658 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 22 Jun 2007 11:09:05 +0200 Subject: [PATCH 088/581] Todo for netstream --- doc/todo/netstream-1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 doc/todo/netstream-1 diff --git a/doc/todo/netstream-1 b/doc/todo/netstream-1 new file mode 100644 index 0000000..7bf2dec --- /dev/null +++ b/doc/todo/netstream-1 @@ -0,0 +1,12 @@ +Logger: + - Eine mail pro Rechner generieren + - Zusammenfassung / intelligente Auswertung + o .*vanished.* + - Zusammenfassung? + - Nur Mail, wenn kritischer Fehler + o option fuer auch Warnungen + +Warnungen: + Dateien verschwunden: + +Fehler: From fb6749098fa3ab376a1fdc810d68f9a6b143e963 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 22 Jun 2007 11:17:14 +0200 Subject: [PATCH 089/581] Update netstream requirements --- doc/todo/netstream-1 | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/doc/todo/netstream-1 b/doc/todo/netstream-1 index 7bf2dec..63d9976 100644 --- a/doc/todo/netstream-1 +++ b/doc/todo/netstream-1 @@ -1,12 +1,20 @@ +Preamble: + Netstream (www.netstream.ch) may consider using ccollect for backing up many + unix servers and needs some clean reporting. The following things + need to be done, so ccollect will be useful for netstream: + Logger: - - Eine mail pro Rechner generieren - - Zusammenfassung / intelligente Auswertung - o .*vanished.* - - Zusammenfassung? - - Nur Mail, wenn kritischer Fehler - o option fuer auch Warnungen + - Needs to write small mails (sysadmins don't have time to read mails) + - Needs to be able to only write a mail on error + * needs configuration option to also mail on warnings + - Should be able to send one mail per backup source + * or one for the whole backup job -Warnungen: - Dateien verschwunden: +Messages: (to be used for filtering) + Errors: + Read from remote host .*: Connection timed out + + Warnings: + rsync: mknod .* failed: Invalid argument (22) + file has vanished: ".*" -Fehler: From 8b99b05dfd57152e18009283f53231354c7fd766 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 22 Jun 2007 11:19:15 +0200 Subject: [PATCH 090/581] Add running on netbsd --- doc/ccollect.text | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 1962e32..09b86a4 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -20,8 +20,9 @@ Supported and tested operating systems and architectures ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ccollect was successfully tested on the following platforms: -- OpenBSD on amd64 - GNU/Linux on hppa/i386/amd64 +- NetBSD on i386/amd64/sparc/sparc64 +- OpenBSD on amd64 It *should* run on any Unix that supports rsync and has a POSIX-compatible bourne shell. If your platform is not listed above and you have it successfully From a89cb0ce38a8b73112f2645799dda3aaf270e530 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 22 Jun 2007 11:21:17 +0200 Subject: [PATCH 091/581] split CCOLLECT to CCOLLECT_SOURCE and CCOLLECT_DEST --- Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 0b50e4e..80c2ad2 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,8 @@ # INSTALL=install -CCOLLECT=ccollect.sh +CCOLLECT_SOURCE=ccollect.sh +CCOLLECT_DEST=ccollect.sh LN=ln -sf ASCIIDOC=asciidoc DOCBOOKTOTEXI=docbook2x-texi @@ -14,10 +15,10 @@ XSL=/usr/share/xml/docbook/stylesheet/nwalsh/html/docbook.xsl prefix=/usr/packages/ccollect-git bindir=$(prefix)/bin -destination=$(bindir)/$(CCOLLECT) +destination=$(bindir)/$(CCOLLECT_DEST) path_dir=/usr/local/bin -path_destination=$(path_dir)/$(CCOLLECT) +path_destination=$(path_dir)/$(CCOLLECT_DEST) # where to publish host=home.schottelius.org @@ -67,7 +68,7 @@ install-link: install-script $(LN) $(destination) $(path_destination) install-script: - $(INSTALL) -D -m 0755 $(CCOLLECT) $(destination) + $(INSTALL) -D -m 0755 $(CCOLLECT_SOURCE) $(destination) # docbook gets .htm, asciidoc directly .html From 2138967b194315e6a5e51e8959b43e7e7af01f9a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 22 Jun 2007 11:22:09 +0200 Subject: [PATCH 092/581] Add hints from tonnerre --- doc/todo/0.5.3.tonnerre | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 doc/todo/0.5.3.tonnerre diff --git a/doc/todo/0.5.3.tonnerre b/doc/todo/0.5.3.tonnerre new file mode 100644 index 0000000..4e7b7db --- /dev/null +++ b/doc/todo/0.5.3.tonnerre @@ -0,0 +1,11 @@ +NetBSD/i386,amd64,sparc,sparc64 + +13:13 < Tonnerre> telmich, die kleine wä, 2 Variablen aus $(CCOLLECT) zu + machen +13:13 < Tonnerre> telmich, eine fü Sourcepfad und eine fü +Destinationfpad +13:13 < Tonnerre> pfa +13:13 < Tonnerre> d +13:14 < Tonnerre> telmich, die gröre wä die $() durch ${} zu ersetzen, so +dass der Kram auch mit !GNU-Make geht + From 3af14e5eacd685a13704f8e6eeae13fd2f56db2a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 22 Jun 2007 11:23:37 +0200 Subject: [PATCH 093/581] replace () with {} to support non gnu-make --- Makefile | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 80c2ad2..7afb146 100644 --- a/Makefile +++ b/Makefile @@ -14,42 +14,42 @@ XSLTPROC=xsltproc XSL=/usr/share/xml/docbook/stylesheet/nwalsh/html/docbook.xsl prefix=/usr/packages/ccollect-git -bindir=$(prefix)/bin -destination=$(bindir)/$(CCOLLECT_DEST) +bindir=${prefix}/bin +destination=${bindir}/${CCOLLECT_DEST} path_dir=/usr/local/bin -path_destination=$(path_dir)/$(CCOLLECT_DEST) +path_destination=${path_dir}/${CCOLLECT_DEST} # where to publish host=home.schottelius.org dir=www/org/schottelius/unix/www/ccollect/ -docdir=$(dir)/doc +docdir=${dir}/doc # # Asciidoc will be used to generate other formats later # MANDOCS = doc/man/ccollect.text -DOCS = $(MANDOCS) doc/ccollect.text doc/ccollect-DE.text +DOCS = ${MANDOCS} doc/ccollect.text doc/ccollect-DE.text # # Doku # -HTMLDOCS = $(DOCS:.text=.html) -DBHTMLDOCS = $(DOCS:.text=.htm) +HTMLDOCS = ${DOCS:.text=.html} +DBHTMLDOCS = ${DOCS:.text=.htm} -TEXIDOCS = $(DOCS:.text=.texi) +TEXIDOCS = ${DOCS:.text=.texi} -MANPDOCS = $(MANDOCS:.text=.man) +MANPDOCS = ${MANDOCS:.text=.man} -DOCBDOCS = $(DOCS:.text=.docbook) +DOCBDOCS = ${DOCS:.text=.docbook} -DOC_ALL = $(HTMLDOCS) $(DBHTMLDOCS) $(TEXIDOCS) $(MANPDOCS) +DOC_ALL = ${HTMLDOCS} ${DBHTMLDOCS} ${TEXIDOCS} ${MANPDOCS} -html: $(HTMLDOCS) -htm: $(DBHTMLDOCS) -info: $(TEXIDOCS) -man: $(MANPDOCS) -documentation: $(DOC_ALL) +html: ${HTMLDOCS} +htm: ${DBHTMLDOCS} +info: ${TEXIDOCS} +man: ${MANPDOCS} +documentation: ${DOC_ALL} # # End user targets @@ -59,16 +59,16 @@ all: @echo "documentation: generate HTMl, Texinfo and manpage" @echo "html: only generate HTML" @echo "info: only generate Texinfo" - @echo "man: only generate manpage(s)" - @echo "install: install ccollect to $(prefix)" + @echo "man: only generate manpage{s}" + @echo "install: install ccollect to ${prefix}" install: install-script install-link install-link: install-script - $(LN) $(destination) $(path_destination) + ${LN} ${destination} ${path_destination} install-script: - $(INSTALL) -D -m 0755 $(CCOLLECT_SOURCE) $(destination) + ${INSTALL} -D -m 0755 ${CCOLLECT_SOURCE} ${destination} # docbook gets .htm, asciidoc directly .html @@ -104,18 +104,18 @@ push-work: @cg-push sygroup publish-doc: documentation - @echo "Transferring files to $(host)" - @chmod a+r $(DOCS) $(DOC_ALL) - @tar c $(DOCS) $(DOC_ALL) | ssh $(host) "cd $(dir); tar xv" + @echo "Transferring files to ${host}" + @chmod a+r ${DOCS} ${DOC_ALL} + @tar c ${DOCS} ${DOC_ALL} | ssh ${host} "cd ${dir}; tar xv" # # Distribution # allclean: - rm -f $(DOC_ALL) + rm -f ${DOC_ALL} distclean: allclean - rm -f $(DOCBDOCS) + rm -f ${DOCBDOCS} # # Be nice with the users and generate documentation for them From d0a61902032191a9c61de1478099dc0a82c6e693 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 25 Jun 2007 12:00:05 +0200 Subject: [PATCH 094/581] Initial version of ccollect-stats.sh from Daniel Aubry (w/o header and everything) --- tools/ccollect-stats.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tools/ccollect-stats.sh diff --git a/tools/ccollect-stats.sh b/tools/ccollect-stats.sh new file mode 100644 index 0000000..5ce171b --- /dev/null +++ b/tools/ccollect-stats.sh @@ -0,0 +1,17 @@ +#!/bin/sh + + +if [ ! -e /tmp/ccollect-stats.lock ] +then + touch /tmp/ccollect-stats.lock + find /etc/ccollect/sources/ -type l | while read line + do + backupname=$(basename $(readlink $line)) + echo "====[Backup: $backupname]====" | tee -a /var/log/backup.log + du -sh $line/* | tee -a /var/log/backup.log + done + rm /tmp/ccollect-stats.lock +fi + + + From a92d28db169c431b99b87adadeb7803864625265 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 7 Aug 2007 07:48:52 +0200 Subject: [PATCH 095/581] Add create source --- tools/create_source.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tools/create_source.sh diff --git a/tools/create_source.sh b/tools/create_source.sh new file mode 100644 index 0000000..92f2bc7 --- /dev/null +++ b/tools/create_source.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# Nico Schottelius +# 2007-08-07 +# Written for Netstream (www.netstream.ch) +# Creates a source, including exclude + +if [ $# -ne 1 ]; then + echo $(basename $0): name + exit 1 +fi + +CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} +CSOURCES=$CCOLLECT_CONF/sources +CDEFAULTS=$CCOLLECT_CONF/defaults + +name="$1" +fullname="${CSOURCES}/${name}" + +if [ -e "${fullname}" ]; then + echo "${fullname} already exists. Aborting." + exit 2 +fi From e87a7a5db14377a97dd808e834d3d98fc0e498f1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 7 Aug 2007 07:49:50 +0200 Subject: [PATCH 096/581] More todo --- doc/todo/0.6 | 5 +++++ doc/todo/netstream-1 | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/doc/todo/0.6 b/doc/todo/0.6 index 4732ab6..79c2941 100644 --- a/doc/todo/0.6 +++ b/doc/todo/0.6 @@ -33,6 +33,11 @@ _eecho () { _techo "ERROR $msg" } - add --version, -V - do we want rsync -H by default? +ssh / port change: + change rsync_extra format +add note for + 09:24 < telmich> Obri: ~/.ssh/config! + Documentation: - hint: backuping backup diff --git a/doc/todo/netstream-1 b/doc/todo/netstream-1 index 63d9976..0e13896 100644 --- a/doc/todo/netstream-1 +++ b/doc/todo/netstream-1 @@ -18,3 +18,10 @@ Messages: (to be used for filtering) rsync: mknod .* failed: Invalid argument (22) file has vanished: ".*" +-------------------------------------------------------------------------------- +rsync_extra global! +- \n delimeted + +Analyzer: + - grosse Dateien + - grosse Veraenderungen From 500bfc55e45684f3bd1ce065534d58a922773fbc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 7 Aug 2007 08:21:40 +0200 Subject: [PATCH 097/581] added exclude --- tools/create_source.sh | 47 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) mode change 100644 => 100755 tools/create_source.sh diff --git a/tools/create_source.sh b/tools/create_source.sh old mode 100644 new mode 100755 index 92f2bc7..7795baa --- a/tools/create_source.sh +++ b/tools/create_source.sh @@ -4,19 +4,54 @@ # Written for Netstream (www.netstream.ch) # Creates a source, including exclude -if [ $# -ne 1 ]; then - echo $(basename $0): name - exit 1 -fi - +# standard values CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} CSOURCES=$CCOLLECT_CONF/sources CDEFAULTS=$CCOLLECT_CONF/defaults +# functions first +_echo() +{ + echo -n "$(basename $0)> $@" + exit 1 +} + +_exit_err() +{ + _echo "$@" + rm -f "$TMP" + exit 1 +} + +# argv +if [ $# -ne 1 ]; then + _echo "$(basename $0): " + exit 1 +fi + name="$1" fullname="${CSOURCES}/${name}" +# Tests if [ -e "${fullname}" ]; then - echo "${fullname} already exists. Aborting." + _echo "${fullname} already exists. Aborting." exit 2 fi + +_echo "Trying to reach ${name} ..." +ping -c1 "${name}" || _exit_err "Cannot reach ${name}. Aborting." + +# Create +_echo "Creating ${fullname} ..." +mkdir -p "${fullname}" || exit 3 + +echo "${name}:/" > "${fullname}/source" +cat << eof > "${fullname}/exclude" +/dev/* +/proc/* +/tmp/* +eof + +# finish +_echo "Added some default values, please verify ${fullname}." +_echo "Finished." From 78c3dc1bd7a67851a8d43ca6f8e07eba7e7113e1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 7 Aug 2007 08:40:44 +0200 Subject: [PATCH 098/581] Finished create_source --- tools/create_source.sh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tools/create_source.sh b/tools/create_source.sh index 7795baa..f05a237 100755 --- a/tools/create_source.sh +++ b/tools/create_source.sh @@ -9,10 +9,12 @@ CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} CSOURCES=$CCOLLECT_CONF/sources CDEFAULTS=$CCOLLECT_CONF/defaults +self=$(basename $0) + # functions first _echo() { - echo -n "$(basename $0)> $@" + echo -n "${self}> $@" exit 1 } @@ -24,13 +26,14 @@ _exit_err() } # argv -if [ $# -ne 1 ]; then - _echo "$(basename $0): " +if [ $# -ne 2 ]; then + _echo "Arguments needed: " exit 1 fi name="$1" fullname="${CSOURCES}/${name}" +destination="$2" # Tests if [ -e "${fullname}" ]; then @@ -46,12 +49,25 @@ _echo "Creating ${fullname} ..." mkdir -p "${fullname}" || exit 3 echo "${name}:/" > "${fullname}/source" -cat << eof > "${fullname}/exclude" +cat << eof > "${fullname}/exclude" || exit 4 /dev/* /proc/* /tmp/* eof +# Destination +if [ -e "${destination}" ]; then + if [ ! -d "${destination}" ]; then + echo "${destination} exists, but is not a directory. Aborting." + exit 5 + fi +else + mkdir -p "${destination}" || _exit_err "Failed to create ${destination}." +fi + +ln -s "${destination}" "${fullname}/destination" || \ + _exit_err "Failed to link \"${destination}\" to \"${fullname}/destination\"" + # finish _echo "Added some default values, please verify ${fullname}." _echo "Finished." From e3555ed0184c8688e4a9b40b670fc228cb94d0f2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 7 Aug 2007 10:27:17 +0200 Subject: [PATCH 099/581] echo, not echo -n --- tools/create_source.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/create_source.sh b/tools/create_source.sh index f05a237..075a025 100755 --- a/tools/create_source.sh +++ b/tools/create_source.sh @@ -14,7 +14,7 @@ self=$(basename $0) # functions first _echo() { - echo -n "${self}> $@" + echo "${self}> $@" exit 1 } From 4c2737cb5b3dcae66e72f591646ca3709cf4480b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 7 Aug 2007 10:28:59 +0200 Subject: [PATCH 100/581] Inform about create --- tools/create_source.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/create_source.sh b/tools/create_source.sh index 075a025..8ea532b 100755 --- a/tools/create_source.sh +++ b/tools/create_source.sh @@ -62,6 +62,7 @@ if [ -e "${destination}" ]; then exit 5 fi else + _echo "Creating ${destination} ..." mkdir -p "${destination}" || _exit_err "Failed to create ${destination}." fi From 4b77c5ba852126ebe52c2997857ad1ab5d357167 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 7 Aug 2007 10:33:55 +0200 Subject: [PATCH 101/581] exit at the wrong location --- tools/create_source.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/create_source.sh b/tools/create_source.sh index 8ea532b..3d12e64 100755 --- a/tools/create_source.sh +++ b/tools/create_source.sh @@ -15,7 +15,6 @@ self=$(basename $0) _echo() { echo "${self}> $@" - exit 1 } _exit_err() From d0a417c3bd7bcfbdd8addf63ec7cf5750fedc777 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 7 Aug 2007 10:42:42 +0200 Subject: [PATCH 102/581] Name can be different. Default is to backup as root --- tools/create_source.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tools/create_source.sh b/tools/create_source.sh index 3d12e64..7a34c6b 100755 --- a/tools/create_source.sh +++ b/tools/create_source.sh @@ -25,14 +25,16 @@ _exit_err() } # argv -if [ $# -ne 2 ]; then - _echo "Arguments needed: " +if [ $# -ne 3 ]; then + _echo " " + _echo "Example: \"my-notebook\" \"192.168.42.42\" \"/home/server/backup/my-notebook\"" exit 1 fi name="$1" +source="$2" +destination="$3" fullname="${CSOURCES}/${name}" -destination="$2" # Tests if [ -e "${fullname}" ]; then @@ -40,14 +42,14 @@ if [ -e "${fullname}" ]; then exit 2 fi -_echo "Trying to reach ${name} ..." -ping -c1 "${name}" || _exit_err "Cannot reach ${name}. Aborting." +_echo "Trying to reach ${source} ..." +ping -c1 "${source}" || _exit_err "Cannot reach ${source}. Aborting." # Create _echo "Creating ${fullname} ..." mkdir -p "${fullname}" || exit 3 -echo "${name}:/" > "${fullname}/source" +echo "root@${source}:/" > "${fullname}/source" cat << eof > "${fullname}/exclude" || exit 4 /dev/* /proc/* @@ -69,5 +71,5 @@ ln -s "${destination}" "${fullname}/destination" || \ _exit_err "Failed to link \"${destination}\" to \"${fullname}/destination\"" # finish -_echo "Added some default values, please verify ${fullname}." +_echo "Added some default values, please verify \"${fullname}\"." _echo "Finished." From fa695bdebf87b0213fe808c3ec46414e2ec64cd1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 7 Aug 2007 11:06:10 +0200 Subject: [PATCH 103/581] Add script which uses a basedir --- tools/create_source2.sh | 85 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100755 tools/create_source2.sh diff --git a/tools/create_source2.sh b/tools/create_source2.sh new file mode 100755 index 0000000..6df7b78 --- /dev/null +++ b/tools/create_source2.sh @@ -0,0 +1,85 @@ +#!/bin/sh +# Nico Schottelius +# 2007-08-07 +# Written for Netstream (www.netstream.ch) +# Creates a source, including exclude + +# standard values +CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} +CSOURCES=$CCOLLECT_CONF/sources +CDEFAULTS=$CCOLLECT_CONF/defaults + +self=$(basename $0) + +# functions first +_echo() +{ + echo "${self}> $@" +} + +_exit_err() +{ + _echo "$@" + rm -f "$TMP" + exit 1 +} + +# argv +if [ $# -ne 3 ]; then + _echo " " + _echo "Example: \"192.168.42.42\" \"/home/server/backup/\"" + _echo " This will create ${CSOURCES}/192.168.42.42 and /home/server/backup/192.168.42.42." + exit 1 +fi + +# sourcename / servername +name="$1" + +# basedir +basedir="$2" + +fullname="${CSOURCES}/${name}" +destination=${basedir}/${name}" + +# Tests +if [ -e "${fullname}" ]; then + _echo "${fullname} already exists. Aborting." + exit 2 +fi + +_echo "Trying to reach ${source} ..." +ping -c1 "${name}" || _exit_err "Cannot reach ${name}. Aborting." + +if [ ! -d "${basedir}" ]; then + echo "${basedir} is not a directory. Aborting." + exit 7 +fi + +# Create +_echo "Creating ${fullname} ..." +mkdir -p "${fullname}" || exit 3 + +echo "root@${name}:/" > "${fullname}/source" +cat << eof > "${fullname}/exclude" || exit 4 +/dev/* +/proc/* +/tmp/* +eof + +# Destination +if [ -e "${destination}" ]; then + if [ ! -d "${destination}" ]; then + echo "${destination} exists, but is not a directory. Aborting." + exit 5 + fi +else + _echo "Creating ${destination} ..." + mkdir -p "${destination}" || _exit_err "Failed to create ${destination}." +fi + +ln -s "${destination}" "${fullname}/destination" || \ + _exit_err "Failed to link \"${destination}\" to \"${fullname}/destination\"" + +# finish +_echo "Added some default values, please verify \"${fullname}\"." +_echo "Finished." From dc5aec71ed641c0a459685c0de4b541d34305cb4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 7 Aug 2007 11:16:58 +0200 Subject: [PATCH 104/581] Change for basedir, argv --- tools/create_source2.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/create_source2.sh b/tools/create_source2.sh index 6df7b78..842afb6 100755 --- a/tools/create_source2.sh +++ b/tools/create_source2.sh @@ -25,7 +25,7 @@ _exit_err() } # argv -if [ $# -ne 3 ]; then +if [ $# -ne 2 ]; then _echo " " _echo "Example: \"192.168.42.42\" \"/home/server/backup/\"" _echo " This will create ${CSOURCES}/192.168.42.42 and /home/server/backup/192.168.42.42." @@ -39,7 +39,7 @@ name="$1" basedir="$2" fullname="${CSOURCES}/${name}" -destination=${basedir}/${name}" +destination="${basedir}/${name}" # Tests if [ -e "${fullname}" ]; then @@ -47,7 +47,7 @@ if [ -e "${fullname}" ]; then exit 2 fi -_echo "Trying to reach ${source} ..." +_echo "Trying to reach ${name} ..." ping -c1 "${name}" || _exit_err "Cannot reach ${name}. Aborting." if [ ! -d "${basedir}" ]; then From 965c3e37f7dab558356c7762166b622af9208b3b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 14 Aug 2007 14:29:17 +0200 Subject: [PATCH 105/581] More todo for netstream --- doc/todo/netstream-1 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/doc/todo/netstream-1 b/doc/todo/netstream-1 index 0e13896..9b7a514 100644 --- a/doc/todo/netstream-1 +++ b/doc/todo/netstream-1 @@ -25,3 +25,24 @@ rsync_extra global! Analyzer: - grosse Dateien - grosse Veraenderungen +-------------------------------------------------------------------------------- +exclude-lists-doku: +freebsd: + /usr/ports/* + /proc/* + /dev/* + /tmp/* + /var/tmp/* +linux: + /sys/* + /proc/* + /dev/* + /tmp/* +-------------------------------------------------------------------------------- + -S, --sparse + Try to handle sparse files efficiently so they take up less space on the des‐ + tination. Conflicts with --inplace because it’s not possible to overwrite + data in a sparse fashion. + +-------------------------------------------------------------------------------- + Always report return code! From d08ac69af61d2b89f23318eecacb5d348af24262 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 14 Aug 2007 14:33:22 +0200 Subject: [PATCH 106/581] Better parsable date output --- ccollect.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 367006c..260fae6 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -1,6 +1,6 @@ #!/bin/sh # Nico Schottelius -# written for SyGroup (www.sygroup.ch) +# Initially written for SyGroup (www.sygroup.ch) # Date: Mon Nov 14 11:45:11 CET 2005 # Last Modified: (See ls -l or git) @@ -24,7 +24,7 @@ FULL_VERSION="ccollect $VERSION ($RELEASE)" # DDATE: how the user should see it in our output # CDATE="date +%Y-%m-%d-%H%M" -DDATE="date" +DDATE="date +%Y-%m-%d-%H:%M:%S" # # unset parallel execution From 30352b83a86422801ca59e273804edf775fa619e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 14 Aug 2007 14:36:33 +0200 Subject: [PATCH 107/581] Always print return code --- ccollect.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index 260fae6..808b4a2 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -489,8 +489,10 @@ while [ "$i" -lt "$no_sources" ]; do ret=$? + echo "Rsync return code: $ret." + if [ "$ret" -ne 0 ]; then - echo "rsync reported error $ret. The backup may be broken (see rsync errors)." + echo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." fi # From dc7d5d614bcf07bcf53c8a5824ade450aac33b46 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 14 Aug 2007 14:41:36 +0200 Subject: [PATCH 108/581] Reorder: first check if we should take all sources, then execute pre-exec --- ccollect.sh | 26 +++++++++++++++----------- doc/CHANGES | 1 + doc/todo/0.6 | 4 +++- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 808b4a2..c656f16 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -93,6 +93,9 @@ export INTERVAL="$1"; shift i=1 no_sources=0 +# +# Create source "array" +# while [ "$i" -le $# ]; do eval arg=\"\$$i\" @@ -139,17 +142,6 @@ if [ "$VERBOSE" = 1 ]; then set -x fi -# -# Look for pre-exec command (general) -# -if [ -x "${CPREEXEC}" ]; then - echo "Executing ${CPREEXEC} ..." - "${CPREEXEC}"; ret=$? - echo "Finished ${CPREEXEC}." - - [ "${ret}" -eq 0 ] || _exit_err "${CPREEXEC} failed, not starting backup." -fi - # # Look, if we should take ALL sources # @@ -171,6 +163,18 @@ if [ "$ALL" = 1 ]; then done < "${TMP}" fi +# +# Look for pre-exec command (general) +# +if [ -x "${CPREEXEC}" ]; then + echo "Executing ${CPREEXEC} ..." + "${CPREEXEC}"; ret=$? + echo "Finished ${CPREEXEC}." + + [ "${ret}" -eq 0 ] || _exit_err "${CPREEXEC} exited with return-code $ret" \ + ", aborting backup." +fi + # # Need at least ONE source to backup # diff --git a/doc/CHANGES b/doc/CHANGES index fcfef5e..505ee9a 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,6 +1,7 @@ 0.5.2 to 0.5.3: * add 'exec-after-rm' (source specific) configuration * added logwrapper + * Always print return code of rsync 0.5.1 to 0.5.2: * Display correct error code, if rsync returns non-zero diff --git a/doc/todo/0.6 b/doc/todo/0.6 index 79c2941..85fd981 100644 --- a/doc/todo/0.6 +++ b/doc/todo/0.6 @@ -45,5 +45,7 @@ Documentation: - german doc? - exit pre/post exec -> error codes (after implementation!) (in 0.4) - write about fast changing fs - +- Variables: + source_$n + no_sources From 08e864ee0dd4b54cc4a3be2961f509f7a2eff528 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 14 Aug 2007 14:57:26 +0200 Subject: [PATCH 109/581] Add test to Makefile --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 7afb146..0512afe 100644 --- a/Makefile +++ b/Makefile @@ -121,3 +121,6 @@ distclean: allclean # Be nice with the users and generate documentation for them # dist: distclean documentation + +test: ccollect.sh + CCOLLECT_CONF=./conf ./ccollect.sh daily "source with spaces" From c042479097d25a539aeaf20ffc25fe28ffe24c7e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 14 Aug 2007 15:26:20 +0200 Subject: [PATCH 110/581] Add much more timing information And empty $@ and $#, which we'll reuse later. --- ccollect.sh | 97 ++++++++++++++------------ conf/sources/source with spaces/source | 2 +- doc/CHANGES | 1 + doc/todo/0.6 | 3 + 4 files changed, 56 insertions(+), 47 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index c656f16..58cf25b 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -14,14 +14,14 @@ CPREEXEC="$CDEFAULTS/pre_exec" CPOSTEXEC="$CDEFAULTS/post_exec" TMP=$(mktemp /tmp/$(basename $0).XXXXXX) -VERSION=0.5.3 +VERSION=0.6 RELEASE="2007-XX-XX" HALF_VERSION="ccollect $VERSION" FULL_VERSION="ccollect $VERSION ($RELEASE)" # # CDATE: how we use it for naming of the archives -# DDATE: how the user should see it in our output +# DDATE: how the user should see it in our output (DISPLAY) # CDATE="date +%Y-%m-%d-%H%M" DDATE="date +%Y-%m-%d-%H:%M:%S" @@ -40,9 +40,16 @@ trap "rm -f \"$TMP\"" 1 2 15 # Functions # +# time displaying echo +_techo() +{ + echo "$(${DDATE}): $@" +} + +# exit on error _exit_err() { - echo "$@" + _techo "$@" rm -f "$TMP" exit 1 } @@ -96,8 +103,9 @@ no_sources=0 # # Create source "array" # -while [ "$i" -le $# ]; do - eval arg=\"\$$i\" +while [ "$#" -ge 1 ]; do + eval arg=\"\$1\" + shift if [ "$NO_MORE_ARGS" = 1 ]; then eval source_${no_sources}=\"$arg\" @@ -135,6 +143,9 @@ done # also export number of sources export no_sources +echo $@, $# +exit + # # be really, really, really verbose # @@ -163,6 +174,15 @@ if [ "$ALL" = 1 ]; then done < "${TMP}" fi +# +# Need at least ONE source to backup +# +if [ "${no_sources}" -lt 1 ]; then + usage +else + _techo "${HALF_VERSION}: Beginning backup using interval ${INTERVAL}" +fi + # # Look for pre-exec command (general) # @@ -171,19 +191,10 @@ if [ -x "${CPREEXEC}" ]; then "${CPREEXEC}"; ret=$? echo "Finished ${CPREEXEC}." - [ "${ret}" -eq 0 ] || _exit_err "${CPREEXEC} exited with return-code $ret" \ + [ "${ret}" -eq 0 ] || _exit_err "${CPREEXEC} exited with return code ${ret}" \ ", aborting backup." fi -# -# Need at least ONE source to backup -# -if [ "$no_sources" -lt 1 ]; then - usage -else - echo "==> $HALF_VERSION: Beginning backup using interval $INTERVAL <==" -fi - # # check default configuration # @@ -191,6 +202,7 @@ fi D_FILE_INTERVAL="${CDEFAULTS}/intervals/${INTERVAL}" D_INTERVAL=$(cat "${D_FILE_INTERVAL}" 2>/dev/null) + # # Let's do the backup # @@ -223,7 +235,7 @@ while [ "$i" -lt "$no_sources" ]; do exec 2>&1 # - # Standard locations + # Configuration # backup="${CSOURCES}/${name}" c_source="${backup}/source" @@ -235,17 +247,12 @@ while [ "$i" -lt "$no_sources" ]; do c_summary="${backup}/summary" c_pre_exec="${backup}/pre_exec" c_post_exec="${backup}/post_exec" - - - # - # FIXME: enable in 0.6 - # Always execute, warn if it exists in normal case - # and rm -rf the old backup, if "delete_incomplete" is set - # c_incomplete="$backup/delete_incomplete" - #c_marker=".ccollect-${CDATE}.$$" - begin=$($DDATE) + # + # Times + # + c_marker=".ccollect-$(${CDATE}).$$" begin_s=$(date +%s) # @@ -257,13 +264,13 @@ while [ "$i" -lt "$no_sources" ]; do VERBOSE="" VVERBOSE="" - echo "${begin} Beginning to backup" + _techo "Beginning to backup" # # Standard configuration checks # if [ ! -e "${backup}" ]; then - echo "Source does not exist." + _techo "Source does not exist." exit 1 fi @@ -271,7 +278,7 @@ while [ "$i" -lt "$no_sources" ]; do # configuration _must_ be a directory # if [ ! -d "${backup}" ]; then - echo "\"${name}\" is not a cconfig-directory. Skipping." + _techo "\"${name}\" is not a cconfig-directory. Skipping." exit 1 fi @@ -280,14 +287,12 @@ while [ "$i" -lt "$no_sources" ]; do # parameters # if [ -x "${c_pre_exec}" ]; then - echo "Executing ${c_pre_exec} ..." + _techo "Executing ${c_pre_exec} ..." "${c_pre_exec}"; ret="$?" - echo "Finished ${c_pre_exec}." + _techo "Finished ${c_pre_exec} (return code ${ret})." - # FIXME: is _exit_err senseful here? if [ "${ret}" -ne 0 ]; then - echo "${c_pre_exec} failed. Skipping." - exit 1 + _exit_err "${c_pre_exec} failed. Skipping." fi fi @@ -299,25 +304,20 @@ while [ "$i" -lt "$no_sources" ]; do if [ -z "${c_interval}" ]; then c_interval="${D_INTERVAL}" - # FIXME: is _exit_err senseful here? if [ -z "${c_interval}" ]; then - echo "No definition for interval \"${INTERVAL}\" found. Skipping." - exit 1 + _exit_err "No definition for interval \"${INTERVAL}\" found. Skipping." fi fi # # Source checks # - # FIXME: is _exit_err senseful here? if [ ! -f "${c_source}" ]; then - echo "Source description ${c_source} is not a file. Skipping." - exit 1 + _exit_err "Source description \"${c_source}\" is not a file. Skipping." else - source=$(cat "$c_source") - if [ $? -ne 0 ]; then - echo "Source $c_source is not readable. Skipping." - exit 1 + source=$(cat "${c_source}"); ret=$? + if [ ${ret} -ne 0 ]; then + _exit_err "Source ${c_source} is not readable. Skipping." fi fi @@ -325,14 +325,19 @@ while [ "$i" -lt "$no_sources" ]; do # destination _must_ be a directory # if [ ! -d "${c_dest}" ]; then - echo "Destination ${c_dest} neither links to nor is a directory. Skipping." - exit 1 + _exit_err "Destination ${c_dest} neither links to nor is a directory. Skipping." fi + # NEW + # - insert ccollect default parameters + # - insert options + # - insert user options + + # # exclude list # - if [ -f "$c_exclude" ]; then + if [ -f "${c_exclude}" ]; then # FIXME: check how quoting at the end looks like # perhaps our source contains spaces! EXCLUDE="--exclude-from=$c_exclude" diff --git a/conf/sources/source with spaces/source b/conf/sources/source with spaces/source index 46b885f..13f435d 100644 --- a/conf/sources/source with spaces/source +++ b/conf/sources/source with spaces/source @@ -1 +1 @@ -/home/user/nico/test2 +/home/user/nico/projekte/ccollect diff --git a/doc/CHANGES b/doc/CHANGES index 505ee9a..abc7478 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -2,6 +2,7 @@ * add 'exec-after-rm' (source specific) configuration * added logwrapper * Always print return code of rsync + * Add much more timing information 0.5.1 to 0.5.2: * Display correct error code, if rsync returns non-zero diff --git a/doc/todo/0.6 b/doc/todo/0.6 index 85fd981..a1fb24e 100644 --- a/doc/todo/0.6 +++ b/doc/todo/0.6 @@ -32,6 +32,8 @@ _eecho () { _techo "ERROR $msg" } Wenn Summary angegeben ist am Ende ausgeben - add --version, -V - do we want rsync -H by default? +- add source/ignore_failed_pre_exec +- add source/ignore_failed_post_exec ssh / port change: change rsync_extra format @@ -48,4 +50,5 @@ Documentation: - Variables: source_$n no_sources + name From 63a683941f73f8984f613ec59c582bdbdd1868f0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 14 Aug 2007 15:30:00 +0200 Subject: [PATCH 111/581] Pass exclude in a safe way to rsync --- ccollect.sh | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 58cf25b..da2a8e7 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -104,8 +104,7 @@ no_sources=0 # Create source "array" # while [ "$#" -ge 1 ]; do - eval arg=\"\$1\" - shift + eval arg=\"\$1\"; shift if [ "$NO_MORE_ARGS" = 1 ]; then eval source_${no_sources}=\"$arg\" @@ -143,9 +142,6 @@ done # also export number of sources export no_sources -echo $@, $# -exit - # # be really, really, really verbose # @@ -164,9 +160,9 @@ if [ "$ALL" = 1 ]; then # get entries from sources # cwd=$(pwd -P) - ( cd "${CSOURCES}" && ls > "${TMP}" ) + ( cd "${CSOURCES}" && ls > "${TMP}" ); ret=$? - [ "$?" -eq 0 ] || _exit_err "Listing of sources failed. Aborting." + [ "${ret}" -eq 0 ] || _exit_err "Listing of sources failed. Aborting." while read tmp; do eval source_${no_sources}=\"$tmp\" @@ -332,15 +328,13 @@ while [ "$i" -lt "$no_sources" ]; do # - insert ccollect default parameters # - insert options # - insert user options - + # # exclude list # if [ -f "${c_exclude}" ]; then - # FIXME: check how quoting at the end looks like - # perhaps our source contains spaces! - EXCLUDE="--exclude-from=$c_exclude" + set -- "$@" "--exclude-from=$c_exclude" fi # From ed91b488da0159f409dc367b1361182ff1caa3cb Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 14 Aug 2007 15:31:49 +0200 Subject: [PATCH 112/581] Change rsync_options to one argument per line --- ccollect.sh | 4 +++- doc/CHANGES | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index da2a8e7..98d5720 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -341,7 +341,9 @@ while [ "$i" -lt "$no_sources" ]; do # extra options for rsync # if [ -f "${c_rsync_extra}" ]; then - RSYNC_EXTRA="$(cat "${c_rsync_extra}")" + while read line; do + set -- "$@" "$line" + RSYNC_EXTRA="$(cat "${c_rsync_extra}")" fi # diff --git a/doc/CHANGES b/doc/CHANGES index abc7478..7f39a8c 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,8 +1,9 @@ -0.5.2 to 0.5.3: +0.5.2 to 0.6: * add 'exec-after-rm' (source specific) configuration * added logwrapper * Always print return code of rsync * Add much more timing information + * One option per line in rsync_options now 0.5.1 to 0.5.2: * Display correct error code, if rsync returns non-zero From e92bd762d4efb565571e66f7548c41d9fafbb595 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 14 Aug 2007 15:40:23 +0200 Subject: [PATCH 113/581] Begin reordering options --- ccollect.sh | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 98d5720..d3f553b 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -329,7 +329,11 @@ while [ "$i" -lt "$no_sources" ]; do # - insert options # - insert user options + # + # rsync standard options + # + ouropts="-a --delete --numeric-ids --relative --delete-excluded" # # exclude list # @@ -337,35 +341,29 @@ while [ "$i" -lt "$no_sources" ]; do set -- "$@" "--exclude-from=$c_exclude" fi - # - # extra options for rsync - # - if [ -f "${c_rsync_extra}" ]; then - while read line; do - set -- "$@" "$line" - RSYNC_EXTRA="$(cat "${c_rsync_extra}")" - fi - # # Output a summary # if [ -f "${c_summary}" ]; then - SUMMARY="--stats" + set -- "$@" "--stats" fi # # Verbosity for rsync # - if [ -f "${c_verbose}" ]; then - VERBOSE="-v" + if [ -f "${c_vverbose}" ]; then + set -- "$@" "-vv" + elif [ -f "${c_verbose}" ]; then + set -- "$@" "-v" fi # - # MORE verbosity, includes standard verbosity + # extra options for rsync provided by the user # - if [ -f "${c_vverbose}" ]; then - VERBOSE="-v" - VVERBOSE="-v" + if [ -f "${c_rsync_extra}" ]; then + while read line; do + set -- "$@" "$line" + done < "${c_rsync_extra}" fi # # @@ -447,25 +445,17 @@ while [ "$i" -lt "$no_sources" ]; do abs_destination_dir="$(cd "$destination_dir" && pwd -P)" # - # FIXME: add mark in 0.6 (and remove if successful later! + # added mark in 0.6 (and remove it, if successful later) # - #touch "${abs_destination_dir}/${c_marker}" + touch "${abs_destination_dir}/${c_marker}" # # the rsync part # options partly stolen from rsnapshot # - echo "$($DDATE) Transferring files..." + _techo "Transferring files..." - ouropts="-a --delete --numeric-ids --relative --delete-excluded" - - # - # FIXME: check, whether this is broken with spaces... - # most likely it should be broken...MUST be... - # expanding depens on shell (zsh = 1, dash = 3 arguments in test case) - # - useropts="$VERBOSE $EXCLUDE $SUMMARY $RSYNC_EXTRA" # # FIXME:useropts / rsync extra: one parameter per line! From 70c62e2514b62c3fd21fa6c882459187784d9635 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 17:03:48 +0200 Subject: [PATCH 114/581] Add add_source.sh --- tools/add_source.sh | 100 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100755 tools/add_source.sh diff --git a/tools/add_source.sh b/tools/add_source.sh new file mode 100755 index 0000000..dc8f05a --- /dev/null +++ b/tools/add_source.sh @@ -0,0 +1,100 @@ +#!/bin/sh +# Nico Schottelius +# 2007-08-16 +# Written for Netstream (www.netstream.ch) +# Creates a source from standard values specified in +# /etc/ccollect/defaults/sources + +# standard values +CCOLLECT_CONF="${CCOLLECT_CONF:-/etc/ccollect}" +CSOURCES="${CCOLLECT_CONF}/sources" +CDEFAULTS="${CCOLLECT_CONF}/defaults" +SCONFIG="${CDEFAULTS}/sources" + +exclude="${SCONFIG}/exclude" +summary="${SCONFIG}/summary" +intervals="${SCONFIG}/intervals" + +pre_exec="${SCONFIG}/pre_exec" +post_exec="${SCONFIG}/post_exec" + +rsync_options="${SCONFIG}/rsync_options" + +verbose="${SCONFIG}/verbose" +vverbose="${SCONFIG}/very_verbose" + +# options that we simply copy over +standard_opts="exclude summary intervals pre_exec post_exec rsync_options verbose very_verbose" + +# options not in standard ccollect, used only for source +# generation +src_prefix="${SCONFIG}/source_prefix" +src_postfix="${SCONFIG}/source_postfix" +destination_base="${SCONFIG}/destination_base" + +self=$(basename $0) + +# functions first +_echo() +{ + echo "${self}> $@" +} + +_exit_err() +{ + _echo "$@" + rm -f "$TMP" + exit 1 +} + +# argv +if [ $# -lt 1 ]; then + _exit_err "" +fi + +while [ $# -gt 0 ]; do + +done + +# create source +# Tests +if [ -e "${fullname}" ]; then + _echo "${fullname} already exists. Aborting." + exit 2 +fi + +# copy standard files + +# create source + +# create destination directory + + +# Create +_echo "Creating ${fullname} ..." +mkdir -p "${fullname}" || exit 3 + +echo "root@${source}:/" > "${fullname}/source" +cat << eof > "${fullname}/exclude" || exit 4 +/dev/* +/proc/* +/tmp/* +eof + +# Destination +if [ -e "${destination}" ]; then + if [ ! -d "${destination}" ]; then + echo "${destination} exists, but is not a directory. Aborting." + exit 5 + fi +else + _echo "Creating ${destination} ..." + mkdir -p "${destination}" || _exit_err "Failed to create ${destination}." +fi + +ln -s "${destination}" "${fullname}/destination" || \ + _exit_err "Failed to link \"${destination}\" to \"${fullname}/destination\"" + +# finish +_echo "Added some default values, please verify \"${fullname}\"." +_echo "Finished." From 54538da003812be9a4f6ec4e42f88f6b26b2cc5a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 17:49:43 +0200 Subject: [PATCH 115/581] Add most functionality to add_source.sh --- tools/add_source.sh | 82 +++++++++++++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 28 deletions(-) diff --git a/tools/add_source.sh b/tools/add_source.sh index dc8f05a..29fdf81 100755 --- a/tools/add_source.sh +++ b/tools/add_source.sh @@ -11,28 +11,25 @@ CSOURCES="${CCOLLECT_CONF}/sources" CDEFAULTS="${CCOLLECT_CONF}/defaults" SCONFIG="${CDEFAULTS}/sources" -exclude="${SCONFIG}/exclude" -summary="${SCONFIG}/summary" -intervals="${SCONFIG}/intervals" - -pre_exec="${SCONFIG}/pre_exec" -post_exec="${SCONFIG}/post_exec" - -rsync_options="${SCONFIG}/rsync_options" - -verbose="${SCONFIG}/verbose" -vverbose="${SCONFIG}/very_verbose" +# standard options: variable2filename +exclude="exclude" +summary="summary" +intervals="intervals" +pre_exec="pre_exec" +post_exec="post_exec" +rsync_options="rsync_options" +verbose="verbose" +very_verbose="very_verbose" # options that we simply copy over standard_opts="exclude summary intervals pre_exec post_exec rsync_options verbose very_verbose" -# options not in standard ccollect, used only for source -# generation +# options not in standard ccollect, used only for source generation src_prefix="${SCONFIG}/source_prefix" src_postfix="${SCONFIG}/source_postfix" destination_base="${SCONFIG}/destination_base" -self=$(basename $0) +self="$(basename $0)" # functions first _echo() @@ -54,25 +51,54 @@ fi while [ $# -gt 0 ]; do + source="$1"; shift + + # Create + _echo "Creating ${source} ..." + + fullname="${CSOURCES}/${source}" + + # create source + if [ -e "${fullname}" ]; then + _echo "${fullname} already exists. Skipping." + continue + fi + mkdir -p "${fullname}" || _exit_err Cannot create \"${fullname}\". + + # copy standard files + for file in $standard_opts; do + eval rfile=\"\$$file\" + echo r: $rfile + eval filename=${SCONFIG}/${rfile} + echo f: $filename + if [ -e "${filename}" ]; then + _echo Copying $rfile for $source ... + cp -r "${filename}" "${fullname}/${rfile}" + fi + done + + # create source entry + if [ -f "${src_prefix}" ]; then + source_source="$(cat "${src_prefix}")" || _exit_err "Reading $src_prefix failed." + fi + source_source="${source_source}${source}" + if [ -f "${src_postfix}" ]; then + source_source="${source_source}$(cat "${src_postfix}")" || _exit_err "Reading $src_postfix failed." + fi + _echo "Adding ${source_source} as source for ${source}" + echo "${source_source}" > "${fullname}/source" + + # create destination directory + dest="${destination_base}/${source}" + _echo "Creating destination ${dest} ..." + mkdir -p "${dest}" || _exit_err "${fullname}: Cannot create ${dest}." + done -# create source -# Tests -if [ -e "${fullname}" ]; then - _echo "${fullname} already exists. Aborting." - exit 2 -fi -# copy standard files - -# create source - -# create destination directory +exit 0 -# Create -_echo "Creating ${fullname} ..." -mkdir -p "${fullname}" || exit 3 echo "root@${source}:/" > "${fullname}/source" cat << eof > "${fullname}/exclude" || exit 4 From 06a9447742af8dc18f498c9a5aba2f4315710501 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 17:50:00 +0200 Subject: [PATCH 116/581] rename --- tools/{add_source.sh => add_ccollect_source.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/{add_source.sh => add_ccollect_source.sh} (100%) diff --git a/tools/add_source.sh b/tools/add_ccollect_source.sh similarity index 100% rename from tools/add_source.sh rename to tools/add_ccollect_source.sh From d7b7bab90e38e6db4f61689cc7b073871b734c9f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 18:36:35 +0200 Subject: [PATCH 117/581] Add delete_ccollect_source.sh --- tools/delete_ccollect_source.sh | 88 +++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100755 tools/delete_ccollect_source.sh diff --git a/tools/delete_ccollect_source.sh b/tools/delete_ccollect_source.sh new file mode 100755 index 0000000..92d118d --- /dev/null +++ b/tools/delete_ccollect_source.sh @@ -0,0 +1,88 @@ +#!/bin/sh +# Nico Schottelius +# 2007-08-16 +# Written for Netstream (www.netstream.ch) +# Creates a source from standard values specified in +# /etc/ccollect/defaults/sources + +# standard values +CCOLLECT_CONF="${CCOLLECT_CONF:-/etc/ccollect}" +CSOURCES="${CCOLLECT_CONF}/sources" + +self="$(basename $0)" + +# functions first +_echo() +{ + echo "${self}> $@" +} + +_exit_err() +{ + _echo "$@" + rm -f "$TMP" + exit 1 +} + +# argv +if [ $# -lt 1 ]; then + _echo "[-f] [-d] " + _echo "-f: Do not ask, simply delete. Dangerous and good for sysadmins." + _echo "-d: Also delete the destination (removes all backups)" + _exit_err "Exiting." +fi + +params_possible=yes +force="" +backups="" + +while [ $# -gt 0 ]; do + source="$1"; shift + + if [ "$params_possible" ]; then + case "$1" in + "-f"|"--force") + force=yes + ;; + "-d"|"--destination") + backups=yes + ;; + *) + _exit_err "Unknown option: $1" + ;; + esac + + shift + fi + + # Reached here? So there are no more parameters. + params_possible="" + + # Create + _echo "Deleting ${source} ..." + fullname="${CSOURCES}/${source}" + + # ask the user per source, if she's not forcing us + if [ -z "$force" ]; then + sure="" + _echo "Do you really want to delete ${source} (y/n)? " + read sure + + if [ "$sure" != "y" ]; then + _echo "Skipping ${source}." + continue + fi + fi + + if [ "$backups" ]; then + ddir=$(cd "${fullname}/destination" && pwd -P) || _exit_err "Cannot change to ${fullname}/destination" + _echo "Deleting ${ddir} ..." + rm -r "${ddir}" + fi + + _echo "Deleting ${fullname} ..." + rm -r "${fullname}" + +done + +exit 0 From b267ae4cc874bf3d38d1ae6972bf8696b80b0c67 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 18:45:20 +0200 Subject: [PATCH 118/581] Finished delete_ccollect_source.sh --- tools/delete_ccollect_source.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tools/delete_ccollect_source.sh b/tools/delete_ccollect_source.sh index 92d118d..81da0f7 100755 --- a/tools/delete_ccollect_source.sh +++ b/tools/delete_ccollect_source.sh @@ -26,9 +26,9 @@ _exit_err() # argv if [ $# -lt 1 ]; then - _echo "[-f] [-d] " - _echo "-f: Do not ask, simply delete. Dangerous and good for sysadmins." - _echo "-d: Also delete the destination (removes all backups)" + _echo "${self} [-f] [-d] " + _echo " -f: Do not ask, simply delete. Dangerous and good for sysadmins." + _echo " -d: Also delete the destination (removes all backups)" _exit_err "Exiting." fi @@ -37,27 +37,33 @@ force="" backups="" while [ $# -gt 0 ]; do - source="$1"; shift if [ "$params_possible" ]; then case "$1" in "-f"|"--force") force=yes + shift; continue ;; "-d"|"--destination") backups=yes + shift; continue ;; - *) + --) + params_possible="" + shift; continue + ;; + -*|--*) _exit_err "Unknown option: $1" ;; esac - shift fi # Reached here? So there are no more parameters. params_possible="" + source="$1"; shift + # Create _echo "Deleting ${source} ..." fullname="${CSOURCES}/${source}" @@ -65,7 +71,7 @@ while [ $# -gt 0 ]; do # ask the user per source, if she's not forcing us if [ -z "$force" ]; then sure="" - _echo "Do you really want to delete ${source} (y/n)? " + echo -n "Do you really want to delete ${source} (y/n)? " read sure if [ "$sure" != "y" ]; then From 560562fbf94dcb7f7c08da33fd0ef49d76d8efc7 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 18:48:41 +0200 Subject: [PATCH 119/581] Add swp files from vim --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c9c33f0..3d731f5 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ doc/man/*.htm doc/man/*.texi doc/man/*.man test/* +.*.swp From e0355023ffd1f8fd53db9d6a4d245fe1784da699 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 18:49:09 +0200 Subject: [PATCH 120/581] Finish add_ccollect_source.sh --- tools/add_ccollect_source.sh | 48 +++++++++--------------------------- 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/tools/add_ccollect_source.sh b/tools/add_ccollect_source.sh index 29fdf81..d9ae8a8 100755 --- a/tools/add_ccollect_source.sh +++ b/tools/add_ccollect_source.sh @@ -49,8 +49,9 @@ if [ $# -lt 1 ]; then _exit_err "" fi -while [ $# -gt 0 ]; do +_echo "Reading defaults from ${SCONFIG} ..." +while [ $# -gt 0 ]; do source="$1"; shift # Create @@ -68,59 +69,34 @@ while [ $# -gt 0 ]; do # copy standard files for file in $standard_opts; do eval rfile=\"\$$file\" - echo r: $rfile eval filename=${SCONFIG}/${rfile} - echo f: $filename if [ -e "${filename}" ]; then - _echo Copying $rfile for $source ... + _echo Copying \"$rfile\" to ${fullname} ... cp -r "${filename}" "${fullname}/${rfile}" fi done # create source entry if [ -f "${src_prefix}" ]; then - source_source="$(cat "${src_prefix}")" || _exit_err "Reading $src_prefix failed." + source_source="$(cat "${src_prefix}")" || _exit_err "${src_prefix}: Reading failed." fi source_source="${source_source}${source}" if [ -f "${src_postfix}" ]; then - source_source="${source_source}$(cat "${src_postfix}")" || _exit_err "Reading $src_postfix failed." + source_source="${source_source}$(cat "${src_postfix}")" || _exit_err "${src_postfix}: Reading failed." fi - _echo "Adding ${source_source} as source for ${source}" + _echo "Adding \"${source_source}\" as source for ${source}" echo "${source_source}" > "${fullname}/source" # create destination directory dest="${destination_base}/${source}" _echo "Creating destination ${dest} ..." - mkdir -p "${dest}" || _exit_err "${fullname}: Cannot create ${dest}." + mkdir -p "${dest}" || _exit_err "${dest}: Cannot create." + + # link destination directory + dest_abs=$(cd "${dest}" && pwd -P) || _exit_err "${dest}: Changing to newly create dirctory failed." + ln -s "${dest_abs}" "${fullname}/destination" || \ + _exit_err "${fullname}/destination: Failed to link \"${dest_abs}\"" done - exit 0 - - - -echo "root@${source}:/" > "${fullname}/source" -cat << eof > "${fullname}/exclude" || exit 4 -/dev/* -/proc/* -/tmp/* -eof - -# Destination -if [ -e "${destination}" ]; then - if [ ! -d "${destination}" ]; then - echo "${destination} exists, but is not a directory. Aborting." - exit 5 - fi -else - _echo "Creating ${destination} ..." - mkdir -p "${destination}" || _exit_err "Failed to create ${destination}." -fi - -ln -s "${destination}" "${fullname}/destination" || \ - _exit_err "Failed to link \"${destination}\" to \"${fullname}/destination\"" - -# finish -_echo "Added some default values, please verify \"${fullname}\"." -_echo "Finished." From 2304d6fe0e4f64e85c15ea8d3a5e2d5dd5817be0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 18:52:59 +0200 Subject: [PATCH 121/581] Changed source on testsystem. --- conf/sources/source with spaces/source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/sources/source with spaces/source b/conf/sources/source with spaces/source index 13f435d..2206a2c 100644 --- a/conf/sources/source with spaces/source +++ b/conf/sources/source with spaces/source @@ -1 +1 @@ -/home/user/nico/projekte/ccollect +/home/user/nico/oeffentlich/computer/projekte/ccollect From 0962090138399cdddc25beb0f3c02bc5eb639d49 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 18:53:37 +0200 Subject: [PATCH 122/581] more todo for me in 0.6 --- doc/todo/0.6 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/todo/0.6 b/doc/todo/0.6 index a1fb24e..818e585 100644 --- a/doc/todo/0.6 +++ b/doc/todo/0.6 @@ -51,4 +51,9 @@ Documentation: source_$n no_sources name +- changed naming of sources: + YYYYMMDD-HHMM.PID (better readable) +config: + set destination-base + /etc/ccollect/defaults/source_config From 5bf9fcb64b63a965d4a6c0a617bd08339ffc6ed0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 19:07:45 +0200 Subject: [PATCH 123/581] more to ignore. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 3d731f5..204b8d5 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ doc/man/*.texi doc/man/*.man test/* .*.swp +doc/man/*.[0-9] +doc/*.xml +doc/*/*.xml From 6a891bc2b8298d29baee229ed2ec562e1f0b87b0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 19:43:37 +0200 Subject: [PATCH 124/581] Add manpage for add_ccollect_source --- doc/man/add_ccollect_source.text | 72 ++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 doc/man/add_ccollect_source.text diff --git a/doc/man/add_ccollect_source.text b/doc/man/add_ccollect_source.text new file mode 100644 index 0000000..1737804 --- /dev/null +++ b/doc/man/add_ccollect_source.text @@ -0,0 +1,72 @@ +add_ccollect_source(1) +====================== +Nico Schottelius + + +NAME +---- +add_ccollect_source - create new source for ccollect(1) + + +SYNOPSIS +-------- + +'add_ccollect_source.sh' + + +DESCRIPTION +----------- +add_ccollect_source.sh creates a new backup source for use with +ccollect(1). It copies the files from to the source directory with the hostname +below $CCOLLECT_CONF/sources. + + +FILES +----- +$CCOLLECT_CONF/defaults/sources:: + Main configuration directory. $CCOLLECT_CONF is '/etc/ccollect', if unset. + All the following files reside below this directory. + +exclude:: +summary:: +intervals:: +pre_exec:: +post_exec:: +rsync_options:: +verbose:: +very_verbose:: + Those are the standard configuration files known by ccollect(1). + If the file exist it will be copied to the newly created source. + Directories ('intervals') are copied recursively. + +destination_base:: + A link to the directory where to store the backups. Below this directory + `add_ccollect_source.sh` will create a directory with the hostname you + specified on the command line. + +source_prefix:: +source_postfix:: + `source_prefix` is put before the hostname, `source_postfix` is appended + after it. A common value for `source_prefix` maybe 'root@' and ':/' + for `source_postfix`. + + +SEE ALSO +-------- +delete_ccollect_source(1), ccollect(1) + + +AUTHOR +------ +Nico Schottelius + + +RESOURCES +--------- +Main web site: http://unix.schottelius.org/ccollect/[] + + +COPYING +------- +Copyright \(C) 2006 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License Version 3 (GPLv3). From 23bc864626af68aa6da047154629ced41aa2f015 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 19:56:42 +0200 Subject: [PATCH 125/581] Minor modifications on manpage --- doc/man/add_ccollect_source.text | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/man/add_ccollect_source.text b/doc/man/add_ccollect_source.text index 1737804..8e5f639 100644 --- a/doc/man/add_ccollect_source.text +++ b/doc/man/add_ccollect_source.text @@ -16,9 +16,9 @@ SYNOPSIS DESCRIPTION ----------- -add_ccollect_source.sh creates a new backup source for use with -ccollect(1). It copies the files from to the source directory with the hostname -below $CCOLLECT_CONF/sources. +add_ccollect_source.sh creates a new backup source for use with ccollect(1). +It copies the files from to the source directory with the hostname below +'$CCOLLECT_CONF/sources'. FILES @@ -53,7 +53,7 @@ source_postfix:: SEE ALSO -------- -delete_ccollect_source(1), ccollect(1) +ccollect(1), delete_ccollect_source(1) AUTHOR @@ -68,5 +68,5 @@ Main web site: http://unix.schottelius.org/ccollect/[] COPYING ------- -Copyright \(C) 2006 Nico Schottelius. Free use of this software is +Copyright \(C) 2007 Nico Schottelius. Free use of this software is granted under the terms of the GNU General Public License Version 3 (GPLv3). From 97c56b247e810a11894d7b6119abad2b20a75b1c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 19:57:00 +0200 Subject: [PATCH 126/581] Add manpage for delete_ccollect_source --- doc/man/delete_ccollect_source.text | 55 +++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 doc/man/delete_ccollect_source.text diff --git a/doc/man/delete_ccollect_source.text b/doc/man/delete_ccollect_source.text new file mode 100644 index 0000000..efd1473 --- /dev/null +++ b/doc/man/delete_ccollect_source.text @@ -0,0 +1,55 @@ +delete_ccollect_source(1) +========================= +Nico Schottelius + + +NAME +---- +delete_ccollect_source - delete sources from ccollect(1) + + +SYNOPSIS +-------- +'add_ccollect_source.sh' [-d] [-f] + + +DESCRIPTION +----------- +delete_ccollect_source.sh deletes backup sources from ccollect(1) and optional +also the backups created for that source. + +OPTIONS +------- +-d: + Delete also the destination directory. `'add_ccollect_source.sh` will change + to the source/'name'/destination directory, get the absolute name and delete + it recursively. +-f: + Force deletion. Do not ask. Very handy for people who know what they do. + Very dangerous for everyone. + + +FILES +----- +$CCOLLECT_CONF/sources:: + Directory containing the sources. $CCOLLECT_CONF is '/etc/ccollect', if unset. + +SEE ALSO +-------- +add_ccollect_source(1), ccollect(1) + + +AUTHOR +------ +Nico Schottelius + + +RESOURCES +--------- +Main web site: http://unix.schottelius.org/ccollect/[] + + +COPYING +------- +Copyright \(C) 2007 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License Version 3 (GPLv3). From bfc637bdb2cfc3be1524ef589e7b83211693d87a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 19:59:54 +0200 Subject: [PATCH 127/581] Update main manpage --- doc/man/ccollect.text | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/doc/man/ccollect.text b/doc/man/ccollect.text index 7682999..9960cd6 100644 --- a/doc/man/ccollect.text +++ b/doc/man/ccollect.text @@ -1,6 +1,6 @@ -ccollect.sh(1) -============== -Nico Schottelius +ccollect(1) +=========== +Nico Schottelius NAME @@ -15,16 +15,16 @@ SYNOPSIS DESCRIPTION ----------- -ccollect is a backup utility written in the sh-scripting language. +`ccollect` is a backup utility written in the sh-scripting language. It does not depend on a specific shell, only `/bin/sh` needs to be bourne shell compatibel (like 'dash', 'ksh', 'zsh', 'bash', ...). -For more information refer to the texinfo or html documentation. +For more information refer to the manual titled +"ccollect - Installing, Configuring and Using" (available as texinfo or html). OPTIONS ------- - -h, --help:: Show the help screen @@ -37,14 +37,9 @@ OPTIONS -v, --verbose:: Be very verbose (uses set -x). -BUGS ----- -None. - - AUTHOR ------ -Nico Schottelius +Nico Schottelius RESOURCES @@ -54,5 +49,5 @@ Main web site: http://unix.schottelius.org/ccollect/[] COPYING ------- -Copyright \(C) 2006 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License (GPL). +Copyright \(C) 2006-2007 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License Version 3 (GPLv3). From 3da1d2a02c30ff294013f0703c8867ac61aca02f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 20:01:45 +0200 Subject: [PATCH 128/581] Updated changes for 0.6. --- doc/CHANGES | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/CHANGES b/doc/CHANGES index 7f39a8c..e5c8b7d 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,9 +1,14 @@ 0.5.2 to 0.6: - * add 'exec-after-rm' (source specific) configuration - * added logwrapper * Always print return code of rsync * Add much more timing information * One option per line in rsync_options now + * Added --sparse as default option + * Added management tools: + * add_ccollect_source.sh + * delete_ccollect_source.sh + + * add 'exec-after-rm' (source specific) configuration + * added logwrapper 0.5.1 to 0.5.2: * Display correct error code, if rsync returns non-zero From 6054ee5369074bc2b24a5ca22c0a51e42ee493d6 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 20:06:26 +0200 Subject: [PATCH 129/581] Tooooooooodooo --- doc/todo/0.6 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/todo/0.6 b/doc/todo/0.6 index 818e585..680dd01 100644 --- a/doc/todo/0.6 +++ b/doc/todo/0.6 @@ -57,3 +57,5 @@ Documentation: config: set destination-base /etc/ccollect/defaults/source_config + +done: From ca6c8f60f85250167569e77193207a5cfbb9cb19 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 20:06:42 +0200 Subject: [PATCH 130/581] Correct header --- tools/delete_ccollect_source.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/delete_ccollect_source.sh b/tools/delete_ccollect_source.sh index 81da0f7..b1acb24 100755 --- a/tools/delete_ccollect_source.sh +++ b/tools/delete_ccollect_source.sh @@ -2,8 +2,7 @@ # Nico Schottelius # 2007-08-16 # Written for Netstream (www.netstream.ch) -# Creates a source from standard values specified in -# /etc/ccollect/defaults/sources +# Delete sources and their backups (optionally). # standard values CCOLLECT_CONF="${CCOLLECT_CONF:-/etc/ccollect}" From 624e5b419b07e46268faca49fb0c32aff2228590 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 20:08:23 +0200 Subject: [PATCH 131/581] Many preparations for 0.6 --- ccollect.sh | 157 ++++++++++++++++++++++++++-------------------------- 1 file changed, 77 insertions(+), 80 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index d3f553b..4eadfbf 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -321,10 +321,10 @@ while [ "$i" -lt "$no_sources" ]; do # destination _must_ be a directory # if [ ! -d "${c_dest}" ]; then - _exit_err "Destination ${c_dest} neither links to nor is a directory. Skipping." + _exit_err "Destination ${c_dest} is not a directory. Skipping." fi - # NEW + # NEW method as of 0.6: # - insert ccollect default parameters # - insert options # - insert user options @@ -333,7 +333,9 @@ while [ "$i" -lt "$no_sources" ]; do # rsync standard options # - ouropts="-a --delete --numeric-ids --relative --delete-excluded" + set -- "$@" "--archive" "--delete" "--numeric-ids" "--relative" \ + "--delete-excluded" "--sparse" + # # exclude list # @@ -366,44 +368,54 @@ while [ "$i" -lt "$no_sources" ]; do done < "${c_rsync_extra}" fi -# # -# # show if we shall remove partial backup, and whether the last one -# # is incomplete or not -# # -# # FIXME: test general for incomplete and decide only for warn|delete based on option? -# # FIXME: Define which is the last dir before? Or put this thing into -# # a while loop? Is it senseful to remove _ALL_ backups if non is complete? -# if [ -f "$c_incomplete" ]; then -# echo "Searching for incomplete backups..." -# 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 ..." -# echo rm -rf $VVERBOSE "$last_dir" -# fi -# fi -# fi -# + # + # Check for incomplete backups + # + ( + set -x + cd "${c_dest}" + ls + ls "${INTERVAL}"*/.ccollect-* > "${TMP}" + cat "${TMP}" + + while read broken; do + realbroken=$(echo $broken | sed 's/.ccollect-*/') + echo "Broken backup" + done + ) + sleep 10 + while read incomplete; do + echo "${incomplete} is incomplete" + done < "${TMP}" + + last_dir=$(ls -d "$c_dest/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1) + # # check if maximum number of backups is reached, if so remove # - # FIXME: really do fuzzy matching here? - # or simply declare "everything of that directory (which is a directory) is - # a ccollect-backiup directory"? - # the created directories are named $INTERVAL-$DATE-$TIME.$PID + # + # Check for backup directory to clone from + # + found_old=0 + ( + # can we use ls? or will it produce broken results? + #cd "${c_dest}" && ls -dp1 | grep "^${INTERVAL}\..*/\$" | wc -l | sed 's/^ *//g') + cd "${c_dest}" && ls -dp1 "${INTERVAL}".* > "${TMP}" + ) + while read old; do + echo "Found ${old}" + done < "${TMP}" + + + # + # Check for backups on other intervals, if we did not find any + # + count=$(cd "${c_dest}" && ls -p1 | grep "^${INTERVAL}\..*/\$" | wc -l | sed 's/^ *//g') # FIXME: check return value - echo -n "Currently ${count} backup(s) exist(s)," - echo " total keeping ${c_interval} backup(s)." + _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" - # STOPPED! if [ "${count}" -ge "${c_interval}" ]; then substract=$((${c_interval} - 1)) remove=$(($count - $substract)) @@ -422,8 +434,6 @@ while [ "$i" -lt "$no_sources" ]; do # clone the old directory with hardlinks # - # FIXME: STOPPED - destination_date=$($CDATE) destination_dir="$c_dest/${INTERVAL}.${destination_date}.$$" @@ -462,55 +472,42 @@ while [ "$i" -lt "$no_sources" ]; do # 0.5.3! # - # Clone from previous backup, if existing - if [ "$last_dir" ]; then - - # - # This directory MUST be absolute, because rsync does chdir() - # before beginning backup! - # - - abs_last_dir="$(cd "$last_dir" && pwd -P)" - if [ -z "$abs_last_dir" ]; then - echo "Changing to the last backup directory failed. Skipping." - exit 1 - fi - - rsync_hardlink="--link-dest=$abs_last_dir" - rsync $ouropts "$rsync_hardlink" $useropts "$source" "$abs_destination_dir" - else - rsync $ouropts $useropts "$source" "$abs_destination_dir" - fi - - ret=$? - - echo "Rsync return code: $ret." + set -x + rsync "$@" "$source" "$abs_destination_dir"; ret=$? + # abs_last_dir="$(cd "$last_dir" && pwd -P)" + # if [ -z "$abs_last_dir" ]; then + # echo "Changing to the last backup directory failed. Skipping." + # exit 1 + # fi + # rsync_hardlink="--link-dest=$abs_last_dir" + set +x if [ "$ret" -ne 0 ]; then echo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." fi # - # FIXME: remove marking here - # rm -f $c_marker + # remove marking here # + rm -f "${abs_destination_dir}/${c_marker}" + + _techo "Finished backup (rsync return code: $ret)." - echo "$($DDATE) Finished backup" # # post_exec # - if [ -x "$c_post_exec" ]; then - echo "$($DDATE) Executing $c_post_exec ..." - "$c_post_exec" - ret=$? - echo "$($DDATE) Finished ${c_post_exec}." + if [ -x "${c_post_exec}" ]; then + _techo "Executing ${c_post_exec} ..." + "${c_post_exec}"; ret=$? + _techo "Finished ${c_post_exec}." - if [ $ret -ne 0 ]; then - echo "$c_post_exec failed." + if [ ${ret} -ne 0 ]; then + _exit_err "${c_post_exec} failed." fi fi + # Calculation end_s=$(date +%s) full_seconds=$((${end_s} - ${begin_s})) @@ -519,7 +516,7 @@ while [ "$i" -lt "$no_sources" ]; do minutes=$(($seconds / 60)) seconds=$((${seconds} - (${minutes} * 60))) - echo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" + _techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" ) | add_name done @@ -527,24 +524,24 @@ done # # Be a good parent and wait for our children, if they are running wild parallel # -if [ "$PARALLEL" ]; then - echo "$($DDATE) Waiting for child jobs to complete..." +if [ "${PARALLEL}" ]; then + _techo "Waiting for child jobs to complete..." wait fi # # Look for post-exec command (general) # -if [ -x "$CPOSTEXEC" ]; then - echo "$($DDATE) Executing $CPOSTEXEC ..." - "$CPOSTEXEC" +if [ -x "${CPOSTEXEC}" ]; then + _techo "Executing ${CPOSTEXEC} ..." + "${CPOSTEXEC}" ret=$? - echo "$($DDATE) Finished ${CPOSTEXEC}." + _techo "Finished ${CPOSTEXEC}." - if [ $ret -ne 0 ]; then - echo "$CPOSTEXEC failed." + if [ ${ret} -ne 0 ]; then + echo "${CPOSTEXEC} failed." fi fi -rm -f "$TMP" -echo "==> Finished $WE <==" +rm -f "${TMP}" +_techo "Finished ${WE}" From 799c24faf3d6f0602716ca796acbf61b31b6cc4b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 20:17:54 +0200 Subject: [PATCH 132/581] Many formal cleanups --- ccollect.sh | 64 ++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 4eadfbf..3920688 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -8,22 +8,22 @@ # where to find our configuration and temporary file # CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} -CSOURCES=$CCOLLECT_CONF/sources -CDEFAULTS=$CCOLLECT_CONF/defaults -CPREEXEC="$CDEFAULTS/pre_exec" -CPOSTEXEC="$CDEFAULTS/post_exec" +CSOURCES=${CCOLLECT_CONF}/sources +CDEFAULTS=${CCOLLECT_CONF}/defaults +CPREEXEC="${CDEFAULTS}/pre_exec" +CPOSTEXEC="${CDEFAULTS}/post_exec" -TMP=$(mktemp /tmp/$(basename $0).XXXXXX) +TMP=$(mktemp "/tmp/$(basename $0).XXXXXX") VERSION=0.6 -RELEASE="2007-XX-XX" -HALF_VERSION="ccollect $VERSION" -FULL_VERSION="ccollect $VERSION ($RELEASE)" +RELEASE="2007-08-16/17" +HALF_VERSION="ccollect ${VERSION}" +FULL_VERSION="ccollect ${VERSION} (${RELEASE})" # # CDATE: how we use it for naming of the archives # DDATE: how the user should see it in our output (DISPLAY) # -CDATE="date +%Y-%m-%d-%H%M" +CDATE="date +%Y%m%d-%H%M" DDATE="date +%Y-%m-%d-%H:%M:%S" # @@ -34,7 +34,7 @@ PARALLEL="" # # catch signals # -trap "rm -f \"$TMP\"" 1 2 15 +trap "rm -f \"${TMP}\"" 1 2 15 # # Functions @@ -43,20 +43,20 @@ trap "rm -f \"$TMP\"" 1 2 15 # time displaying echo _techo() { - echo "$(${DDATE}): $@" + echo "$(${DDATE}): " "$@" } # exit on error _exit_err() { _techo "$@" - rm -f "$TMP" + rm -f "${TMP}" exit 1 } add_name() { - sed "s:^:\[$name\] :" + sed "s:^:\[${name}\] :" } # @@ -91,7 +91,7 @@ fi # check for configuraton directory # [ -d "${CCOLLECT_CONF}" ] || _exit_err "No configuration found in " \ - "\"$CCOLLECT_CONF\" (is \$CCOLLECT_CONF properly set?)" + "\"${CCOLLECT_CONF}\" (is \$CCOLLECT_CONF properly set?)" # # Filter arguments @@ -106,14 +106,14 @@ no_sources=0 while [ "$#" -ge 1 ]; do eval arg=\"\$1\"; shift - if [ "$NO_MORE_ARGS" = 1 ]; then - eval source_${no_sources}=\"$arg\" - no_sources=$(($no_sources+1)) + if [ "${NO_MORE_ARGS}" = 1 ]; then + eval source_${no_sources}=\"${arg}\" + no_sources=$((${no_sources}+1)) # make variable available for subscripts eval export source_${no_sources} else - case "$arg" in + case "${arg}" in -a|--all) ALL=1 ;; @@ -145,14 +145,14 @@ export no_sources # # be really, really, really verbose # -if [ "$VERBOSE" = 1 ]; then +if [ "${VERBOSE}" = 1 ]; then set -x fi # # Look, if we should take ALL sources # -if [ "$ALL" = 1 ]; then +if [ "${ALL}" = 1 ]; then # reset everything specified before no_sources=0 @@ -165,8 +165,8 @@ if [ "$ALL" = 1 ]; then [ "${ret}" -eq 0 ] || _exit_err "Listing of sources failed. Aborting." while read tmp; do - eval source_${no_sources}=\"$tmp\" - no_sources=$(($no_sources+1)) + eval source_${no_sources}=\"${tmp}\" + no_sources=$((${no_sources}+1)) done < "${TMP}" fi @@ -183,12 +183,12 @@ fi # Look for pre-exec command (general) # if [ -x "${CPREEXEC}" ]; then - echo "Executing ${CPREEXEC} ..." + _techo "Executing ${CPREEXEC} ..." "${CPREEXEC}"; ret=$? - echo "Finished ${CPREEXEC}." + _techo "Finished ${CPREEXEC}." [ "${ret}" -eq 0 ] || _exit_err "${CPREEXEC} exited with return code ${ret}" \ - ", aborting backup." + ", aborting backup." fi # @@ -203,13 +203,13 @@ D_INTERVAL=$(cat "${D_FILE_INTERVAL}" 2>/dev/null) # Let's do the backup # i=0 -while [ "$i" -lt "$no_sources" ]; do +while [ "${i}" -lt "${no_sources}" ]; do # # Get current source # eval name=\"\$source_${i}\" - i=$(($i+1)) + i=$((${i}+1)) export name @@ -266,16 +266,14 @@ while [ "$i" -lt "$no_sources" ]; do # Standard configuration checks # if [ ! -e "${backup}" ]; then - _techo "Source does not exist." - exit 1 + _exit_err "Source does not exist." fi # # configuration _must_ be a directory # if [ ! -d "${backup}" ]; then - _techo "\"${name}\" is not a cconfig-directory. Skipping." - exit 1 + _exit_err "\"${name}\" is not a cconfig-directory. Skipping." fi # @@ -340,7 +338,7 @@ while [ "$i" -lt "$no_sources" ]; do # exclude list # if [ -f "${c_exclude}" ]; then - set -- "$@" "--exclude-from=$c_exclude" + set -- "$@" "--exclude-from=${c_exclude}" fi # @@ -388,7 +386,7 @@ while [ "$i" -lt "$no_sources" ]; do echo "${incomplete} is incomplete" done < "${TMP}" - last_dir=$(ls -d "$c_dest/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1) + last_dir=$(ls -d "${c_dest}/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1) # # check if maximum number of backups is reached, if so remove From 8f6a942ae912491716386cf18bb80a38e4ea424a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 20:31:30 +0200 Subject: [PATCH 133/581] Finish incomplete deletion in general --- ccollect.sh | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 3920688..bcb32a4 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -43,7 +43,7 @@ trap "rm -f \"${TMP}\"" 1 2 15 # time displaying echo _techo() { - echo "$(${DDATE}): " "$@" + echo "$(${DDATE}): $@" } # exit on error @@ -243,12 +243,16 @@ while [ "${i}" -lt "${no_sources}" ]; do c_summary="${backup}/summary" c_pre_exec="${backup}/pre_exec" c_post_exec="${backup}/post_exec" - c_incomplete="$backup/delete_incomplete" + c_incomplete="${backup}/delete_incomplete" + + # + # Marking backups: If we abort it's not removed => Backup is broken + # + c_marker=".ccollect-marker" # # Times # - c_marker=".ccollect-$(${CDATE}).$$" begin_s=$(date +%s) # @@ -259,6 +263,7 @@ while [ "${i}" -lt "${no_sources}" ]; do SUMMARY="" VERBOSE="" VVERBOSE="" + DELETE_INCOMPLETE="" _techo "Beginning to backup" @@ -322,6 +327,16 @@ while [ "${i}" -lt "${no_sources}" ]; do _exit_err "Destination ${c_dest} is not a directory. Skipping." fi + # + # Check whether to delete incomplete backups + # + if [ -f "${c_incomplete}" ]; then + DELETE_INCOMPLETE="yes" + fi + + # + # Verbosity for rsync + # NEW method as of 0.6: # - insert ccollect default parameters # - insert options @@ -372,14 +387,20 @@ while [ "${i}" -lt "${no_sources}" ]; do ( set -x cd "${c_dest}" - ls - ls "${INTERVAL}"*/.ccollect-* > "${TMP}" + # one column output to ${TMP} + ls -1 "${INTERVAL}"*/${c_marker} > "${TMP}" + + # FIXME: debug cat "${TMP}" - while read broken; do - realbroken=$(echo $broken | sed 's/.ccollect-*/') - echo "Broken backup" - done + while read incomplete; do + realincomplete=$(echo ${incomplete} | sed "s/${c_marker}\$//") + _techo "Incomplete backup: ${realincomplete}" + if [ "$DELETE_INCOMPLETE" = "yes" ]; then + _techo "Deleting ${realincomplete}" + echo rm $VVERBOSE -rf "${realincomplete}" + fi + done < "${TMP}" ) sleep 10 while read incomplete; do From 45c5c29f774ff06244180015f35b9265f880d8da Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 20:41:03 +0200 Subject: [PATCH 134/581] Cleaned up old remove code --- ccollect.sh | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index bcb32a4..e298326 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -385,6 +385,8 @@ while [ "${i}" -lt "${no_sources}" ]; do # Check for incomplete backups # ( + set -e + # FIXME: debug set -x cd "${c_dest}" # one column output to ${TMP} @@ -401,18 +403,36 @@ while [ "${i}" -lt "${no_sources}" ]; do echo rm $VVERBOSE -rf "${realincomplete}" fi done < "${TMP}" - ) - sleep 10 - while read incomplete; do - echo "${incomplete} is incomplete" - done < "${TMP}" - - last_dir=$(ls -d "${c_dest}/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1) + ) || _exit_err "Searching for incomplete backups failed." # # check if maximum number of backups is reached, if so remove # + # use grep and ls -p so we only look at directories + count=$(cd "${c_dest}" && ls -p1 | grep "^${INTERVAL}\..*/\$" | wc -l \ + | sed 's/^ *//g') || _exit_err "Counting backups failed" + + _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" + + if [ "${count}" -ge "${c_interval}" ]; then + substract=$((${c_interval} - 1)) + remove=$((${count} - ${substract})) + echo "Removing ${remove} backup(s)..." + + ( + set -e + cd "${c_dest}" + ls -p1 | grep "^${INTERVAL}\..*/\$" | sort -n | head -n "${remove}" > "${TMP}" + + while read to_remove; do + _techo "Removing ${to_remove} ..." + rm $VVERBOSE -rf "$to_remove" + done < "${TMP}" + ) || _exit_err " + fi + + #last_dir=$(ls -d "${c_dest}/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1) # # Check for backup directory to clone from # @@ -426,29 +446,10 @@ while [ "${i}" -lt "${no_sources}" ]; do echo "Found ${old}" done < "${TMP}" - # # Check for backups on other intervals, if we did not find any # - count=$(cd "${c_dest}" && ls -p1 | grep "^${INTERVAL}\..*/\$" | wc -l | sed 's/^ *//g') - # FIXME: check return value - _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" - - if [ "${count}" -ge "${c_interval}" ]; then - substract=$((${c_interval} - 1)) - remove=$(($count - $substract)) - echo "Removing $remove backup(s)..." - - ls -d "$c_dest/${INTERVAL}."?* | sort -n | head -n "$remove" > "$TMP" - #( cd "$c_dest" && ls -p1 | grep "^${INTERVAL}\..*/\$" | sort -n | head -n $remove > "$TMP" - while read to_remove; do - dir="$to_remove" - echo "Removing $dir ..." - rm $VVERBOSE -rf "$dir" - done < "$TMP" - fi - # # clone the old directory with hardlinks # From 11a2b5a6ba5f1d74fb0924d15d9ede3930e87681 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 20:58:53 +0200 Subject: [PATCH 135/581] things todo for 0.6.1 --- doc/todo/0.6.1 | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 doc/todo/0.6.1 diff --git a/doc/todo/0.6.1 b/doc/todo/0.6.1 new file mode 100644 index 0000000..1b19bc0 --- /dev/null +++ b/doc/todo/0.6.1 @@ -0,0 +1,4 @@ +- Improve finding backup from another interval: + o strip of interval name + o run sort -n + o use the last entry From 86960388df9f6fb882fa87b9c0dc87ba1f752682 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 21:11:13 +0200 Subject: [PATCH 136/581] Added initial support for cloning from different intervals --- ccollect.sh | 75 ++++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index e298326..007bca4 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -405,11 +405,11 @@ while [ "${i}" -lt "${no_sources}" ]; do done < "${TMP}" ) || _exit_err "Searching for incomplete backups failed." + # # check if maximum number of backups is reached, if so remove - # - # use grep and ls -p so we only look at directories + # count=$(cd "${c_dest}" && ls -p1 | grep "^${INTERVAL}\..*/\$" | wc -l \ | sed 's/^ *//g') || _exit_err "Counting backups failed" @@ -427,46 +427,51 @@ while [ "${i}" -lt "${no_sources}" ]; do while read to_remove; do _techo "Removing ${to_remove} ..." - rm $VVERBOSE -rf "$to_remove" + # FIXME DEBUG + echo rm $VVERBOSE -rf "$to_remove" done < "${TMP}" - ) || _exit_err " + ) || _exit_err "Problem removing old backups" fi - #last_dir=$(ls -d "${c_dest}/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1) + # # Check for backup directory to clone from # - found_old=0 - ( - # can we use ls? or will it produce broken results? - #cd "${c_dest}" && ls -dp1 | grep "^${INTERVAL}\..*/\$" | wc -l | sed 's/^ *//g') - cd "${c_dest}" && ls -dp1 "${INTERVAL}".* > "${TMP}" - ) - while read old; do - echo "Found ${old}" - done < "${TMP}" - # - # Check for backups on other intervals, if we did not find any - # + # try our interval + set -x + last_dir="$(ls -d "${c_dest}/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1)" + + # try other intervals, if there's none four our interval + if [ -z "${last_dir}" ]; then + _techo "Did not find existing backups for interval ${INTERVAL}." - # - # clone the old directory with hardlinks - # + # get list + : > "${TMP}" + ( cd "${backup}/intervals/" 2>/dev/null && ls >> "${TMP}" ) + ( cd "${CDEFAULTS}/intervals/" 2>/dev/null && ls >> "${TMP}" ) - destination_date=$($CDATE) - destination_dir="$c_dest/${INTERVAL}.${destination_date}.$$" - # - # FIXME: In 0.6 add search for the latest available backup! - # - last_dir=$(ls -d "$c_dest/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1) + + # FIXME in 0.6.1: choose best source, not first one. + while read other_interval; do + last_dir="$(ls -d "${c_dest}/${other_interval}."?* 2>/dev/null | sort -n | tail -n 1)" + if [ "${last_dir}" ]; then + _techo "Using backup from ${other_interval}." + break + fi + done < "${TMP}" + fi + + # set time when we really begin to backup, not when we began to remove above + destination_date=$(${CDATE}) + destination_dir="${c_dest}/${INTERVAL}.${destination_date}.$$" # give some info - echo "Beginning to backup, this may take some time..." + _techo "Beginning to backup, this may take some time..." - echo "Creating $destination_dir ..." - mkdir $VVERBOSE "$destination_dir" || \ + echo "Creating ${destination_dir} ..." + mkdir ${VVERBOSE} "${destination_dir}" || \ _exit_err "Creating $destination_dir failed. Skipping." # @@ -493,7 +498,8 @@ while [ "${i}" -lt "${no_sources}" ]; do # set -x - rsync "$@" "$source" "$abs_destination_dir"; ret=$? + rsync "$@" "${source}" "${abs_destination_dir}"; ret=$? + # abs_last_dir="$(cd "$last_dir" && pwd -P)" # if [ -z "$abs_last_dir" ]; then # echo "Changing to the last backup directory failed. Skipping." @@ -501,18 +507,15 @@ while [ "${i}" -lt "${no_sources}" ]; do # fi # rsync_hardlink="--link-dest=$abs_last_dir" - set +x - if [ "$ret" -ne 0 ]; then - echo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." - fi - # # remove marking here # rm -f "${abs_destination_dir}/${c_marker}" _techo "Finished backup (rsync return code: $ret)." - + if [ "$ret" -ne 0 ]; then + _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." + fi # # post_exec From a35e31e86c338bd3caaf9f2883b28d22546cc7c1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 21:17:25 +0200 Subject: [PATCH 137/581] In theory ccollect-0.6 is ready, now let's begin testing --- ccollect.sh | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 007bca4..3a1e580 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -463,24 +463,32 @@ while [ "${i}" -lt "${no_sources}" ]; do done < "${TMP}" fi + # + # add old backup if existing + # + if [ "${last_dir}" ]; then + abs_last_dir="$(cd "${last_dir}" && pwd -P)" || _exit_err "Could not change to last dir ${last_dir}." + set -- "$@" "--link-dest=${abs_last_dir}" + fi + + # set time when we really begin to backup, not when we began to remove above destination_date=$(${CDATE}) destination_dir="${c_dest}/${INTERVAL}.${destination_date}.$$" + # give some info _techo "Beginning to backup, this may take some time..." echo "Creating ${destination_dir} ..." mkdir ${VVERBOSE} "${destination_dir}" || \ - _exit_err "Creating $destination_dir failed. Skipping." + _exit_err "Creating ${destination_dir} failed. Skipping." + + # absulte now, it's existing + abs_destination_dir="$(cd "${destination_dir}" && pwd -P)" # - # make an absolute path, perhaps $CCOLLECT_CONF is relative! - # - abs_destination_dir="$(cd "$destination_dir" && pwd -P)" - - # - # added mark in 0.6 (and remove it, if successful later) + # added marking in 0.6 (and remove it, if successful later) # touch "${abs_destination_dir}/${c_marker}" @@ -491,22 +499,9 @@ while [ "${i}" -lt "${no_sources}" ]; do _techo "Transferring files..." - - # - # FIXME:useropts / rsync extra: one parameter per line! - # 0.5.3! - # - set -x rsync "$@" "${source}" "${abs_destination_dir}"; ret=$? - # abs_last_dir="$(cd "$last_dir" && pwd -P)" - # if [ -z "$abs_last_dir" ]; then - # echo "Changing to the last backup directory failed. Skipping." - # exit 1 - # fi - # rsync_hardlink="--link-dest=$abs_last_dir" - # # remove marking here # @@ -534,9 +529,9 @@ while [ "${i}" -lt "${no_sources}" ]; do end_s=$(date +%s) full_seconds=$((${end_s} - ${begin_s})) - hours=$(($full_seconds / 3600)) - seconds=$(($full_seconds - ($hours * 3600))) - minutes=$(($seconds / 60)) + hours=$((${full_seconds} / 3600)) + seconds=$((${full_seconds} - (${hours} * 3600))) + minutes=$((${seconds} / 60)) seconds=$((${seconds} - (${minutes} * 60))) _techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" From e2a143e0b623e9dd5d26adedd9d59ea7cff48b13 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 21:25:46 +0200 Subject: [PATCH 138/581] Some cleanups --- ccollect.sh | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 3a1e580..271a82d 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -384,26 +384,19 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Check for incomplete backups # - ( - set -e - # FIXME: debug - set -x - cd "${c_dest}" - # one column output to ${TMP} - ls -1 "${INTERVAL}"*/${c_marker} > "${TMP}" + ( cd "${c_dest}" 2>/dev/null && ls -1 "${INTERVAL}"*/${c_marker} > "${TMP}" 2>/dev/null) - # FIXME: debug - cat "${TMP}" + # FIXME: debug + cat "${TMP}" - while read incomplete; do - realincomplete=$(echo ${incomplete} | sed "s/${c_marker}\$//") - _techo "Incomplete backup: ${realincomplete}" - if [ "$DELETE_INCOMPLETE" = "yes" ]; then - _techo "Deleting ${realincomplete}" - echo rm $VVERBOSE -rf "${realincomplete}" - fi - done < "${TMP}" - ) || _exit_err "Searching for incomplete backups failed." + while read incomplete; do + realincomplete=$(echo ${incomplete} | sed "s/${c_marker}\$//") + _techo "Incomplete backup: ${realincomplete}" + if [ "${DELETE_INCOMPLETE}" = "yes" ]; then + _techo "Deleting ${realincomplete} ..." + rm $VVERBOSE -rf "${c_dest}/${realincomplete}" + fi + done < "${TMP}" # @@ -441,6 +434,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # try our interval set -x last_dir="$(ls -d "${c_dest}/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1)" + set +x # try other intervals, if there's none four our interval if [ -z "${last_dir}" ]; then @@ -501,6 +495,7 @@ while [ "${i}" -lt "${no_sources}" ]; do set -x rsync "$@" "${source}" "${abs_destination_dir}"; ret=$? + set +x # # remove marking here From dc28b25e3cce10c9eeee8bc76c33b992cce48071 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 21:26:56 +0200 Subject: [PATCH 139/581] use _techo, not echo --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index 271a82d..031914e 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -411,7 +411,7 @@ while [ "${i}" -lt "${no_sources}" ]; do if [ "${count}" -ge "${c_interval}" ]; then substract=$((${c_interval} - 1)) remove=$((${count} - ${substract})) - echo "Removing ${remove} backup(s)..." + _techo "Removing ${remove} backup(s)..." ( set -e From 8f65880db5bc5f0161d46756b5ffa6ed8edea47e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 21:37:39 +0200 Subject: [PATCH 140/581] Cleanups, cleanups, cleanups, ... --- ccollect.sh | 52 +++++++++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 031914e..4a0b8d1 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -185,10 +185,9 @@ fi if [ -x "${CPREEXEC}" ]; then _techo "Executing ${CPREEXEC} ..." "${CPREEXEC}"; ret=$? - _techo "Finished ${CPREEXEC}." + _techo "Finished ${CPREEXEC} (return code: ${ret})." - [ "${ret}" -eq 0 ] || _exit_err "${CPREEXEC} exited with return code ${ret}" \ - ", aborting backup." + [ "${ret}" -eq 0 ] || _exit_err "${CPREEXEC} failed. Aborting" fi # @@ -384,17 +383,15 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Check for incomplete backups # - ( cd "${c_dest}" 2>/dev/null && ls -1 "${INTERVAL}"*/${c_marker} > "${TMP}" 2>/dev/null) - - # FIXME: debug - cat "${TMP}" + ( cd "${c_dest}" 2>/dev/null && ls -1 "${INTERVAL}"*"/${c_marker}" > "${TMP}" 2>/dev/null) while read incomplete; do realincomplete=$(echo ${incomplete} | sed "s/${c_marker}\$//") _techo "Incomplete backup: ${realincomplete}" if [ "${DELETE_INCOMPLETE}" = "yes" ]; then _techo "Deleting ${realincomplete} ..." - rm $VVERBOSE -rf "${c_dest}/${realincomplete}" + rm $VVERBOSE -rf "${c_dest}/${realincomplete}" || \ + _exit_err "Removing ${c_dest}/${realincomplete} failed." fi done < "${TMP}" @@ -413,17 +410,14 @@ while [ "${i}" -lt "${no_sources}" ]; do remove=$((${count} - ${substract})) _techo "Removing ${remove} backup(s)..." - ( - set -e - cd "${c_dest}" - ls -p1 | grep "^${INTERVAL}\..*/\$" | sort -n | head -n "${remove}" > "${TMP}" + ( cd "${c_dest}" 2>/dev/null && ls -p1 | grep "^${INTERVAL}\..*/\$" | \ + sort -n | head -n "${remove}" > "${TMP}" ) - while read to_remove; do - _techo "Removing ${to_remove} ..." - # FIXME DEBUG - echo rm $VVERBOSE -rf "$to_remove" - done < "${TMP}" - ) || _exit_err "Problem removing old backups" + while read to_remove; do + _techo "Removing ${to_remove} ..." + rm ${VVERBOSE} -rf "$to_remove" || \ + _exit_err "Removing ${to_remove} failed." + done < "${TMP}" fi @@ -432,9 +426,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # # try our interval - set -x last_dir="$(ls -d "${c_dest}/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1)" - set +x # try other intervals, if there's none four our interval if [ -z "${last_dir}" ]; then @@ -445,8 +437,6 @@ while [ "${i}" -lt "${no_sources}" ]; do ( cd "${backup}/intervals/" 2>/dev/null && ls >> "${TMP}" ) ( cd "${CDEFAULTS}/intervals/" 2>/dev/null && ls >> "${TMP}" ) - - # FIXME in 0.6.1: choose best source, not first one. while read other_interval; do last_dir="$(ls -d "${c_dest}/${other_interval}."?* 2>/dev/null | sort -n | tail -n 1)" @@ -458,7 +448,7 @@ while [ "${i}" -lt "${no_sources}" ]; do fi # - # add old backup if existing + # clone from old backup, if existing # if [ "${last_dir}" ]; then abs_last_dir="$(cd "${last_dir}" && pwd -P)" || _exit_err "Could not change to last dir ${last_dir}." @@ -470,7 +460,6 @@ while [ "${i}" -lt "${no_sources}" ]; do destination_date=$(${CDATE}) destination_dir="${c_dest}/${INTERVAL}.${destination_date}.$$" - # give some info _techo "Beginning to backup, this may take some time..." @@ -492,15 +481,13 @@ while [ "${i}" -lt "${no_sources}" ]; do # _techo "Transferring files..." - - set -x rsync "$@" "${source}" "${abs_destination_dir}"; ret=$? - set +x # # remove marking here # - rm -f "${abs_destination_dir}/${c_marker}" + rm -f "${abs_destination_dir}/${c_marker}" || \ + _exit_err "Removing ${abs_destination_dir}/${c_marker} failed." _techo "Finished backup (rsync return code: $ret)." if [ "$ret" -ne 0 ]; then @@ -538,7 +525,7 @@ done # Be a good parent and wait for our children, if they are running wild parallel # if [ "${PARALLEL}" ]; then - _techo "Waiting for child jobs to complete..." + _techo "Waiting for children to complete..." wait fi @@ -547,12 +534,11 @@ fi # if [ -x "${CPOSTEXEC}" ]; then _techo "Executing ${CPOSTEXEC} ..." - "${CPOSTEXEC}" - ret=$? - _techo "Finished ${CPOSTEXEC}." + "${CPOSTEXEC}"; ret=$? + _techo "Finished ${CPOSTEXEC} (return code: ${ret})." if [ ${ret} -ne 0 ]; then - echo "${CPOSTEXEC} failed." + _echo "${CPOSTEXEC} failed." fi fi From 43ca90a2f20561284dd0b3b73c0566c1d6627bec Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 21:38:51 +0200 Subject: [PATCH 141/581] Update changes for 0.6 --- doc/CHANGES | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/doc/CHANGES b/doc/CHANGES index e5c8b7d..332804d 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,15 +1,12 @@ 0.5.2 to 0.6: * Always print return code of rsync * Add much more timing information - * One option per line in rsync_options now + * One option per line in rsync_options now (NOT space seperated) * Added --sparse as default option - * Added management tools: + * Added management tools (including manpages): * add_ccollect_source.sh * delete_ccollect_source.sh - * add 'exec-after-rm' (source specific) configuration - * added logwrapper - 0.5.1 to 0.5.2: * Display correct error code, if rsync returns non-zero * Unify messages From 27d9e2e429df099baa3739ce1dd08163ef57e9f3 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 21:39:54 +0200 Subject: [PATCH 142/581] Update todos - part 1 --- doc/todo/0.5.3 | 4 +++- doc/todo/0.6 | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/todo/0.5.3 b/doc/todo/0.5.3 index 411904d..4a20e5e 100644 --- a/doc/todo/0.5.3 +++ b/doc/todo/0.5.3 @@ -1,7 +1,6 @@ - check and export variables for use in scripts! - documentation * -F / --filter for rsync - * integrate updated german documentation X join todos - fix possible quoting problems * rsync_extra (redefine format) @@ -17,3 +16,6 @@ X join todos -> tonnerre / #cLinux Done: + +Contact Julian later: + * integrate updated german documentation diff --git a/doc/todo/0.6 b/doc/todo/0.6 index 680dd01..07993ee 100644 --- a/doc/todo/0.6 +++ b/doc/todo/0.6 @@ -53,9 +53,13 @@ Documentation: name - changed naming of sources: YYYYMMDD-HHMM.PID (better readable) + => source / backup converter! => not needed! +- delete_incomplete config: set destination-base /etc/ccollect/defaults/source_config + done: + From aaf29c92b542d01217a269d9a754520e2156715d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 21:45:02 +0200 Subject: [PATCH 143/581] another case for _techo --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index 4a0b8d1..c5ab5b1 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -463,7 +463,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # give some info _techo "Beginning to backup, this may take some time..." - echo "Creating ${destination_dir} ..." + _techo "Creating ${destination_dir} ..." mkdir ${VVERBOSE} "${destination_dir}" || \ _exit_err "Creating ${destination_dir} failed. Skipping." From 88c295a5b7a54e3b1e2c2cb37938a5b8cb1a42e9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 21:46:02 +0200 Subject: [PATCH 144/581] typo --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index c5ab5b1..d1d1c5c 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -538,7 +538,7 @@ if [ -x "${CPOSTEXEC}" ]; then _techo "Finished ${CPOSTEXEC} (return code: ${ret})." if [ ${ret} -ne 0 ]; then - _echo "${CPOSTEXEC} failed." + _techo "${CPOSTEXEC} failed." fi fi From d87d1616e61b51d3804a884c79efa84dc32f714e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 22:21:56 +0200 Subject: [PATCH 145/581] Upgrade to GPLv3 --- COPYING | 427 +++++++++++++++++--------------------------------------- 1 file changed, 126 insertions(+), 301 deletions(-) diff --git a/COPYING b/COPYING index 3912109..fc8a5de 100644 --- a/COPYING +++ b/COPYING @@ -1,340 +1,165 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. + 0. Additional Definitions. - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". + 1. Exception to Section 3 of the GNU GPL. -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. + 2. Conveying Modified Versions. -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. + 3. Object Code Incorporating Material from Library Header Files. - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. + b) Accompany the object code with a copy of the GNU GPL and this license + document. - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: + 4. Combined Works. - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. + d) Do one of the following: - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. + 5. Combined Libraries. -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. + 6. Revised Versions of the GNU Lesser General Public License. - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. - NO WARRANTY + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. From 951a88c7369966ebba4813a64f82c4419ba46c66 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 22:23:33 +0200 Subject: [PATCH 146/581] Change license to GPLv3 --- doc/CHANGES | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/CHANGES b/doc/CHANGES index 332804d..4737306 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -6,6 +6,7 @@ * Added management tools (including manpages): * add_ccollect_source.sh * delete_ccollect_source.sh + * Changed license to GPLv3 (from GPLv2) 0.5.1 to 0.5.2: * Display correct error code, if rsync returns non-zero From 39c4e83fbc1b274ecef81d66abed12ac9437f831 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 22:27:01 +0200 Subject: [PATCH 147/581] Add master script to update configuration --- tools/config-pre-0.6-to-0.6.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 tools/config-pre-0.6-to-0.6.sh diff --git a/tools/config-pre-0.6-to-0.6.sh b/tools/config-pre-0.6-to-0.6.sh new file mode 100755 index 0000000..3f4c876 --- /dev/null +++ b/tools/config-pre-0.6-to-0.6.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# Nico Schottelius, 20070816-2225 +# Transfer configuration to 0.6 layout +# Copying: GPLv3 +# + +if [ $# -ne 1 ]; then + echo "$0: ccollect-configuration directory" + echo "" + echo " Fix pre 0.6 configuration directories to match 0.6 style" + echo "" + exit 23 +fi + +dir="$1" +script=$(echo $0 | sed 's/\.sh$/.sub.sh/') + +find "${dir}/sources/" -name rsync_options -exec "${skript}" {} \; From 967613b4c54d05dfd9fcfb6df3b1be49f64fcd15 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 22:30:02 +0200 Subject: [PATCH 148/581] Add subscript --- tools/config-pre-0.6-to-0.6.sub.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 tools/config-pre-0.6-to-0.6.sub.sh diff --git a/tools/config-pre-0.6-to-0.6.sub.sh b/tools/config-pre-0.6-to-0.6.sub.sh new file mode 100755 index 0000000..dde17cf --- /dev/null +++ b/tools/config-pre-0.6-to-0.6.sub.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# Nico Schottelius, 20070816-2227 +# Transfer configuration to 0.6 layout (subscript) +# Copying: GPLv3 +# + +if [ $# -ne 1 ]; then + echo "$0: rsync_options file" + echo "" + echo " Fix pre 0.6 configuration directories to match 0.6 style (sub)" + echo "" + exit 23 +fi + +tmp=$(mktemp) + +for option in $(cat "$1"); do + echo "${option}" >> "${tmp}" +done +mv ${tmp} "$1" From db5bd32b3b55a2704e050c5b157cdf560132440b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 22:34:39 +0200 Subject: [PATCH 149/581] Finish convert scripts --- tools/config-pre-0.6-to-0.6.sh | 4 +++- tools/config-pre-0.6-to-0.6.sub.sh | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/config-pre-0.6-to-0.6.sh b/tools/config-pre-0.6-to-0.6.sh index 3f4c876..5efce68 100755 --- a/tools/config-pre-0.6-to-0.6.sh +++ b/tools/config-pre-0.6-to-0.6.sh @@ -15,4 +15,6 @@ fi dir="$1" script=$(echo $0 | sed 's/\.sh$/.sub.sh/') -find "${dir}/sources/" -name rsync_options -exec "${skript}" {} \; +find "${dir}/sources/" -type f -name rsync_options -exec "${script}" {} \; + +echo "Finished." diff --git a/tools/config-pre-0.6-to-0.6.sub.sh b/tools/config-pre-0.6-to-0.6.sub.sh index dde17cf..b4e0bd3 100755 --- a/tools/config-pre-0.6-to-0.6.sub.sh +++ b/tools/config-pre-0.6-to-0.6.sub.sh @@ -14,6 +14,8 @@ fi tmp=$(mktemp) +echo "Working on $1 ..." + for option in $(cat "$1"); do echo "${option}" >> "${tmp}" done From 326dbc52e3e65912077c247f5fb7002a4bb27b5e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 22:40:19 +0200 Subject: [PATCH 150/581] Add incompatibilties --- doc/ccollect.text | 69 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 19 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 09b86a4..4755a75 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,9 +1,10 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -0.5, for ccollect 0.4-0.5.3, Initial Version from 2006-01-13 +0.6, for ccollect 0.6, Initial Version from 2006-01-13 :Author Initials: NS + (pseudo) incremental backup with different exclude lists using hardlinks and `rsync` @@ -11,20 +12,20 @@ using hardlinks and `rsync` Introduction ------------ -ccollect is a backup utility written in the sh-scripting language. +`ccollect` is a backup utility written in the sh-scripting language. It does not depend on a specific shell, only `/bin/sh` needs to be bourne shell compatible (like 'dash', 'ksh', 'zsh', 'bash', ...). Supported and tested operating systems and architectures ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -ccollect was successfully tested on the following platforms: +`ccollect` was successfully tested on the following platforms: -- GNU/Linux on hppa/i386/amd64 -- NetBSD on i386/amd64/sparc/sparc64 -- OpenBSD on amd64 +- GNU/Linux on amd64/hppa/i386 +- NetBSD on amd64/i386/sparc/sparc64 +- OpenBSD on amd64 -It *should* run on any Unix that supports rsync and has a POSIX-compatible +It *should* run on any Unix that supports `rsync` and has a POSIX-compatible bourne shell. If your platform is not listed above and you have it successfully running, please drop me a mail. @@ -62,6 +63,23 @@ All other backups are still secure. Incompatibilities ~~~~~~~~~~~~~~~~~ +Versions 0.5 and 0.6 +^^^^^^^^^^^^^^^^^^^^^ +.The format of `rsync_options` changed: +- Before 0.6 it was whitespace delimeted +- As of 0.6 it is newline seperated (so you can pass whitespaces to `rsync`) + +You can update your configuration using `tools/config-pre-0.6-to-0.6.sub.sh`. + +.The name of the backup directories changed: +- Before 0.6: "date +%Y-%m-%d-%H%M" +- As of 0.6: "date +%Y%m%d-%H%M" (better readable, date is closer together) + +For the second change there is no updated needed, as XXXX- is always before +XXXXX (- comes before digit). + + + Versions 0.4 and 0.5 ^^^^^^^^^^^^^^^^^^^^^ Not a real incompatibilty, but seems to fit in this section: @@ -101,7 +119,7 @@ For those who do not want to read the whole long document: -------------------------------------------------------------------------------- # get latest ccollect tarball from http://unix.schottelius.org/ccollect/ # replace value for CCV with the current version -export CCV=0.5.2 +export CCV=0.6 # # replace 'wget' with fetch on bsd @@ -118,8 +136,9 @@ cd ccollect-${CCV} mkdir -p miniconfig/defaults/intervals mkdir miniconfig/sources -# create a sample interval -echo 42 > miniconfig/defaults/intervals/testinterval +# create sample intervals +echo 2 > miniconfig/defaults/intervals/testinterval +echo 3 > miniconfig/defaults/intervals/testinterval2 # create destination directory, where the backups will be kept mkdir ~/DASI @@ -133,11 +152,21 @@ ln -s ~/DASI miniconfig/sources/testsource/destination touch miniconfig/sources/testsource/verbose touch miniconfig/sources/testsource/summary -# do the backup, twice +echo "do the backup, twice" CCOLLECT_CONF=./miniconfig ./ccollect.sh testinterval testsource CCOLLECT_CONF=./miniconfig ./ccollect.sh testinterval testsource -# Let's see how much space we used with two backups and compare it to /bin +echo "the third time ccollect begins to remove old backups" +echo -n "Hit enter to see it" +read +CCOLLECT_CONF=./miniconfig ./ccollect.sh testinterval testsource + +echo "Now we add another interval, ccollect should clone from existent ones" +echo -n "Hit enter to see it" +read +CCOLLECT_CONF=./miniconfig ./ccollect.sh testinterval2 testsource + +echo "Let's see how much space we used with two backups and compare it to /bin" du -s ~/DASI /bin -------------------------------------------------------------------------------- @@ -265,15 +294,17 @@ Each source contains at least the following files: Additionally a source may have the following files: - - `verbose` whether to be verbose (passes -v to `rsync`) - - `very_verbose` be very verbose (-v also for `mkdir`, `rm`) - - `summary` create a transfer summary when `rsync` finished + - `verbose` whether to be verbose (passes -v to `rsync`) + - `very_verbose` be very verbose (`mkdir -v`, `rm -v` and `rsync -vv`) + - `summary` create a transfer summary when `rsync` finished - - `exclude` exclude list for `rsync`. newline ('\n') seperates list. - - `rsync_options` extra options to pass to `rsync` + - `exclude` exclude list for `rsync`. newline seperated list. + - `rsync_options` extra options for `rsync`. newline seperated list. - - `pre_exec` program to execute before backing up *this* source - - `post_exec` program to execute after backing up *this* source + - `pre_exec` program to execute before backing up *this* source + - `post_exec` program to execute after backing up *this* source + + - `delete_incomplete` Example: From e68e536033bf5331fabe26f6fff8487a1e2d06fa Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 22:50:50 +0200 Subject: [PATCH 151/581] Rename so there's no conflict in global binary execute namespace --- tools/{list_intervals.sh => list_ccollect_intervals.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/{list_intervals.sh => list_ccollect_intervals.sh} (100%) diff --git a/tools/list_intervals.sh b/tools/list_ccollect_intervals.sh similarity index 100% rename from tools/list_intervals.sh rename to tools/list_ccollect_intervals.sh From d05b4dc3a83593134a83cfe1d262b2330dcf2c11 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 22:57:15 +0200 Subject: [PATCH 152/581] Add idea, du -shl vs. du -sh, but no implementation --- tools/gnu-du-backup-size-compare.sh | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 tools/gnu-du-backup-size-compare.sh diff --git a/tools/gnu-du-backup-size-compare.sh b/tools/gnu-du-backup-size-compare.sh new file mode 100755 index 0000000..ea8b833 --- /dev/null +++ b/tools/gnu-du-backup-size-compare.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# +# Nico Schottelius +# Date: 2007-08-16 +# Last Modified: - +# + +exit 1 +# not yet finished. + +CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} +CCOLLECT_SOURCES="$CCOLLECT_CONF/defaults/sources" + +me="$(basename "$0")" + +if [ $# -lt 1 ]; then + echo "${me}: sources names + exit 1 +fi + +if [ ! -d "$CCOLLECT_SOURCES" ]; then + echo "No sources defined in $CCOLLECT_SOURCES" + exit 1 +fi + +cd "$CCOLLECT_INTERVALS" + +for interval in *; do + eval int_$interval=$(cat $interval); + eval echo $interval: \$int_$interval; +done From 22f83a023825e92e70304e599ff2bc9910d8840a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 22:58:37 +0200 Subject: [PATCH 153/581] Add another idea without implementation --- tools/ccollect-logwrapper.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 tools/ccollect-logwrapper.sh diff --git a/tools/ccollect-logwrapper.sh b/tools/ccollect-logwrapper.sh new file mode 100755 index 0000000..a3cb6d8 --- /dev/null +++ b/tools/ccollect-logwrapper.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# Nico Schottelius +# written for Netstream (www.netstream.ch) +# Date: Fr 8. Jun 10:30:24 CEST 2007 +# Call the log-wrapper instead of ccollect.sh and it will log +# to your selected destinations + +# not implemented +exit 0 + +Analyses output produced by ccollect. + +# +# where to find our configuration and temporary file +# +CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} +LOGCONF=$CCOLLECT_CONF/logwrapper +VERSION=0.1 +RELEASE="2007-XX-XX" + +HALF_VERSION="ccollect $VERSION" +FULL_VERSION="ccollect $VERSION ($RELEASE)" + +# syslog: logger -t ccollect-logwrapper + From 845cc5f0b5d0a2bfaa78f5a914ffef7bc8973222 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 22:59:12 +0200 Subject: [PATCH 154/581] Add delete_incomplete to test configuration --- conf/sources/source with spaces/delete_incomplete | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 conf/sources/source with spaces/delete_incomplete diff --git a/conf/sources/source with spaces/delete_incomplete b/conf/sources/source with spaces/delete_incomplete new file mode 100644 index 0000000..e69de29 From 30013fb4a6f95b6b3f3f9f6272521ffc9bdfa3ef Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 23:00:10 +0200 Subject: [PATCH 155/581] Add readme for conf/ --- conf/README | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 conf/README diff --git a/conf/README b/conf/README new file mode 100644 index 0000000..8402c76 --- /dev/null +++ b/conf/README @@ -0,0 +1,3 @@ +This is my personal test configuration. +It can perhaps be some example for you, although it may be pretty +unsorted and highly chaotic. From bea4dea52b6eb3e6b0ef4511f6bc69c1e823d227 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 23:01:06 +0200 Subject: [PATCH 156/581] Add configuration defaults for add_ccollect_source --- conf/defaults/sources/exclude | 1 + conf/defaults/sources/rsync_options | 0 conf/defaults/sources/source_postfix | 1 + conf/defaults/sources/source_prefix | 1 + conf/defaults/sources/verbose | 0 5 files changed, 3 insertions(+) create mode 100644 conf/defaults/sources/exclude create mode 100644 conf/defaults/sources/rsync_options create mode 100644 conf/defaults/sources/source_postfix create mode 100644 conf/defaults/sources/source_prefix create mode 100644 conf/defaults/sources/verbose diff --git a/conf/defaults/sources/exclude b/conf/defaults/sources/exclude new file mode 100644 index 0000000..ee4c926 --- /dev/null +++ b/conf/defaults/sources/exclude @@ -0,0 +1 @@ +/test diff --git a/conf/defaults/sources/rsync_options b/conf/defaults/sources/rsync_options new file mode 100644 index 0000000..e69de29 diff --git a/conf/defaults/sources/source_postfix b/conf/defaults/sources/source_postfix new file mode 100644 index 0000000..0b5cde7 --- /dev/null +++ b/conf/defaults/sources/source_postfix @@ -0,0 +1 @@ +:/ diff --git a/conf/defaults/sources/source_prefix b/conf/defaults/sources/source_prefix new file mode 100644 index 0000000..fc37f9d --- /dev/null +++ b/conf/defaults/sources/source_prefix @@ -0,0 +1 @@ +root@ diff --git a/conf/defaults/sources/verbose b/conf/defaults/sources/verbose new file mode 100644 index 0000000..e69de29 From 31b90624c8132b4463dea30501565d936daec202 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 23:38:25 +0200 Subject: [PATCH 157/581] Add How can I prevent missing the right time to enter my password? to faq --- doc/ccollect.text | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 4755a75..f51f5ae 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -173,7 +173,7 @@ du -s ~/DASI /bin Cutting and pasting the complete section above to your shell will result in the download of ccollect, the creation of a sample configuration and the -execution of two backups. +execution of some backups. Requirements @@ -200,7 +200,13 @@ Using ccollect Installing ---------- Either type 'make install' or simply copy it to a directory in your -$PATH and execute 'chmod *0755* /path/to/ccollect.sh'. +$PATH and execute 'chmod *0755* /path/to/ccollect.sh'. If you would +like to use the new management scripts (available since 0.6), copy +the following scripts to a directory in $PATH: + +- `tools/add_ccollect_source.sh` +- `tools/list_ccollect_intervals.sh` +- `tools/delete_ccollect_source.sh` Configuring @@ -241,7 +247,8 @@ Interval definition ^^^^^^^^^^^^^^^^^^^^ The interval definition can be found in '$CCOLLECT_CONF/defaults/intervals/' or '/etc/ccollect/defaults/intervals'. -Each file in this directory specifies an interval. The name of the file is the same as the name of the interval: `intervals/''`. +Each file in this directory specifies an interval. The name of the file is +the same as the name of the interval: `intervals/''`. The content of this file should be a single line containing a number. This number defines how many versions of this interval are kept. @@ -304,7 +311,7 @@ Additionally a source may have the following files: - `pre_exec` program to execute before backing up *this* source - `post_exec` program to execute after backing up *this* source - - `delete_incomplete` + - `delete_incomplete` delete incomplete backups Example: @@ -493,6 +500,9 @@ df -h df -h -------------------------------------------------------------------------------- +Detailed description of "delete_incomplete" +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Hints ----- @@ -611,6 +621,9 @@ This leads to - more transferred files - much greater disk space usage, as no hardlinks can be used +If the whole `ccollect` process was interrupted, `ccollect` (since 0.6) can +detect that and remove the incomplete backups, so you can clone from a complete +backup instead. When backing up from localhost the destination is also included. Is this a bug? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -630,7 +643,6 @@ permissions. Try `chmod 0755 /etc/ccollect/sources/'yoursource'/*_exec``. Why does the backup job fail when part of the source is a link? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - When a part of your path you specified in the source is a (symbolic, hard links are not possible for directories) link, the backup *must* fail. @@ -671,6 +683,18 @@ However, you can backup directories containing symbolic links /home/user/nico/projekte and oeffentlich/computer/projekte). +How can I prevent missing the right time to enter my password? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +As `ccollect` first deletes the old backups, it may take some time +until `rsync` requests the password for the `ssh` session from you. + +The easiest way not to miss that point is running `ccollect` in `screen`, +which has the ability to monitor the output for activity. So as soon as +your screen beeps, after `ccollect` began to remove the last directory, +you can enter your password (have a look at screen(1), especially "C-a M" +and "C-a _", for more information). + + Examples -------- @@ -901,4 +925,3 @@ Truncated output from `ps axuwwwf`: ------------------------------------------------------------------------- As you can see, six processes are deleting old backups, while one backup (ddba034) is already copying data. - From 52095b7cf0cdc0df303c0fe0dd6fdb788a5fc156 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 23:39:18 +0200 Subject: [PATCH 158/581] Update e-mail --- tools/list_ccollect_intervals.sh | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tools/list_ccollect_intervals.sh b/tools/list_ccollect_intervals.sh index 463f9b4..2d51688 100755 --- a/tools/list_ccollect_intervals.sh +++ b/tools/list_ccollect_intervals.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Nico Schottelius +# Nico Schottelius # Date: 24-Jun-2006 # Last Modified: - # @@ -8,14 +8,22 @@ CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} CCOLLECT_INTERVALS="$CCOLLECT_CONF/defaults/intervals" -if [ ! -d "$CCOLLECT_INTERVALS" ]; then - echo "No intervals defined in $CCOLLECT_INTERVALS" - exit 23 +me="$(basename $0)" + +_echo() +{ + echo "$me> $@" +} + +if [ ! -d "${CCOLLECT_INTERVALS}" ]; then + _echo "No intervals defined in ${CCOLLECT_INTERVALS}" + exit 1 fi -cd "$CCOLLECT_INTERVALS" +set -e +cd "${CCOLLECT_INTERVALS}" for interval in *; do - eval int_$interval=$(cat $interval); - eval echo $interval: \$int_$interval; + eval int_${interval}=$(cat "${interval}"); + eval echo ${interval}: \$int_${interval}; done From abb408a9b2bd41c823d395545a57eb6e66f044ae Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 23:46:57 +0200 Subject: [PATCH 159/581] Add explanation for delete_incomplete --- doc/ccollect.text | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/ccollect.text b/doc/ccollect.text index f51f5ae..ec6678b 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -502,6 +502,10 @@ df -h Detailed description of "delete_incomplete" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +If you create the file `delete_incomplete` in a source specification directory, +`ccollect` will look for incomplete backups (when the whole `ccollect` process +was interrupted) and remove them. Without this file `ccollect` will only warn +the user. Hints From e8044b6f79bd626cad02a8e48346cdb3cad5173b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 23:50:55 +0200 Subject: [PATCH 160/581] Using source names or interval in pre_/post_exec scripts --- doc/ccollect.text | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/ccollect.text b/doc/ccollect.text index ec6678b..c3756e4 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -511,6 +511,17 @@ the user. Hints ----- +Using source names or interval in pre_/post_exec scripts +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The pre-/post_exec scripts can access some internal variables from `ccollect`: + +- INTERVAL: The interval specified on the command line +- no_sources: number of sources +- source_$NUM: the name of the source +- name: the name of the currently being backuped source (not available for + generic pre_exec script) + + Using rsync protocol without ssh ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When you have a computer with little computing power, it may be useful to use From 73501e8963a0e440201fa52a58a770c00dca8808 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 16 Aug 2007 23:52:36 +0200 Subject: [PATCH 161/581] finished 0.5.3 todos --- doc/todo/0.5.3 | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/doc/todo/0.5.3 b/doc/todo/0.5.3 index 4a20e5e..0019581 100644 --- a/doc/todo/0.5.3 +++ b/doc/todo/0.5.3 @@ -1,21 +1,34 @@ -- check and export variables for use in scripts! -- documentation - * -F / --filter for rsync +Done: +==> screenshot +u0219 zrha166.netstream.ch # ~chdscni9/ccollect.sh weekly zrha166.netstream.ch +2007-08-16-21:49:44: ccollect 0.6: Beginning backup using interval weekly +[zrha166.netstream.ch] 2007-08-16-21:49:44: Beginning to backup +[zrha166.netstream.ch] 2007-08-16-21:49:45: Existing backups: 0 Total keeping backups: 8 +[zrha166.netstream.ch] 2007-08-16-21:49:45: Did not find existing backups for interval weekly. +[zrha166.netstream.ch] 2007-08-16-21:49:45: Using backup from daily. +[zrha166.netstream.ch] 2007-08-16-21:49:45: Beginning to backup, this may take some time... +[zrha166.netstream.ch] 2007-08-16-21:49:45: Creating /etc/ccollect/sources/zrha166.netstream.ch/destination/weekly.20070816-2149.22188 ... +[zrha166.netstream.ch] 2007-08-16-21:49:45: Transferring files... + +- beep-after-delete-hack? + -> tonnerre / #cLinux + +- replace nico-linux-ccollect with nico-ccollect + * ccollect is not Linux specific + +- remove exit-calls + * will leave behind unused temporary file! + * use _exit_err + X join todos + - fix possible quoting problems * rsync_extra (redefine format) * exclude * other * create _rsync, filtering args, creating new $@ -- remove exit-calls - * will leave behind unused temporary file! - * use _exit_err -- replace nico-linux-ccollect with nico-ccollect - * ccollect is not Linux specific -- beep-after-delete-hack? - -> tonnerre / #cLinux -Done: +- check and export variables for use in scripts! Contact Julian later: * integrate updated german documentation From 2c38ea503f0f24b076d8640342d9d4c164d22dd2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 00:10:08 +0200 Subject: [PATCH 162/581] Update todo for 0.6.1 --- doc/todo/0.6 | 56 ++++++++++++++++++++++++-------------------------- doc/todo/0.6.1 | 8 ++++++++ 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/doc/todo/0.6 b/doc/todo/0.6 index 07993ee..ee8e97f 100644 --- a/doc/todo/0.6 +++ b/doc/todo/0.6 @@ -1,3 +1,22 @@ +not did, did not remember why I wanted to do that: + +- do sed-time check: + +1.2. replace sed? +compare timing: +_echo () { echo "$name $msg" } +and create +_techo () { echo "$timestamp $name $msg" } +perhaps create +_eecho () { _techo "ERROR $msg" } +? + + + +done: +add note for + 09:24 < telmich> Obri: ~/.ssh/config! + - implement use of different intervals as source for cloning * use 'woechentlich' if available and no backup exists for 'daily' * add 'prefer_latest' to prefer different interval, that's newer than @@ -14,39 +33,15 @@ sven / markierung - do not check by name, but by time * is ls -t posix? * also check: -p -1 -- do sed-time check: - -1.2. replace sed? -compare timing: -_echo () { echo "$name $msg" } -and create -_techo () { echo "$timestamp $name $msg" } -perhaps create -_eecho () { _techo "ERROR $msg" } -? - - ccollect Zeitausgabe verbessern - Wofuer wie lange gebraucht * rm * klonen (gibt es so ja nicht) Wenn Summary angegeben ist am Ende ausgeben -- add --version, -V - do we want rsync -H by default? -- add source/ignore_failed_pre_exec -- add source/ignore_failed_post_exec - + * no: takes much more memory ssh / port change: change rsync_extra format -add note for - 09:24 < telmich> Obri: ~/.ssh/config! - - -Documentation: -- hint: backuping backup -- update documentation: - - german doc? - - exit pre/post exec -> error codes (after implementation!) (in 0.4) - - write about fast changing fs - Variables: source_$n no_sources @@ -54,12 +49,15 @@ Documentation: - changed naming of sources: YYYYMMDD-HHMM.PID (better readable) => source / backup converter! => not needed! -- delete_incomplete - config: set destination-base /etc/ccollect/defaults/source_config - -done: +Documentation: +- hint: backuping backup +- update documentation: + - german doc? + - exit pre/post exec -> error codes (after implementation!) (in 0.4) + - write about fast changing fs +- delete_incomplete diff --git a/doc/todo/0.6.1 b/doc/todo/0.6.1 index 1b19bc0..88db122 100644 --- a/doc/todo/0.6.1 +++ b/doc/todo/0.6.1 @@ -2,3 +2,11 @@ o strip of interval name o run sort -n o use the last entry +- do not delete_incomplete, when there's only one backup left! +- Add filter support + * filter +- think about 'prefer_same_interval' / 'prefer_latest' +- add --version, -V +- add source/ignore_failed_pre_exec +- add source/ignore_failed_post_exec + From f609fbc25c5e13f3955dd7514f7793c3719a4860 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 00:11:48 +0200 Subject: [PATCH 163/581] Add ssh port hint --- doc/ccollect.text | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index c3756e4..debf500 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -511,6 +511,20 @@ the user. Hints ----- +Using a different ssh port +~~~~~~~~~~~~~~~~~~~~~~~~~~ +Mostly easy is to use your ~/.ssh/config file: + +-------------------------------------------------------------------------------- +host mx2.schottelius.org + Port 2342 +-------------------------------------------------------------------------------- + +If you only use that port for backup and normally want to use another port, +you can add 'HostName' and "HostKeyAlias" (if you also have different +keys on the different ports). + + Using source names or interval in pre_/post_exec scripts ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The pre-/post_exec scripts can access some internal variables from `ccollect`: @@ -587,7 +601,7 @@ Now you can use /home/backup/web1 as the `destination` for the backup. Do *not* name the first backup something like "daily.initial", but use the "*0*" (or some number that is lower than the current year) as extension. `ccollect` uses `sort` to find the latest backup. `ccollect` -itself uses 'interval.YEAR-MONTH-DAY-HOURMINUTE.PID'. This notation will +itself uses 'interval.YEARMONTHDAY-HOURMINUTE.PID'. This notation will *always* be before "daily.initial", as numbers are earlier in the list which is produced by `sort`. So, if you have a directory named "daily.initial", `ccollect` will always diff against this backup and transfer and delete From 760ddd2073f5af55402a90c86cd5fb06626e189b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 00:19:12 +0200 Subject: [PATCH 164/581] Update readme --- README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README b/README index ad6a181..12bcdb3 100644 --- a/README +++ b/README @@ -39,8 +39,8 @@ A small try to visualize the differnces in a table: | Programming | perl | sh | | language | | (posix compatible) | +---------------+-------------------------------------------------------------+ -| Lines of code | 6636 | 476 | -| (2006-10-25) | | | +| Lines of code | 6772 (5353 w/o comments, | 546 (375 w/o comments, | +| (2006-10-25) | 4794 w/o empty lines) | 288 w/o empty lines) | +---------------+-------------------------------------------------------------+ | Age | Available since 2002/2003 | Written at 2005-11-14 | +---------------+-------------------------------------------------------------+ From d442277d68ba46c6763500bdbd55536c532e99c1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 00:19:28 +0200 Subject: [PATCH 165/581] Prepare release date --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index d1d1c5c..60554a4 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -15,7 +15,7 @@ CPOSTEXEC="${CDEFAULTS}/post_exec" TMP=$(mktemp "/tmp/$(basename $0).XXXXXX") VERSION=0.6 -RELEASE="2007-08-16/17" +RELEASE="2007-08-17" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" From 0161529e1c62c586e0d6cb6218d8712da835297f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 00:19:53 +0200 Subject: [PATCH 166/581] Cleanup exit calls --- doc/CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/CHANGES b/doc/CHANGES index 4737306..7cc0a50 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -6,6 +6,8 @@ * Added management tools (including manpages): * add_ccollect_source.sh * delete_ccollect_source.sh + * list_ccollect_intervals.sh + * Cleaned up exit calls (now always cleanly removes temporary files) * Changed license to GPLv3 (from GPLv2) 0.5.1 to 0.5.2: From e5010b0d063e1db1e111b057290891b1ce10b8e2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 00:21:32 +0200 Subject: [PATCH 167/581] less todo --- doc/todo/netstream-1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/todo/netstream-1 b/doc/todo/netstream-1 index 9b7a514..a0a6eba 100644 --- a/doc/todo/netstream-1 +++ b/doc/todo/netstream-1 @@ -19,8 +19,6 @@ Messages: (to be used for filtering) file has vanished: ".*" -------------------------------------------------------------------------------- -rsync_extra global! -- \n delimeted Analyzer: - grosse Dateien @@ -38,6 +36,12 @@ linux: /proc/* /dev/* /tmp/* + +-------------------------------------------------------------------------------- +done: + +rsync_extra global! +- \n delimeted -------------------------------------------------------------------------------- -S, --sparse Try to handle sparse files efficiently so they take up less space on the des‐ @@ -46,3 +50,4 @@ linux: -------------------------------------------------------------------------------- Always report return code! + From bb4a870852ef65afb102904b9c065162244ba2ad Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 00:23:17 +0200 Subject: [PATCH 168/581] add example for hostkeysalias --- doc/ccollect.text | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index debf500..5a29bd8 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -522,7 +522,20 @@ host mx2.schottelius.org If you only use that port for backup and normally want to use another port, you can add 'HostName' and "HostKeyAlias" (if you also have different -keys on the different ports). +keys on the different ports): + +-------------------------------------------------------------------------------- +Host hhydrogenium + Hostname bruehe.schottelius.org + Port 666 + HostKeyAlias hydrogenium + +Host bruehe + Hostname bruehe.schottelius.org + Port 22 + HostKeyAlias bruehe.schottelius.org +-------------------------------------------------------------------------------- + Using source names or interval in pre_/post_exec scripts From 194787e2d28d76c3074f33c88ec0c416da41ff6d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 10:13:14 +0200 Subject: [PATCH 169/581] Add manpage for list_ccollect_intervals --- doc/man/list_ccollect_intervals.text | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 doc/man/list_ccollect_intervals.text diff --git a/doc/man/list_ccollect_intervals.text b/doc/man/list_ccollect_intervals.text new file mode 100644 index 0000000..356e99b --- /dev/null +++ b/doc/man/list_ccollect_intervals.text @@ -0,0 +1,45 @@ +list_ccollect_intervals(1) +========================== +Nico Schottelius + + +NAME +---- +list_ccollect_intervals - list available intervals from ccollect(1) + + +SYNOPSIS +-------- +'list_ccollect_intervals.sh' + + +DESCRIPTION +----------- +list_ccollect_intervals.sh shows intervals specified in the configuration +for ccollect(1). It displays the name of each interval, followed by a colon +followed by the number backups to keep. + +FILES +----- +$CCOLLECT_CONF/intervals:: + Directory containing the intervals. $CCOLLECT_CONF is '/etc/ccollect', if unset. + +SEE ALSO +-------- +add_ccollect_source(1), ccollect(1), delete_ccollect_source(1) + + +AUTHOR +------ +Nico Schottelius + + +RESOURCES +--------- +Main web site: http://unix.schottelius.org/ccollect/[] + + +COPYING +------- +Copyright \(C) 2007 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License Version 3 (GPLv3). From 52c2132eb3d6ebb0f80bea4da96cdb33bc9572c8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 10:48:04 +0200 Subject: [PATCH 170/581] Add GPLv3 note --- tools/add_ccollect_source.sh | 1 + tools/delete_ccollect_source.sh | 1 + tools/list_ccollect_intervals.sh | 1 + 3 files changed, 3 insertions(+) diff --git a/tools/add_ccollect_source.sh b/tools/add_ccollect_source.sh index d9ae8a8..7a238f5 100755 --- a/tools/add_ccollect_source.sh +++ b/tools/add_ccollect_source.sh @@ -4,6 +4,7 @@ # Written for Netstream (www.netstream.ch) # Creates a source from standard values specified in # /etc/ccollect/defaults/sources +# Copying: GPLv3 # standard values CCOLLECT_CONF="${CCOLLECT_CONF:-/etc/ccollect}" diff --git a/tools/delete_ccollect_source.sh b/tools/delete_ccollect_source.sh index b1acb24..8a811d3 100755 --- a/tools/delete_ccollect_source.sh +++ b/tools/delete_ccollect_source.sh @@ -3,6 +3,7 @@ # 2007-08-16 # Written for Netstream (www.netstream.ch) # Delete sources and their backups (optionally). +# Copying: GPLv3 (See file COPYING in top directory) # standard values CCOLLECT_CONF="${CCOLLECT_CONF:-/etc/ccollect}" diff --git a/tools/list_ccollect_intervals.sh b/tools/list_ccollect_intervals.sh index 2d51688..47c1481 100755 --- a/tools/list_ccollect_intervals.sh +++ b/tools/list_ccollect_intervals.sh @@ -3,6 +3,7 @@ # Nico Schottelius # Date: 24-Jun-2006 # Last Modified: - +# Copying: GPLv3 (See file COPYING in top directory) # CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} From d61f7e1fda66a1f994b65c80b9f96c0c0b605982 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 10:48:33 +0200 Subject: [PATCH 171/581] Minor corrections in documentation --- doc/man/add_ccollect_source.text | 2 +- doc/man/ccollect.text | 5 +++++ doc/man/delete_ccollect_source.text | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/doc/man/add_ccollect_source.text b/doc/man/add_ccollect_source.text index 8e5f639..8421d69 100644 --- a/doc/man/add_ccollect_source.text +++ b/doc/man/add_ccollect_source.text @@ -53,7 +53,7 @@ source_postfix:: SEE ALSO -------- -ccollect(1), delete_ccollect_source(1) +ccollect(1), delete_ccollect_source(1), list_ccollect_intervals(1) AUTHOR diff --git a/doc/man/ccollect.text b/doc/man/ccollect.text index 9960cd6..abe4ebe 100644 --- a/doc/man/ccollect.text +++ b/doc/man/ccollect.text @@ -37,6 +37,11 @@ OPTIONS -v, --verbose:: Be very verbose (uses set -x). +SEE ALSO +-------- +add_ccollect_source(1), delete_ccollect_source(1), list_ccollect_intervals(1) + + AUTHOR ------ Nico Schottelius diff --git a/doc/man/delete_ccollect_source.text b/doc/man/delete_ccollect_source.text index efd1473..9401418 100644 --- a/doc/man/delete_ccollect_source.text +++ b/doc/man/delete_ccollect_source.text @@ -10,7 +10,7 @@ delete_ccollect_source - delete sources from ccollect(1) SYNOPSIS -------- -'add_ccollect_source.sh' [-d] [-f] +'delete_ccollect_source.sh' [-d] [-f] DESCRIPTION @@ -21,7 +21,7 @@ also the backups created for that source. OPTIONS ------- -d: - Delete also the destination directory. `'add_ccollect_source.sh` will change + Delete also the destination directory. `add_ccollect_source.sh` will change to the source/'name'/destination directory, get the absolute name and delete it recursively. -f: @@ -36,7 +36,7 @@ $CCOLLECT_CONF/sources:: SEE ALSO -------- -add_ccollect_source(1), ccollect(1) +add_ccollect_source(1), ccollect(1), list_ccollect_intervals(1) AUTHOR From 7d5c1e00774bd3dcb351c293b67ba79ea25cc7bc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 11:07:55 +0200 Subject: [PATCH 172/581] Also install manpages --- Makefile | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 0512afe..3ced51e 100644 --- a/Makefile +++ b/Makefile @@ -12,11 +12,15 @@ DOCBOOKTOTEXI=docbook2x-texi DOCBOOKTOMAN=docbook2x-man XSLTPROC=xsltproc XSL=/usr/share/xml/docbook/stylesheet/nwalsh/html/docbook.xsl +A2X=a2x prefix=/usr/packages/ccollect-git bindir=${prefix}/bin destination=${bindir}/${CCOLLECT_DEST} +mandest=${prefix}/man/man1 +manlink=/usr/local/man/man1 + path_dir=/usr/local/bin path_destination=${path_dir}/${CCOLLECT_DEST} @@ -28,7 +32,11 @@ docdir=${dir}/doc # # Asciidoc will be used to generate other formats later # -MANDOCS = doc/man/ccollect.text +MANDOCS = doc/man/ccollect.text \ + doc/man/add_ccollect_source.text \ + doc/man/delete_ccollect_source.text \ + doc/man/list_ccollect_intervals.text + DOCS = ${MANDOCS} doc/ccollect.text doc/ccollect-DE.text # @@ -62,7 +70,7 @@ all: @echo "man: only generate manpage{s}" @echo "install: install ccollect to ${prefix}" -install: install-script install-link +install: install-link install-manlink install-link: install-script ${LN} ${destination} ${path_destination} @@ -70,6 +78,14 @@ install-link: install-script install-script: ${INSTALL} -D -m 0755 ${CCOLLECT_SOURCE} ${destination} +install-man: man + ${INSTALL} -d -m 0755 ${mandest} + ${INSTALL} -D -m 0644 doc/man/*.1 ${mandest} + +install-manlink: install-man + ${INSTALL} -d -m 0755 ${manlink} + for man in ${mandest}/*; do ${LN} $$man ${manlink}; done + # docbook gets .htm, asciidoc directly .html %.htm: %.docbook @@ -87,11 +103,15 @@ install-script: %.texi: %.docbook ${DOCBOOKTOTEXI} --to-stdout $< > $@ -%.mandocbook: %.text - ${ASCIIDOC} -b docbook -d manpage -o $@ $< +#%.mandocbook: %.text +# ${ASCIIDOC} -b docbook -d manpage -o $@ $< + +#%.man: %.mandocbook +# ${DOCBOOKTOMAN} --to-stdout $< > $@ + +%.man: %.text + ${A2X} -f manpage $< -%.man: %.mandocbook - ${DOCBOOKTOMAN} --to-stdout $< > $@ # # Developer targets @@ -113,9 +133,11 @@ publish-doc: documentation # allclean: rm -f ${DOC_ALL} + rm -f doc/man/*.[0-9] doc/man/*.xml distclean: allclean rm -f ${DOCBDOCS} + rm -f doc/man/*.[0-9] doc/man/*.xml # # Be nice with the users and generate documentation for them From caa6e9f023e21bcab5fef5c9695498d37c273379 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 11:23:32 +0200 Subject: [PATCH 173/581] Add pdf support --- Makefile | 17 ++++++++++++----- doc/CHANGES | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 3ced51e..54ec563 100644 --- a/Makefile +++ b/Makefile @@ -45,18 +45,23 @@ DOCS = ${MANDOCS} doc/ccollect.text doc/ccollect-DE.text HTMLDOCS = ${DOCS:.text=.html} DBHTMLDOCS = ${DOCS:.text=.htm} +# texi is broken currently, don't know why xslt things complain yet TEXIDOCS = ${DOCS:.text=.texi} +TEXIDOCS = + +PDFDOCS = ${DOCS:.text=.pdf} MANPDOCS = ${MANDOCS:.text=.man} DOCBDOCS = ${DOCS:.text=.docbook} -DOC_ALL = ${HTMLDOCS} ${DBHTMLDOCS} ${TEXIDOCS} ${MANPDOCS} +DOC_ALL = ${HTMLDOCS} ${DBHTMLDOCS} ${TEXIDOCS} ${MANPDOCS} ${PDFDOCS} html: ${HTMLDOCS} htm: ${DBHTMLDOCS} info: ${TEXIDOCS} man: ${MANPDOCS} +pdf: ${PDFDOCS} documentation: ${DOC_ALL} # @@ -112,6 +117,9 @@ install-manlink: install-man %.man: %.text ${A2X} -f manpage $< +%.pdf: %.text + ${A2X} -f pdf $< + # # Developer targets @@ -131,18 +139,17 @@ publish-doc: documentation # # Distribution # -allclean: +clean: rm -f ${DOC_ALL} rm -f doc/man/*.[0-9] doc/man/*.xml -distclean: allclean +distclean: clean rm -f ${DOCBDOCS} - rm -f doc/man/*.[0-9] doc/man/*.xml # # Be nice with the users and generate documentation for them # dist: distclean documentation -test: ccollect.sh +test: ccollect.sh documentation CCOLLECT_CONF=./conf ./ccollect.sh daily "source with spaces" diff --git a/doc/CHANGES b/doc/CHANGES index 7cc0a50..c7ec0ae 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -8,6 +8,7 @@ * delete_ccollect_source.sh * list_ccollect_intervals.sh * Cleaned up exit calls (now always cleanly removes temporary files) + * In theory, added pdf documentation (though, was unable to do it with fop) * Changed license to GPLv3 (from GPLv2) 0.5.1 to 0.5.2: From 96d5ab1b3bc112c398f1b13cb13e893910ef2e6e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 11:24:30 +0200 Subject: [PATCH 174/581] disable automatic pdf generation for now --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 54ec563..5c3bde5 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,9 @@ DBHTMLDOCS = ${DOCS:.text=.htm} TEXIDOCS = ${DOCS:.text=.texi} TEXIDOCS = +# fop fails here, so disable it for now PDFDOCS = ${DOCS:.text=.pdf} +PDFDOCS = MANPDOCS = ${MANDOCS:.text=.man} From 6bd8393d3d7b211ce53346c1cdd39b1e364a91bb Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 11:28:05 +0200 Subject: [PATCH 175/581] Ignore texi/fo --- .gitignore | 2 ++ Makefile | 13 +++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 204b8d5..4e9c74d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ test/* doc/man/*.[0-9] doc/*.xml doc/*/*.xml +*.texi +*.fo diff --git a/Makefile b/Makefile index 5c3bde5..763e492 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ TEXIDOCS = PDFDOCS = ${DOCS:.text=.pdf} PDFDOCS = -MANPDOCS = ${MANDOCS:.text=.man} +MANPDOCS = ${MANDOCS:.text=.1} DOCBDOCS = ${DOCS:.text=.docbook} @@ -116,7 +116,8 @@ install-manlink: install-man #%.man: %.mandocbook # ${DOCBOOKTOMAN} --to-stdout $< > $@ -%.man: %.text +#%.man: %.text +%.1: %.text ${A2X} -f manpage $< %.pdf: %.text @@ -127,11 +128,7 @@ install-manlink: install-man # Developer targets # update: - @cg-update home - -push-work: - @cg-push home - @cg-push sygroup + @git push publish-doc: documentation @echo "Transferring files to ${host}" @@ -143,7 +140,7 @@ publish-doc: documentation # clean: rm -f ${DOC_ALL} - rm -f doc/man/*.[0-9] doc/man/*.xml + rm -f doc/man/*.[0-9] doc/man/*.xml doc/*.fo doc/man/*.fo distclean: clean rm -f ${DOCBDOCS} From 7558d88a3d9816425ab2fb9ba81be86691788dfb Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 15:05:45 +0200 Subject: [PATCH 176/581] cleanup (in testing) --- tools/gnu-du-backup-size-compare.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/gnu-du-backup-size-compare.sh b/tools/gnu-du-backup-size-compare.sh index ea8b833..4a199dc 100755 --- a/tools/gnu-du-backup-size-compare.sh +++ b/tools/gnu-du-backup-size-compare.sh @@ -23,9 +23,10 @@ if [ ! -d "$CCOLLECT_SOURCES" ]; then exit 1 fi -cd "$CCOLLECT_INTERVALS" +cd "${CCOLLECT_SOURCES}" -for interval in *; do - eval int_$interval=$(cat $interval); - eval echo $interval: \$int_$interval; +while [ "$#" -gt 0 ]; do + source="$1"; shift + fsource="${CCOLLECT_SOURCES}/${source}" + du "${fsource}/"* "${fsource}" done From 8490b77acfc3016363225dccc602e6883ad343a6 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 15:14:49 +0200 Subject: [PATCH 177/581] Add -s to du --- tools/gnu-du-backup-size-compare.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/gnu-du-backup-size-compare.sh b/tools/gnu-du-backup-size-compare.sh index 4a199dc..85b876b 100755 --- a/tools/gnu-du-backup-size-compare.sh +++ b/tools/gnu-du-backup-size-compare.sh @@ -28,5 +28,6 @@ cd "${CCOLLECT_SOURCES}" while [ "$#" -gt 0 ]; do source="$1"; shift fsource="${CCOLLECT_SOURCES}/${source}" - du "${fsource}/"* "${fsource}" + du -s "${fsource}/"* "${fsource}" + # du -l should follow done From e71146dbbf67e3ca3975f0ce58a5dabd19e7b7b4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 15:45:21 +0200 Subject: [PATCH 178/581] Create destination on real path --- doc/CHANGES | 3 +++ tools/add_ccollect_source.sh | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/CHANGES b/doc/CHANGES index c7ec0ae..1bd429f 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,6 @@ +0.6 to 0.6.1: + * Added check for destination_base in add_ccollect_source.sh + 0.5.2 to 0.6: * Always print return code of rsync * Add much more timing information diff --git a/tools/add_ccollect_source.sh b/tools/add_ccollect_source.sh index 7a238f5..ec8e40a 100755 --- a/tools/add_ccollect_source.sh +++ b/tools/add_ccollect_source.sh @@ -89,8 +89,13 @@ while [ $# -gt 0 ]; do echo "${source_source}" > "${fullname}/source" # create destination directory - dest="${destination_base}/${source}" - _echo "Creating destination ${dest} ..." + _echo "Creating destination ..." + + absbase=$(cd "${destination_base}" 2>/dev/null && pwd -P) || \ + _exit_err "${destination_base} should exist before creating sources." + + dest="${absbase}/${source}" + _echo "Creating ${dest} ..." mkdir -p "${dest}" || _exit_err "${dest}: Cannot create." # link destination directory From 2918f4a1e5d4822f52f1a8ffa0ed8bbdc30de68e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 15:53:23 +0200 Subject: [PATCH 179/581] too much information, clean up --- tools/add_ccollect_source.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/add_ccollect_source.sh b/tools/add_ccollect_source.sh index ec8e40a..f431c7f 100755 --- a/tools/add_ccollect_source.sh +++ b/tools/add_ccollect_source.sh @@ -89,10 +89,8 @@ while [ $# -gt 0 ]; do echo "${source_source}" > "${fullname}/source" # create destination directory - _echo "Creating destination ..." - absbase=$(cd "${destination_base}" 2>/dev/null && pwd -P) || \ - _exit_err "${destination_base} should exist before creating sources." + _exit_err "${destination_base} must exist before creating sources." dest="${absbase}/${source}" _echo "Creating ${dest} ..." From 6d01706aea64eb9f0a9ede3f93d141f5a700d74e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 23:24:42 +0200 Subject: [PATCH 180/581] Add Markus to credit list --- CREDITS | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CREDITS b/CREDITS index 3f36270..1616f6f 100644 --- a/CREDITS +++ b/CREDITS @@ -1,5 +1,10 @@ Thanks go to the following people: - - the whole #cLinux channel for testing and debugging - (those I mean should know ;-) - - Alexey Maximov for finding return-value and shell limitation bugs +* the whole #cLinux channel + - for testing and debugging (those I mean should know ;-) +* Alexey Maximov + - for finding return-value and shell limitation bugs +* Markus Meier + - for finding a really simple solution for choosing the right backup to + clone from: Make it independent of the interval, simply choose the last + one created. From 2c80eab8e1e19624d3b148e0048ecd54e97c094f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 23:31:45 +0200 Subject: [PATCH 181/581] Include intelligent cloning --- ccollect.sh | 37 +++++++++++-------------------------- doc/todo/0.6.1 | 2 +- 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 60554a4..c20c23d 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -333,9 +333,6 @@ while [ "${i}" -lt "${no_sources}" ]; do DELETE_INCOMPLETE="yes" fi - # - # Verbosity for rsync - # NEW method as of 0.6: # - insert ccollect default parameters # - insert options @@ -422,36 +419,24 @@ while [ "${i}" -lt "${no_sources}" ]; do # - # Check for backup directory to clone from + # Check for backup directory to clone from: Always clone from the latest one! + # + # Use ls -1c instead of -1t, because last modification maybe the same on all + # and metadate update (-c) is updated by rsync locally. # - # try our interval - last_dir="$(ls -d "${c_dest}/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1)" + set -x + #last_dir="$(ls -d "${c_dest}/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1)" + last_dir="$(cd "${c_dest}" && ls -pc1 | grep '/$' | tail -n 1)" || \ + _exit_err "Failed to list contents of ${c_dest}." + set +x - # try other intervals, if there's none four our interval - if [ -z "${last_dir}" ]; then - _techo "Did not find existing backups for interval ${INTERVAL}." - - # get list - : > "${TMP}" - ( cd "${backup}/intervals/" 2>/dev/null && ls >> "${TMP}" ) - ( cd "${CDEFAULTS}/intervals/" 2>/dev/null && ls >> "${TMP}" ) - - # FIXME in 0.6.1: choose best source, not first one. - while read other_interval; do - last_dir="$(ls -d "${c_dest}/${other_interval}."?* 2>/dev/null | sort -n | tail -n 1)" - if [ "${last_dir}" ]; then - _techo "Using backup from ${other_interval}." - break - fi - done < "${TMP}" - fi - # # clone from old backup, if existing # if [ "${last_dir}" ]; then - abs_last_dir="$(cd "${last_dir}" && pwd -P)" || _exit_err "Could not change to last dir ${last_dir}." + abs_last_dir="$(cd "${last_dir}" && pwd -P)" || \ + _exit_err "Could not change to last dir ${last_dir}." set -- "$@" "--link-dest=${abs_last_dir}" fi diff --git a/doc/todo/0.6.1 b/doc/todo/0.6.1 index 88db122..c4a39d5 100644 --- a/doc/todo/0.6.1 +++ b/doc/todo/0.6.1 @@ -9,4 +9,4 @@ - add --version, -V - add source/ignore_failed_pre_exec - add source/ignore_failed_post_exec - +- .ccollect-marker is deleted by rsync at the beginning! From fd6a50a36b80d7b803b4753da485e0c6658c8ac6 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 17 Aug 2007 23:50:40 +0200 Subject: [PATCH 182/581] with -tcp1 need to head -n1, not tail -n1 anymore --- ccollect.sh | 8 +++----- doc/todo/0.6.1 | 11 +++++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index c20c23d..0927f22 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -424,12 +424,9 @@ while [ "${i}" -lt "${no_sources}" ]; do # Use ls -1c instead of -1t, because last modification maybe the same on all # and metadate update (-c) is updated by rsync locally. # - - set -x - #last_dir="$(ls -d "${c_dest}/${INTERVAL}."?* 2>/dev/null | sort -n | tail -n 1)" - last_dir="$(cd "${c_dest}" && ls -pc1 | grep '/$' | tail -n 1)" || \ + rel_last_dir="$(cd "${c_dest}" && ls -tcp1 | grep '/$' | head -n 1)" || \ _exit_err "Failed to list contents of ${c_dest}." - set +x + last_dir="${c_dest}/${rel_last_dir}" # # clone from old backup, if existing @@ -438,6 +435,7 @@ while [ "${i}" -lt "${no_sources}" ]; do abs_last_dir="$(cd "${last_dir}" && pwd -P)" || \ _exit_err "Could not change to last dir ${last_dir}." set -- "$@" "--link-dest=${abs_last_dir}" + _techo "Hard linking from ${rel_last_dir}" fi diff --git a/doc/todo/0.6.1 b/doc/todo/0.6.1 index c4a39d5..619beeb 100644 --- a/doc/todo/0.6.1 +++ b/doc/todo/0.6.1 @@ -1,7 +1,3 @@ -- Improve finding backup from another interval: - o strip of interval name - o run sort -n - o use the last entry - do not delete_incomplete, when there's only one backup left! - Add filter support * filter @@ -10,3 +6,10 @@ - add source/ignore_failed_pre_exec - add source/ignore_failed_post_exec - .ccollect-marker is deleted by rsync at the beginning! + - fix marking + +Done: +- Improve finding backup from another interval: + o strip of interval name + o run sort -n + o use the last entry From 95b4b66a9956ab0c4b29756fd7eabf7803ad2461 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 18 Aug 2007 00:14:10 +0200 Subject: [PATCH 183/581] Add version information --- ccollect.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 0927f22..203ff7e 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -14,8 +14,8 @@ CPREEXEC="${CDEFAULTS}/pre_exec" CPOSTEXEC="${CDEFAULTS}/post_exec" TMP=$(mktemp "/tmp/$(basename $0).XXXXXX") -VERSION=0.6 -RELEASE="2007-08-17" +VERSION=0.6.1 +RELEASE="2007-08-XX" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" @@ -59,6 +59,15 @@ add_name() sed "s:^:\[${name}\] :" } +# +# Version +# +display_version() +{ + echo "${FULL_VERSION}" + exit 0 +} + # # Tell how to use us # @@ -72,6 +81,7 @@ usage() echo " -p, --parallel: Parallelise backup processes" echo " -a, --all: Backup all sources specified in ${CSOURCES}" echo " -v, --verbose: Be very verbose (uses set -x)" + echo " -V, --version: Print version information" echo "" echo " This is version ${VERSION}, released on ${RELEASE}" echo " (the first version was written on 2005-12-05 by Nico Schottelius)." @@ -84,7 +94,11 @@ usage() # need at least interval and one source or --all # if [ $# -lt 2 ]; then - usage + if [ "$1" = "-V" -o "$1" = "--version" ]; then + display_version + else + usage + fi fi # From 8bce8d8620ccbb66e9a748a3b3f7c10a0c989730 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 18 Aug 2007 00:15:48 +0200 Subject: [PATCH 184/581] something with being tired. working too much :/ --- doc/CHANGES | 1 + doc/todo/0.6.1 | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/CHANGES b/doc/CHANGES index 1bd429f..b336b8d 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,5 +1,6 @@ 0.6 to 0.6.1: * Added check for destination_base in add_ccollect_source.sh + * Add support for -V and --version 0.5.2 to 0.6: * Always print return code of rsync diff --git a/doc/todo/0.6.1 b/doc/todo/0.6.1 index 619beeb..f92d5ac 100644 --- a/doc/todo/0.6.1 +++ b/doc/todo/0.6.1 @@ -1,10 +1,8 @@ -- do not delete_incomplete, when there's only one backup left! - Add filter support * filter -- think about 'prefer_same_interval' / 'prefer_latest' -- add --version, -V - add source/ignore_failed_pre_exec - add source/ignore_failed_post_exec +- do not delete_incomplete, when there's only one backup left! - .ccollect-marker is deleted by rsync at the beginning! - fix marking @@ -13,3 +11,7 @@ Done: o strip of interval name o run sort -n o use the last entry +- add --version, -V + +not needed: +- think about 'prefer_same_interval' / 'prefer_latest' From fe2d9d2fe53168b24fe24c8b1f3b8bc3c831fac5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Aug 2007 11:58:31 +0200 Subject: [PATCH 185/581] Finished logwrapper in general --- tools/ccollect-logwrapper.sh | 37 ++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/tools/ccollect-logwrapper.sh b/tools/ccollect-logwrapper.sh index a3cb6d8..518201e 100755 --- a/tools/ccollect-logwrapper.sh +++ b/tools/ccollect-logwrapper.sh @@ -2,11 +2,7 @@ # Nico Schottelius # written for Netstream (www.netstream.ch) # Date: Fr 8. Jun 10:30:24 CEST 2007 -# Call the log-wrapper instead of ccollect.sh and it will log -# to your selected destinations - -# not implemented -exit 0 +# Call the log-wrapper instead of ccollect.sh and it will create nice logs Analyses output produced by ccollect. @@ -15,11 +11,32 @@ Analyses output produced by ccollect. # CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} LOGCONF=$CCOLLECT_CONF/logwrapper -VERSION=0.1 -RELEASE="2007-XX-XX" -HALF_VERSION="ccollect $VERSION" -FULL_VERSION="ccollect $VERSION ($RELEASE)" +logdir="${LOGCONF}/destination" +CDATE="date +%Y%m%d-%H%M" +we="$(basenae $0)" +pid=$$ -# syslog: logger -t ccollect-logwrapper +logfile="${logdir}/$(${CDATE}).${pid}" +# use syslog normally +_echo() +{ + logger "${we}-${pid}: $@" + echo "${we}-${pid}: $@" +} + + +# exit on error +_exit_err() +{ + _echo "$@" + rm -f "${TMP}" + exit 1 +} + +# put everything into that specified file +_echo "Starting with arguments: $@" +touch "${logfile}" || _exit_err "Failed to create ${logfile}" +ccollect.sh "$@" > "${logfile}" 2>&1 +_echo "Finished." From 69ae9076e344bb8c6345ce995a94731ea27a641c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Aug 2007 12:45:23 +0200 Subject: [PATCH 186/581] Add comment about --link-dest --- ccollect.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ccollect.sh b/ccollect.sh index 203ff7e..048f051 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -446,6 +446,8 @@ while [ "${i}" -lt "${no_sources}" ]; do # clone from old backup, if existing # if [ "${last_dir}" ]; then + # must be absolute, otherwise rsync uses it relative to + # the destination directory. See rsync(1). abs_last_dir="$(cd "${last_dir}" && pwd -P)" || \ _exit_err "Could not change to last dir ${last_dir}." set -- "$@" "--link-dest=${abs_last_dir}" From 2a45844e1c2afcff6dc6d1b2ca61812a5f44a0f8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Aug 2007 17:29:24 +0200 Subject: [PATCH 187/581] Also warn if there's a mostly impossible error --- ccollect.sh | 3 ++- doc/todo/0.6.1 | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index 048f051..d699963 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -467,7 +467,8 @@ while [ "${i}" -lt "${no_sources}" ]; do _exit_err "Creating ${destination_dir} failed. Skipping." # absulte now, it's existing - abs_destination_dir="$(cd "${destination_dir}" && pwd -P)" + abs_destination_dir="$(cd "${destination_dir}" && pwd -P)" || \ + _exit_err "Changing to newly created ${destination_dir} failed. Skipping." # # added marking in 0.6 (and remove it, if successful later) diff --git a/doc/todo/0.6.1 b/doc/todo/0.6.1 index f92d5ac..99a17eb 100644 --- a/doc/todo/0.6.1 +++ b/doc/todo/0.6.1 @@ -5,6 +5,11 @@ - do not delete_incomplete, when there's only one backup left! - .ccollect-marker is deleted by rsync at the beginning! - fix marking +- add logwrapper +- add loganalyser + speedup is + error codes + vanished files (see netstream)!!! Done: - Improve finding backup from another interval: @@ -15,3 +20,4 @@ Done: not needed: - think about 'prefer_same_interval' / 'prefer_latest' + From c0c19d259838e9eef4625ede31b8674d35689c11 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Aug 2007 17:33:09 +0200 Subject: [PATCH 188/581] Minor cleanup --- ccollect.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index d699963..73c47f2 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -477,7 +477,6 @@ while [ "${i}" -lt "${no_sources}" ]; do # # the rsync part - # options partly stolen from rsnapshot # _techo "Transferring files..." @@ -490,7 +489,7 @@ while [ "${i}" -lt "${no_sources}" ]; do _exit_err "Removing ${abs_destination_dir}/${c_marker} failed." _techo "Finished backup (rsync return code: $ret)." - if [ "$ret" -ne 0 ]; then + if [ "${ret}" -ne 0 ]; then _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." fi From 03a55f1b1f116e2eb650b434d95e28b2dde1d1cc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Aug 2007 17:35:37 +0200 Subject: [PATCH 189/581] Finish ccollect-logwrapper.sh, without testing --- tools/ccollect-logwrapper.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/ccollect-logwrapper.sh b/tools/ccollect-logwrapper.sh index 518201e..f2feb0c 100755 --- a/tools/ccollect-logwrapper.sh +++ b/tools/ccollect-logwrapper.sh @@ -4,8 +4,6 @@ # Date: Fr 8. Jun 10:30:24 CEST 2007 # Call the log-wrapper instead of ccollect.sh and it will create nice logs -Analyses output produced by ccollect. - # # where to find our configuration and temporary file # @@ -20,6 +18,7 @@ pid=$$ logfile="${logdir}/$(${CDATE}).${pid}" # use syslog normally +# Also use echo, can be redirected with > /dev/null if someone cares _echo() { logger "${we}-${pid}: $@" From e4969a390ae2e60c4597a3422ec5e04f8357b1ff Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Aug 2007 17:45:06 +0200 Subject: [PATCH 190/581] Update changelog, documentation and fix ccollect-logwrapper.sh --- doc/CHANGES | 1 + doc/ccollect.text | 2 +- tools/ccollect-logwrapper.sh | 13 +++++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/doc/CHANGES b/doc/CHANGES index b336b8d..16af523 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,6 +1,7 @@ 0.6 to 0.6.1: * Added check for destination_base in add_ccollect_source.sh * Add support for -V and --version + * Added ccollect-logwrapper.sh (and a manpage ;-) 0.5.2 to 0.6: * Always print return code of rsync diff --git a/doc/ccollect.text b/doc/ccollect.text index 5a29bd8..968fe33 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -0.6, for ccollect 0.6, Initial Version from 2006-01-13 +0.6, for ccollect 0.6 - 0.6.1, Initial Version from 2006-01-13 :Author Initials: NS diff --git a/tools/ccollect-logwrapper.sh b/tools/ccollect-logwrapper.sh index f2feb0c..6142385 100755 --- a/tools/ccollect-logwrapper.sh +++ b/tools/ccollect-logwrapper.sh @@ -12,7 +12,7 @@ LOGCONF=$CCOLLECT_CONF/logwrapper logdir="${LOGCONF}/destination" CDATE="date +%Y%m%d-%H%M" -we="$(basenae $0)" +we="$(basename $0)" pid=$$ logfile="${logdir}/$(${CDATE}).${pid}" @@ -21,8 +21,9 @@ logfile="${logdir}/$(${CDATE}).${pid}" # Also use echo, can be redirected with > /dev/null if someone cares _echo() { - logger "${we}-${pid}: $@" - echo "${we}-${pid}: $@" + string="${we} (${pid}): $@" + logger "${string}" + echo "${string}" } @@ -37,5 +38,9 @@ _exit_err() # put everything into that specified file _echo "Starting with arguments: $@" touch "${logfile}" || _exit_err "Failed to create ${logfile}" -ccollect.sh "$@" > "${logfile}" 2>&1 + +# First line in the logfile is always the commandline +echo ccollect.sh "$@" > "${logfile}" 2>&1 +ccollect.sh "$@" >> "${logfile}" 2>&1 + _echo "Finished." From 916e0cb2ff0583dfd7d16a5aec22029563bdc0ce Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Aug 2007 18:07:10 +0200 Subject: [PATCH 191/581] Add manpage for the logwrapper --- doc/man/ccollect-logwrapper.text | 55 ++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 doc/man/ccollect-logwrapper.text diff --git a/doc/man/ccollect-logwrapper.text b/doc/man/ccollect-logwrapper.text new file mode 100644 index 0000000..189244f --- /dev/null +++ b/doc/man/ccollect-logwrapper.text @@ -0,0 +1,55 @@ +ccollect_logwrapper(1) +====================== +Nico Schottelius + + +NAME +---- +ccollect_logwrapper - start ccollect(1) and create a unique log + + +SYNOPSIS +-------- +'ccollect_logwrapper.sh' + + +DESCRIPTION +----------- +ccollect_logwrapper.sh creates a unique logfile below +'$CCOLLECT_CONF/logwrapper' and redirects ccollect(1) output +(stdout and stderr) to it. + + +OPTIONS +------- +Options are passed directly to ccollect(1). + + +FILES +----- +$CCOLLECT_CONF/logwrapper:: + Directory containing the configuration. $CCOLLECT_CONF is '/etc/ccollect', if unset. + +$CCOLLECT_CONF/logwrapper/destination:: + Link to the destination directory for the logfiles + +SEE ALSO +-------- +add_ccollect_source(1), ccollect(1), +delete_ccollect_source(1), list_ccollect_intervals(1) + + +AUTHOR +------ +Nico Schottelius + + +RESOURCES +--------- +Main web site: http://unix.schottelius.org/ccollect/[] + + +COPYING +------- +Copyright \(C) 2007 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License Version 3 (GPLv3). From b007d346eb6082b7f0d5752094a633ad8db10695 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Aug 2007 18:09:48 +0200 Subject: [PATCH 192/581] Update documentation for ccollect-logwrapper --- Makefile | 1 + doc/CHANGES | 5 ++++- doc/man/add_ccollect_source.text | 3 ++- doc/man/ccollect.text | 3 ++- doc/man/delete_ccollect_source.text | 3 ++- doc/man/list_ccollect_intervals.text | 3 ++- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 763e492..b5a7995 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,7 @@ docdir=${dir}/doc MANDOCS = doc/man/ccollect.text \ doc/man/add_ccollect_source.text \ doc/man/delete_ccollect_source.text \ + doc/man/ccollect-logwrapper.text \ doc/man/list_ccollect_intervals.text DOCS = ${MANDOCS} doc/ccollect.text doc/ccollect-DE.text diff --git a/doc/CHANGES b/doc/CHANGES index 16af523..996c3b0 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,7 +1,10 @@ 0.6 to 0.6.1: * Added check for destination_base in add_ccollect_source.sh - * Add support for -V and --version + * Added support for -V and --version * Added ccollect-logwrapper.sh (and a manpage ;-) + * Changed behaviour: ccollect now clones from the latest existing backup, + independent of the interval. This way different intervals do not + diverge. ccollect uses ls -c to determine latest backup. 0.5.2 to 0.6: * Always print return code of rsync diff --git a/doc/man/add_ccollect_source.text b/doc/man/add_ccollect_source.text index 8421d69..98f4198 100644 --- a/doc/man/add_ccollect_source.text +++ b/doc/man/add_ccollect_source.text @@ -53,7 +53,8 @@ source_postfix:: SEE ALSO -------- -ccollect(1), delete_ccollect_source(1), list_ccollect_intervals(1) +ccollect(1), ccollect-logwrapper(1), +delete_ccollect_source(1), list_ccollect_intervals(1) AUTHOR diff --git a/doc/man/ccollect.text b/doc/man/ccollect.text index abe4ebe..a246dbf 100644 --- a/doc/man/ccollect.text +++ b/doc/man/ccollect.text @@ -39,7 +39,8 @@ OPTIONS SEE ALSO -------- -add_ccollect_source(1), delete_ccollect_source(1), list_ccollect_intervals(1) +add_ccollect_source(1), ccollect-logwrapper(1) +delete_ccollect_source(1), list_ccollect_intervals(1) AUTHOR diff --git a/doc/man/delete_ccollect_source.text b/doc/man/delete_ccollect_source.text index 9401418..b6e05bc 100644 --- a/doc/man/delete_ccollect_source.text +++ b/doc/man/delete_ccollect_source.text @@ -36,7 +36,8 @@ $CCOLLECT_CONF/sources:: SEE ALSO -------- -add_ccollect_source(1), ccollect(1), list_ccollect_intervals(1) +add_ccollect_source(1), ccollect(1), +ccollect-logwrapper(1), list_ccollect_intervals(1) AUTHOR diff --git a/doc/man/list_ccollect_intervals.text b/doc/man/list_ccollect_intervals.text index 356e99b..6fd1a88 100644 --- a/doc/man/list_ccollect_intervals.text +++ b/doc/man/list_ccollect_intervals.text @@ -26,7 +26,8 @@ $CCOLLECT_CONF/intervals:: SEE ALSO -------- -add_ccollect_source(1), ccollect(1), delete_ccollect_source(1) +add_ccollect_source(1), ccollect(1), +ccollect-logwrapper(1), delete_ccollect_source(1) AUTHOR From 2cbfdf5bd50f22a40132357d8f236ea053e5feac Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Aug 2007 18:20:31 +0200 Subject: [PATCH 193/581] Add section about ccollect-logwrapper in the manual --- doc/ccollect.text | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/ccollect.text b/doc/ccollect.text index 968fe33..92a95ae 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -511,6 +511,21 @@ the user. Hints ----- +Smart logging +~~~~~~~~~~~~~ +Since ccollect-0.6.1 you can use the ccollect-logwrapper.sh(1) for logging. +You call it the same way you call ccollect.sh and it will create a +logfile containing the output of ccollect.sh. For more information look +at the manpage 'ccollect-logwrapper'. The following is an example running +ccollect-logwrapper.sh: + +-------------------------------------------------------------------------------- +u0219 ~ # ~chdscni9/ccollect-logwrapper.sh daily u0160.nshq.ch.netstream.com +ccollect-logwrapper.sh (11722): Starting with arguments: daily u0160.nshq.ch.netstream.com +ccollect-logwrapper.sh (11722): Finished. +-------------------------------------------------------------------------------- + + Using a different ssh port ~~~~~~~~~~~~~~~~~~~~~~~~~~ Mostly easy is to use your ~/.ssh/config file: From dcf92a1788a00015b236ddfe9d6f1bd04a892ccc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Aug 2007 18:21:54 +0200 Subject: [PATCH 194/581] Update release date --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index 73c47f2..a123ca2 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -15,7 +15,7 @@ CPOSTEXEC="${CDEFAULTS}/post_exec" TMP=$(mktemp "/tmp/$(basename $0).XXXXXX") VERSION=0.6.1 -RELEASE="2007-08-XX" +RELEASE="2007-08-20" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" From 7511d3f78388d2e14db0fdc22cc0c37218af4aa6 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 20 Aug 2007 18:27:50 +0200 Subject: [PATCH 195/581] Fix typo --- doc/man/ccollect-logwrapper.text | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/man/ccollect-logwrapper.text b/doc/man/ccollect-logwrapper.text index 189244f..e1a4d6c 100644 --- a/doc/man/ccollect-logwrapper.text +++ b/doc/man/ccollect-logwrapper.text @@ -1,21 +1,21 @@ -ccollect_logwrapper(1) +ccollect-logwrapper(1) ====================== Nico Schottelius NAME ---- -ccollect_logwrapper - start ccollect(1) and create a unique log +ccollect-logwrapper - start ccollect(1) and create a unique log SYNOPSIS -------- -'ccollect_logwrapper.sh' +'ccollect-logwrapper.sh' DESCRIPTION ----------- -ccollect_logwrapper.sh creates a unique logfile below +ccollect-logwrapper.sh creates a unique logfile below '$CCOLLECT_CONF/logwrapper' and redirects ccollect(1) output (stdout and stderr) to it. From c7ae7fc3220d96c165618294700d71552e0cdebd Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 21 Aug 2007 17:49:15 +0200 Subject: [PATCH 196/581] Add template for analyse-ccollect-logs.sh --- tools/analyse-ccollect-logs.sh | 92 ++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 tools/analyse-ccollect-logs.sh diff --git a/tools/analyse-ccollect-logs.sh b/tools/analyse-ccollect-logs.sh new file mode 100755 index 0000000..ab69563 --- /dev/null +++ b/tools/analyse-ccollect-logs.sh @@ -0,0 +1,92 @@ +#!/bin/sh +# Nico Schottelius +# written for Netstream (www.netstream.ch) +# Date: Di 21. Aug 17:10:15 CEST 2007 +# Analyse existing logs + +# Interesting strings in the logs: +# -------------------------------------------------------- +# err +# [ddba017.netstream.ch] receiving file list ... cannot send long-named file "/usr/local/www/apache22/cgi-bin/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/ backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/bac kup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup /backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/ba ckup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backu p/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/back" +#[ddba033.netstream.ch] rsync: readlink "/usr/local/inetpub2/webmailroot/2wire.ch/royal@2wire.ch" failed: Input/output error (5) +#[ddba033.netstream.ch] WARNING: usr/local/inetpub2/netstream/adsl.netstream.ch/mrtg/lbswiss.rrd failed verification -- update discarded (will try again). +#[ddba033.netstream.ch] rsync: read errors mapping "/usr/local/inetpub2/netstream/adsl.netstream.ch/mrtg/lbswiss.rrd": Input/output error (5) +#[ddba033.netstream.ch] ERROR: usr/local/inetpub2/netstream/adsl.netstream.ch/mrtg/lbswiss.rrd failed verification -- update discarded. +#[ddba033.netstream.ch] rsync: read errors mapping "/usr/local/inetpub2/netstream/adsl.netstream.ch/mrtg/lbswiss.rrd": Input/output error (5) +#[ddba049.netstream.ch] receiving file list ... rsync: readdir("/proc"): Invalid argument (22) +#[zrha165.netstream.ch] Read from remote host zrha165.netstream.ch: Connection reset by peer +#[zrha165.netstream.ch] rsync: connection unexpectedly closed (10722819 bytes received so far) [receiver] +#[zrha165.netstream.ch] rsync error: error in rsync protocol data stream (code 12) at io.c(453) [receiver=2.6.9] +#[zrha165.netstream.ch] rsync: connection unexpectedly closed (10710627 bytes received so far) [generator] +#[zrha165.netstream.ch] rsync error: unexplained error (code 255) at io.c(453) [generator=2.6.9] +#[zrha165.netstream.ch] 2007-08-21-03:32:04: Finished backup (rsync return code: 255). +#[zrha166.netstream.ch] Read from remote host zrha166.netstream.ch: Connection reset by peer +#[zrha166.netstream.ch] rsync: connection unexpectedly closed (12731672 bytes received so far) [receiver] +#[zrha166.netstream.ch] rsync error: error in rsync protocol data stream (code 12) at io.c(453) [receiver=2.6.9] +#[zrha166.netstream.ch] rsync: connection unexpectedly closed (12721988 bytes received so far) [generator] +#[zrha166.netstream.ch] rsync error: unexplained error (code 255) at io.c(453) [generator=2.6.9] +#[zrha166.netstream.ch] 2007-08-21-03:12:15: Finished backup (rsync return code: 255). +# Read from remote host .*: Connection timed out +# rsync: mknod .* failed: Invalid argument (22) + +# warn +# [ddba015.netstream.ch] send_files failed to open /usr/local/dnscache/log/main/@4000000046ca0f3616939c14.s: No such file or directory +# [ddba015.netstream.ch] 2007-08-21-02:17:28: Finished backup (rsync return code: 23). +# [ddba017.netstream.ch] file has vanished: "/var/spool/postfix/active/657575D686" +#[ddba026.netstream.ch] 2007-08-21-05:35:13: Finished backup (rsync return code: 24). +#[ddba045.netstream.ch] send_files failed to open /data/hsphere/local/var/named/logs/@4000000046c98fa9079f39ac.s: No such file or directory +# file has vanished: ".*" + +# info: +# [u0160.nshq.ch.netstream.com] Total file size: 1694612169 bytes +# [u0160.nshq.ch.netstream.com] Total transferred file size: 17997414 bytes +# [u0160.nshq.ch.netstream.com] 2007-08-20-18:26:06: Backup lasted: 0:43:34 (h:m:s) +#[ddba012.netstream.ch] sent 3303866 bytes received 1624630525 bytes 122700.92 bytes/sec +#[ddba012.netstream.ch] total size is 22384627486 speedup is 13.75 +#[ddba012.netstream.ch] 2007-08-21-04:03:21: Finished backup (rsync return code: 0). +# speedup is +# error codes + + + + +# +# where to find our configuration and temporary file +# +CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} +LOGCONF=$CCOLLECT_CONF/logwrapper + +logdir="${LOGCONF}/destination" +CDATE="date +%Y%m%d-%H%M" +we="$(basename $0)" +pid=$$ + +logfile="${logdir}/$(${CDATE}).${pid}" + +# use syslog normally +# Also use echo, can be redirected with > /dev/null if someone cares +_echo() +{ + string="${we} (${pid}): $@" + logger "${string}" + echo "${string}" +} + + +# exit on error +_exit_err() +{ + _echo "$@" + rm -f "${TMP}" + exit 1 +} + +# put everything into that specified file +_echo "Starting with arguments: $@" +touch "${logfile}" || _exit_err "Failed to create ${logfile}" + +# First line in the logfile is always the commandline +echo ccollect.sh "$@" > "${logfile}" 2>&1 +ccollect.sh "$@" >> "${logfile}" 2>&1 + +_echo "Finished." From 327e901527f7581467162a832e7a6b01fe9c51cf Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 24 Aug 2007 15:44:00 +0200 Subject: [PATCH 197/581] Export logfile name, output errors on stderr --- tools/ccollect-logwrapper.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/ccollect-logwrapper.sh b/tools/ccollect-logwrapper.sh index 6142385..c2b0c2e 100755 --- a/tools/ccollect-logwrapper.sh +++ b/tools/ccollect-logwrapper.sh @@ -15,7 +15,7 @@ CDATE="date +%Y%m%d-%H%M" we="$(basename $0)" pid=$$ -logfile="${logdir}/$(${CDATE}).${pid}" +export ccollect_logfile="${logdir}/$(${CDATE}).${pid}" # use syslog normally # Also use echo, can be redirected with > /dev/null if someone cares @@ -30,17 +30,17 @@ _echo() # exit on error _exit_err() { - _echo "$@" + _echo "$@" >&2 rm -f "${TMP}" exit 1 } # put everything into that specified file _echo "Starting with arguments: $@" -touch "${logfile}" || _exit_err "Failed to create ${logfile}" +touch "${ccollect_logfile}" || _exit_err "Failed to create ${ccollect_logfile}" # First line in the logfile is always the commandline -echo ccollect.sh "$@" > "${logfile}" 2>&1 -ccollect.sh "$@" >> "${logfile}" 2>&1 +echo ccollect.sh "$@" > "${ccollect_logfile}" 2>&1 +ccollect.sh "$@" >> "${ccollect_logfile}" 2>&1 _echo "Finished." From feea0661a7e4b4270e2b869155e1a3acebcaba61 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Aug 2007 18:56:03 +0200 Subject: [PATCH 198/581] use . as a seperator for marking, not directly in the dir, which will be removed anyway. --- ccollect.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index a123ca2..c621648 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -14,7 +14,7 @@ CPREEXEC="${CDEFAULTS}/pre_exec" CPOSTEXEC="${CDEFAULTS}/post_exec" TMP=$(mktemp "/tmp/$(basename $0).XXXXXX") -VERSION=0.6.1 +VERSION=0.6.2 RELEASE="2007-08-20" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" @@ -394,10 +394,10 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Check for incomplete backups # - ( cd "${c_dest}" 2>/dev/null && ls -1 "${INTERVAL}"*"/${c_marker}" > "${TMP}" 2>/dev/null) + ( cd "${c_dest}" 2>/dev/null && ls -1 "${INTERVAL}"*".${c_marker}" > "${TMP}" 2>/dev/null) while read incomplete; do - realincomplete=$(echo ${incomplete} | sed "s/${c_marker}\$//") + realincomplete=$(echo ${incomplete} | sed "s/\\.${c_marker}\$//") _techo "Incomplete backup: ${realincomplete}" if [ "${DELETE_INCOMPLETE}" = "yes" ]; then _techo "Deleting ${realincomplete} ..." @@ -422,7 +422,7 @@ while [ "${i}" -lt "${no_sources}" ]; do _techo "Removing ${remove} backup(s)..." ( cd "${c_dest}" 2>/dev/null && ls -p1 | grep "^${INTERVAL}\..*/\$" | \ - sort -n | head -n "${remove}" > "${TMP}" ) + sort -n | head -n "${remove}" ) > "${TMP}" while read to_remove; do _techo "Removing ${to_remove} ..." From 5acca63d53e7427f190be1649a07edef6d84248c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Aug 2007 18:57:14 +0200 Subject: [PATCH 199/581] [BUGFIX]: Removing of backups was broken (forgot to prepend the path :/) --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index c621648..cc902c5 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -426,7 +426,7 @@ while [ "${i}" -lt "${no_sources}" ]; do while read to_remove; do _techo "Removing ${to_remove} ..." - rm ${VVERBOSE} -rf "$to_remove" || \ + rm ${VVERBOSE} -rf "${c_dest}/${to_remove}" || \ _exit_err "Removing ${to_remove} failed." done < "${TMP}" fi From c2cbd983c888371b11f8635228a3923f8990cc7b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Aug 2007 18:59:10 +0200 Subject: [PATCH 200/581] Finish mostly analyse-logs --- tools/analyse-ccollect-logs.sh | 157 +++++++++++++++++---------------- 1 file changed, 82 insertions(+), 75 deletions(-) diff --git a/tools/analyse-ccollect-logs.sh b/tools/analyse-ccollect-logs.sh index ab69563..6ceb414 100755 --- a/tools/analyse-ccollect-logs.sh +++ b/tools/analyse-ccollect-logs.sh @@ -4,32 +4,68 @@ # Date: Di 21. Aug 17:10:15 CEST 2007 # Analyse existing logs -# Interesting strings in the logs: -# -------------------------------------------------------- -# err -# [ddba017.netstream.ch] receiving file list ... cannot send long-named file "/usr/local/www/apache22/cgi-bin/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/ backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/bac kup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup /backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/ba ckup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backu p/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/back" -#[ddba033.netstream.ch] rsync: readlink "/usr/local/inetpub2/webmailroot/2wire.ch/royal@2wire.ch" failed: Input/output error (5) -#[ddba033.netstream.ch] WARNING: usr/local/inetpub2/netstream/adsl.netstream.ch/mrtg/lbswiss.rrd failed verification -- update discarded (will try again). -#[ddba033.netstream.ch] rsync: read errors mapping "/usr/local/inetpub2/netstream/adsl.netstream.ch/mrtg/lbswiss.rrd": Input/output error (5) -#[ddba033.netstream.ch] ERROR: usr/local/inetpub2/netstream/adsl.netstream.ch/mrtg/lbswiss.rrd failed verification -- update discarded. -#[ddba033.netstream.ch] rsync: read errors mapping "/usr/local/inetpub2/netstream/adsl.netstream.ch/mrtg/lbswiss.rrd": Input/output error (5) -#[ddba049.netstream.ch] receiving file list ... rsync: readdir("/proc"): Invalid argument (22) -#[zrha165.netstream.ch] Read from remote host zrha165.netstream.ch: Connection reset by peer -#[zrha165.netstream.ch] rsync: connection unexpectedly closed (10722819 bytes received so far) [receiver] -#[zrha165.netstream.ch] rsync error: error in rsync protocol data stream (code 12) at io.c(453) [receiver=2.6.9] -#[zrha165.netstream.ch] rsync: connection unexpectedly closed (10710627 bytes received so far) [generator] -#[zrha165.netstream.ch] rsync error: unexplained error (code 255) at io.c(453) [generator=2.6.9] -#[zrha165.netstream.ch] 2007-08-21-03:32:04: Finished backup (rsync return code: 255). -#[zrha166.netstream.ch] Read from remote host zrha166.netstream.ch: Connection reset by peer -#[zrha166.netstream.ch] rsync: connection unexpectedly closed (12731672 bytes received so far) [receiver] -#[zrha166.netstream.ch] rsync error: error in rsync protocol data stream (code 12) at io.c(453) [receiver=2.6.9] -#[zrha166.netstream.ch] rsync: connection unexpectedly closed (12721988 bytes received so far) [generator] -#[zrha166.netstream.ch] rsync error: unexplained error (code 255) at io.c(453) [generator=2.6.9] -#[zrha166.netstream.ch] 2007-08-21-03:12:15: Finished backup (rsync return code: 255). -# Read from remote host .*: Connection timed out -# rsync: mknod .* failed: Invalid argument (22) +version=0.1 +date=2007-08-24 +fullversion="${version} (${date})" +args=iwe + +usage() { + echo "$(basename "$0") ${fullversion}: [iwe]" + echo "" + echo " i: print informational messages" + echo " w: print warning messages" + echo " e: print error messages" + echo "" + echo "Reading input from stdin, displaying to stdout." + exit 1 +} + +# +# read and verify argv +# +if [ "$#" -ne 1 ]; then + usage +fi +argv="$1"; shift + +wrong="$(echo ${argv} | grep -e "[^${args}]")" +if [ "${wrong}" ]; then + usage +fi + + +# set output levels +search_err="$(echo ${argv} | grep 'e')" +search_warn="$(echo ${argv} | grep 'w')" +search_info="$(echo ${argv} | grep 'i')" + +# +# Interesting strings in the logs: errors +# --------------------------------------- + +if [ "$search_err" ]; then + set -- "$@" "-e" 'Read from remote host .*: Connection timed out$' + set -- "$@" "-e" 'Read from remote host .*: Connection reset by peer$' + set -- "$@" "-e" 'rsync: .*: Invalid argument (22)$' + set -- "$@" "-e" 'rsync: .*: Input/output error (5)$' + set -- "$@" "-e" 'cannot send long-named file "' + set -- "$@" "-e" 'ERROR: .* failed verification -- update discarded.$' +fi + +# known error strings: +#[ddba049.netstream.ch] receiving file list ... rsync: readdir("/proc"): Invalid argument (22) +#[ddba033.netstream.ch] rsync: readlink "/usr/local/inetpub2/webmailroot/2wire.ch/royal@2wire.ch" failed: Input/output error (5) +#[ddba033.netstream.ch] rsync: read errors mapping "/usr/local/inetpub2/netstream/adsl.netstream.ch/mrtg/lbswiss.rrd": Input/output error (5) +#[zrha165.netstream.ch] Read from remote host zrha165.netstream.ch: Connection reset by peer +#[ddba017.netstream.ch] receiving file list ... cannot send long-named file "/usr/local/www/apache22/cgi-bin/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/ backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/bac kup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup /backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/ba ckup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backu p/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/back" +#[ddba033.netstream.ch] ERROR: usr/local/inetpub2/netstream/adsl.netstream.ch/mrtg/lbswiss.rrd failed verification -- update discarded. + + +# +# Interesting strings in the logs: warnings +# ----------------------------------------- +#[ddba033.netstream.ch] rsync: read errors mapping "/usr/local/inetpub2/netstream/adsl.netstream.ch/mrtg/lbswiss.rrd": Input/output error (5) -# warn # [ddba015.netstream.ch] send_files failed to open /usr/local/dnscache/log/main/@4000000046ca0f3616939c14.s: No such file or directory # [ddba015.netstream.ch] 2007-08-21-02:17:28: Finished backup (rsync return code: 23). # [ddba017.netstream.ch] file has vanished: "/var/spool/postfix/active/657575D686" @@ -37,56 +73,27 @@ #[ddba045.netstream.ch] send_files failed to open /data/hsphere/local/var/named/logs/@4000000046c98fa9079f39ac.s: No such file or directory # file has vanished: ".*" -# info: -# [u0160.nshq.ch.netstream.com] Total file size: 1694612169 bytes -# [u0160.nshq.ch.netstream.com] Total transferred file size: 17997414 bytes +if [ "$search_warn" ]; then + # warn on non-zero exit code + set -- "$@" "-e" 'Finished backup (rsync return code: [^0]' + set -- "$@" "-e" 'WARNING: .* failed verification -- update discarded (will try again).' +fi +# known warnings: +#[ddba033.netstream.ch] WARNING: usr/local/inetpub2/netstream/adsl.netstream.ch/mrtg/lbswiss.rrd failed verification -- update discarded (will try again). + + +# +# Interesting strings in the logs: informational +# ---------------------------------------------- +if [ "$search_info" ]; then + set -- "$@" "-e" 'total size is [[:digit:]]* speedup is' + set -- "$@" "-e" 'Backup lasted: [[:digit:]]*:[[:digit:]]\{1,2\}:[[:digit:]]* (h:m:s)$' + set -- "$@" "-e" 'send [[:digit:]]* bytes received [0-9]* bytes [0-9]* bytes/sec$' +fi + +# info includes: +#[ddba012.netstream.ch] total size is 22384627486 speedup is 13.75 # [u0160.nshq.ch.netstream.com] 2007-08-20-18:26:06: Backup lasted: 0:43:34 (h:m:s) #[ddba012.netstream.ch] sent 3303866 bytes received 1624630525 bytes 122700.92 bytes/sec -#[ddba012.netstream.ch] total size is 22384627486 speedup is 13.75 -#[ddba012.netstream.ch] 2007-08-21-04:03:21: Finished backup (rsync return code: 0). -# speedup is -# error codes - - - -# -# where to find our configuration and temporary file -# -CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} -LOGCONF=$CCOLLECT_CONF/logwrapper - -logdir="${LOGCONF}/destination" -CDATE="date +%Y%m%d-%H%M" -we="$(basename $0)" -pid=$$ - -logfile="${logdir}/$(${CDATE}).${pid}" - -# use syslog normally -# Also use echo, can be redirected with > /dev/null if someone cares -_echo() -{ - string="${we} (${pid}): $@" - logger "${string}" - echo "${string}" -} - - -# exit on error -_exit_err() -{ - _echo "$@" - rm -f "${TMP}" - exit 1 -} - -# put everything into that specified file -_echo "Starting with arguments: $@" -touch "${logfile}" || _exit_err "Failed to create ${logfile}" - -# First line in the logfile is always the commandline -echo ccollect.sh "$@" > "${logfile}" 2>&1 -ccollect.sh "$@" >> "${logfile}" 2>&1 - -_echo "Finished." +grep "$@" From a4cc7c0779c8baa4e6d28c940cf51eb994105051 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Aug 2007 18:59:26 +0200 Subject: [PATCH 201/581] Update changes for 0.6.2 --- doc/CHANGES | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/CHANGES b/doc/CHANGES index 996c3b0..7ad047f 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,8 @@ +0.6.1 to 0.6.2: + * Added analyse-ccollect-logs.sh + * Fixed bug: Removing of backups was broken since update to 0.6 + (forgot to prepend path...) + 0.6 to 0.6.1: * Added check for destination_base in add_ccollect_source.sh * Added support for -V and --version From c516175669c04a97e1b9aa23d2bd8fe5d3fb237c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Aug 2007 19:00:43 +0200 Subject: [PATCH 202/581] delete real path, print relative path --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index cc902c5..677fb86 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -402,7 +402,7 @@ while [ "${i}" -lt "${no_sources}" ]; do if [ "${DELETE_INCOMPLETE}" = "yes" ]; then _techo "Deleting ${realincomplete} ..." rm $VVERBOSE -rf "${c_dest}/${realincomplete}" || \ - _exit_err "Removing ${c_dest}/${realincomplete} failed." + _exit_err "Removing ${realincomplete} failed." fi done < "${TMP}" From f68a68a1e27c3ca38bc2fe98d7a23864a565e509 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Aug 2007 19:10:02 +0200 Subject: [PATCH 203/581] Finish problem with the marker --- ccollect.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 677fb86..7ca7bd2 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -473,7 +473,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # # added marking in 0.6 (and remove it, if successful later) # - touch "${abs_destination_dir}/${c_marker}" + touch "${abs_destination_dir}.${c_marker}" # # the rsync part @@ -485,7 +485,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # # remove marking here # - rm -f "${abs_destination_dir}/${c_marker}" || \ + rm "${abs_destination_dir}.${c_marker}" || \ _exit_err "Removing ${abs_destination_dir}/${c_marker} failed." _techo "Finished backup (rsync return code: $ret)." From ab482026f2941e80eb77a01a7cdb53a0f571364d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Aug 2007 19:13:51 +0200 Subject: [PATCH 204/581] More todo --- doc/todo/0.6.2 | 1 + doc/todo/0.6.3 | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 doc/todo/0.6.2 create mode 100644 doc/todo/0.6.3 diff --git a/doc/todo/0.6.2 b/doc/todo/0.6.2 new file mode 100644 index 0000000..05798ff --- /dev/null +++ b/doc/todo/0.6.2 @@ -0,0 +1 @@ +- fix delete_incomplete marker diff --git a/doc/todo/0.6.3 b/doc/todo/0.6.3 new file mode 100644 index 0000000..54f06cb --- /dev/null +++ b/doc/todo/0.6.3 @@ -0,0 +1,4 @@ +- add global delete_incomplete (/etc/ccollect/defaults/delete_incomplete) +- add wrapper, to do logging and analyse + * output filename in the wrapper, save into variable + * call analyser From 57a9cf489e3924c9b3a390b3fe41162dca9df6df Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Aug 2007 19:13:59 +0200 Subject: [PATCH 205/581] Changes for 0.6.2 --- doc/CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/CHANGES b/doc/CHANGES index 7ad047f..3ac5681 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -2,6 +2,8 @@ * Added analyse-ccollect-logs.sh * Fixed bug: Removing of backups was broken since update to 0.6 (forgot to prepend path...) + * Fixed bug: The marker was always deleted, because rsync deleted it. + Create it outside of the backup destination now. 0.6 to 0.6.1: * Added check for destination_base in add_ccollect_source.sh From be207d75209ab446f91d89ca9b47ab358ad57f95 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Aug 2007 19:15:35 +0200 Subject: [PATCH 206/581] update date and version --- ccollect.sh | 2 +- doc/ccollect.text | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 7ca7bd2..bc63183 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -15,7 +15,7 @@ CPOSTEXEC="${CDEFAULTS}/post_exec" TMP=$(mktemp "/tmp/$(basename $0).XXXXXX") VERSION=0.6.2 -RELEASE="2007-08-20" +RELEASE="2007-08-27" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" diff --git a/doc/ccollect.text b/doc/ccollect.text index 92a95ae..3428fd0 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -0.6, for ccollect 0.6 - 0.6.1, Initial Version from 2006-01-13 +0.6, for ccollect 0.6 - 0.6.2, Initial Version from 2006-01-13 :Author Initials: NS From 4d4ba36e6883a438d9e4eaf8bc20e62d51821ee4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Aug 2007 19:24:48 +0200 Subject: [PATCH 207/581] Add todo for 0.6.3 --- doc/todo/0.6.3 | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/todo/0.6.3 b/doc/todo/0.6.3 index 54f06cb..c3d9c29 100644 --- a/doc/todo/0.6.3 +++ b/doc/todo/0.6.3 @@ -2,3 +2,4 @@ - add wrapper, to do logging and analyse * output filename in the wrapper, save into variable * call analyser +- fix german documentation! From 5f11ffcaaf304acfc4233d8e74707d6492e29438 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 2 Oct 2007 13:27:56 +0200 Subject: [PATCH 208/581] Add readme for munin-plugins --- external/munin/README | 1 + 1 file changed, 1 insertion(+) create mode 100644 external/munin/README diff --git a/external/munin/README b/external/munin/README new file mode 100644 index 0000000..566c7f9 --- /dev/null +++ b/external/munin/README @@ -0,0 +1 @@ +Plugins for munin to be used against the logfile of ccollect. From 42e2c7e95ddfe4d9f8debdee2d293e8c2a82558d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 2 Oct 2007 13:28:14 +0200 Subject: [PATCH 209/581] Update version string --- ccollect.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index bc63183..4147e8a 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -14,8 +14,8 @@ CPREEXEC="${CDEFAULTS}/pre_exec" CPOSTEXEC="${CDEFAULTS}/post_exec" TMP=$(mktemp "/tmp/$(basename $0).XXXXXX") -VERSION=0.6.2 -RELEASE="2007-08-27" +VERSION=0.6.3 +RELEASE="2007-09-XX" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" From c49383a9df9d0f3924677e3090663e3cc743175b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 14 Feb 2008 01:13:51 +0100 Subject: [PATCH 210/581] put external tools into their own project --- external/freebsd-port/Makefile | 23 ----------------------- external/freebsd-port/distinfo | 2 -- external/freebsd-port/pkg-descr | 4 ---- external/freebsd-port/pkg-list | 1 - external/munin/README | 1 - 5 files changed, 31 deletions(-) delete mode 100644 external/freebsd-port/Makefile delete mode 100644 external/freebsd-port/distinfo delete mode 100644 external/freebsd-port/pkg-descr delete mode 100644 external/freebsd-port/pkg-list delete mode 100644 external/munin/README diff --git a/external/freebsd-port/Makefile b/external/freebsd-port/Makefile deleted file mode 100644 index c14c77d..0000000 --- a/external/freebsd-port/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -# New ports collection makefile for: oneko -# New ports collection makefile for: ccollect -# Date created: 2006-10-20 -# Whom: Nico Schottelius -# -# $FreeBSD$ -# - -PORTNAME= ccollect -PORTVERSION= 0.5.1 -CATEGORIES= sysutils archivers -MASTER_SITES= http://unix.schottelius.org/ccollect/ - -MAINTAINER= nico-fbsd-ccollect@schottelius.org -COMMENT= (pseudo) incremental (parallel) backup - -MAN1= ccollect.sh.1 -MANCOMPRESSED= no -USE_BZIP2= yes - -RUN_DEPENDS= rsync:${PORTSDIR}/net/rsync - -.include diff --git a/external/freebsd-port/distinfo b/external/freebsd-port/distinfo deleted file mode 100644 index 9e1b6fe..0000000 --- a/external/freebsd-port/distinfo +++ /dev/null @@ -1,2 +0,0 @@ -MD5 (ccollect-0.5.1.tar.bz2) = 8601a6d6de52ba839768e2804ca57499 -SIZE (ccollect-0.5.1.tar.bz2) = 37397 diff --git a/external/freebsd-port/pkg-descr b/external/freebsd-port/pkg-descr deleted file mode 100644 index c822c6e..0000000 --- a/external/freebsd-port/pkg-descr +++ /dev/null @@ -1,4 +0,0 @@ -This is a port of ccollect, a backup utility which creates -fullbackups with the space needed of incremental backups. - -WWW: http://unix.schottelius.org/ccollect/ diff --git a/external/freebsd-port/pkg-list b/external/freebsd-port/pkg-list deleted file mode 100644 index c1d82f9..0000000 --- a/external/freebsd-port/pkg-list +++ /dev/null @@ -1 +0,0 @@ -bin/ccollect.sh diff --git a/external/munin/README b/external/munin/README deleted file mode 100644 index 566c7f9..0000000 --- a/external/munin/README +++ /dev/null @@ -1 +0,0 @@ -Plugins for munin to be used against the logfile of ccollect. From 6cbfb4b8073f0371f99a0235eb2f4be415016350 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 14 Feb 2008 01:24:26 +0100 Subject: [PATCH 211/581] testcommit --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index b5a7995..677ba00 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ # ccollect # Nico Schottelius, Fri Jan 13 12:13:08 CET 2006 # +# FIXME: add prefix-support? INSTALL=install CCOLLECT_SOURCE=ccollect.sh From 923b3a387a493df85a814cba7473c81827357e6e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 4 Mar 2008 23:01:34 +0100 Subject: [PATCH 212/581] add hints for 0.6.3 --- doc/todo/0.6.3 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/todo/0.6.3 b/doc/todo/0.6.3 index c3d9c29..17ddd15 100644 --- a/doc/todo/0.6.3 +++ b/doc/todo/0.6.3 @@ -3,3 +3,12 @@ * output filename in the wrapper, save into variable * call analyser - fix german documentation! + +09:31 < Obri> telmich: hab nen kleinen tipp für ccollect +09:32 < Obri> telmich: ich habe hier hosts die nicht immer online sind, das ist dumm weil so das backup + kaputtgeht... +09:32 < Obri> telmich: ich habe jetzt das ein preexec script gebastelt: +09:32 < Obri> ping -c1 -q `cat /etc/ccollect/sources/$name/source | cut -d"@" -f2 | cut -d":" -f1` +09:33 < Obri> telmich: so bricht das backup ab wenn der host nicht erreichbar ist +09:33 < Obri> ohne dass ein altes backup entsorgt wird + From eef2d55c61cc113a8e36cd530f2786d133ca2b41 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 5 Mar 2008 00:39:17 +0100 Subject: [PATCH 213/581] begin to implement backup to a host --- ccollect.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 4147e8a..4fdca79 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -14,8 +14,8 @@ CPREEXEC="${CDEFAULTS}/pre_exec" CPOSTEXEC="${CDEFAULTS}/post_exec" TMP=$(mktemp "/tmp/$(basename $0).XXXXXX") -VERSION=0.6.3 -RELEASE="2007-09-XX" +VERSION=0.7.0 +RELEASE="2008-09-XX" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" @@ -334,10 +334,15 @@ while [ "${i}" -lt "${no_sources}" ]; do fi # - # destination _must_ be a directory + # destination can be anything rsync supports # - if [ ! -d "${c_dest}" ]; then - _exit_err "Destination ${c_dest} is not a directory. Skipping." + if [ ! -f "${c_dest}" ]; then + _exit_err "Destination ${c_dest} is not a file. Skipping." + else + destination=$(cat "${c_dest}"); ret=$? + if [ "${ret}" -ne 0 ]; then + _exit_err "Destination ${c_dest} is not readable. Skipping." + fi fi # @@ -357,7 +362,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # set -- "$@" "--archive" "--delete" "--numeric-ids" "--relative" \ - "--delete-excluded" "--sparse" + "--delete-excluded" "--sparse" # # exclude list From 1c3cd057be8a1e8f667755b174f421f66ef28e64 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 5 Mar 2008 00:46:49 +0100 Subject: [PATCH 214/581] rename tools with prefix ccollect_ Thanks dear Lucky for that hint, that is a pretty good idea! --- tools/{add_ccollect_source.sh => ccollect_add_source.sh} | 0 tools/{analyse-ccollect-logs.sh => ccollect_analyse_logs.sh} | 0 tools/{create_source.sh => ccollect_create_source.sh} | 0 tools/{create_source2.sh => ccollect_create_source2.sh} | 0 tools/{delete_ccollect_source.sh => ccollect_delete_source.sh} | 0 tools/{list_ccollect_intervals.sh => ccollect_list_intervals.sh} | 0 tools/{ccollect-logwrapper.sh => ccollect_logwrapper.sh} | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename tools/{add_ccollect_source.sh => ccollect_add_source.sh} (100%) rename tools/{analyse-ccollect-logs.sh => ccollect_analyse_logs.sh} (100%) rename tools/{create_source.sh => ccollect_create_source.sh} (100%) rename tools/{create_source2.sh => ccollect_create_source2.sh} (100%) rename tools/{delete_ccollect_source.sh => ccollect_delete_source.sh} (100%) rename tools/{list_ccollect_intervals.sh => ccollect_list_intervals.sh} (100%) rename tools/{ccollect-logwrapper.sh => ccollect_logwrapper.sh} (100%) diff --git a/tools/add_ccollect_source.sh b/tools/ccollect_add_source.sh similarity index 100% rename from tools/add_ccollect_source.sh rename to tools/ccollect_add_source.sh diff --git a/tools/analyse-ccollect-logs.sh b/tools/ccollect_analyse_logs.sh similarity index 100% rename from tools/analyse-ccollect-logs.sh rename to tools/ccollect_analyse_logs.sh diff --git a/tools/create_source.sh b/tools/ccollect_create_source.sh similarity index 100% rename from tools/create_source.sh rename to tools/ccollect_create_source.sh diff --git a/tools/create_source2.sh b/tools/ccollect_create_source2.sh similarity index 100% rename from tools/create_source2.sh rename to tools/ccollect_create_source2.sh diff --git a/tools/delete_ccollect_source.sh b/tools/ccollect_delete_source.sh similarity index 100% rename from tools/delete_ccollect_source.sh rename to tools/ccollect_delete_source.sh diff --git a/tools/list_ccollect_intervals.sh b/tools/ccollect_list_intervals.sh similarity index 100% rename from tools/list_ccollect_intervals.sh rename to tools/ccollect_list_intervals.sh diff --git a/tools/ccollect-logwrapper.sh b/tools/ccollect_logwrapper.sh similarity index 100% rename from tools/ccollect-logwrapper.sh rename to tools/ccollect_logwrapper.sh From 55edd607581157ce38c79efd94cd94221b40b3f7 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Mar 2008 17:54:04 +0100 Subject: [PATCH 215/581] rename manpages --- ...ect_source.text => ccollect_delete_source.text} | 0 ...intervals.text => ccollect_list_intervals.text} | 14 ++++++++------ ...ct-logwrapper.text => ccollect_logwrapper.text} | 0 3 files changed, 8 insertions(+), 6 deletions(-) rename doc/man/{delete_ccollect_source.text => ccollect_delete_source.text} (100%) rename doc/man/{list_ccollect_intervals.text => ccollect_list_intervals.text} (66%) rename doc/man/{ccollect-logwrapper.text => ccollect_logwrapper.text} (100%) diff --git a/doc/man/delete_ccollect_source.text b/doc/man/ccollect_delete_source.text similarity index 100% rename from doc/man/delete_ccollect_source.text rename to doc/man/ccollect_delete_source.text diff --git a/doc/man/list_ccollect_intervals.text b/doc/man/ccollect_list_intervals.text similarity index 66% rename from doc/man/list_ccollect_intervals.text rename to doc/man/ccollect_list_intervals.text index 6fd1a88..1e6b0a9 100644 --- a/doc/man/list_ccollect_intervals.text +++ b/doc/man/ccollect_list_intervals.text @@ -1,11 +1,11 @@ -list_ccollect_intervals(1) +ccollect_list_intervals(1) ========================== Nico Schottelius NAME ---- -list_ccollect_intervals - list available intervals from ccollect(1) +ccollect_list_intervals - list available intervals from ccollect(1) SYNOPSIS @@ -15,19 +15,21 @@ SYNOPSIS DESCRIPTION ----------- -list_ccollect_intervals.sh shows intervals specified in the configuration +ccollect_list_intervals.sh shows intervals specified in the configuration for ccollect(1). It displays the name of each interval, followed by a colon followed by the number backups to keep. + FILES ----- $CCOLLECT_CONF/intervals:: Directory containing the intervals. $CCOLLECT_CONF is '/etc/ccollect', if unset. + SEE ALSO -------- -add_ccollect_source(1), ccollect(1), -ccollect-logwrapper(1), delete_ccollect_source(1) +ccollect_add_source(1), ccollect_analyse_logs(1), +ccollect_logwrapper(1), ccollect_delete_source(1), ccollect(1) AUTHOR @@ -42,5 +44,5 @@ Main web site: http://unix.schottelius.org/ccollect/[] COPYING ------- -Copyright \(C) 2007 Nico Schottelius. Free use of this software is +Copyright \(C) 2007-2008 Nico Schottelius. Free use of this software is granted under the terms of the GNU General Public License Version 3 (GPLv3). diff --git a/doc/man/ccollect-logwrapper.text b/doc/man/ccollect_logwrapper.text similarity index 100% rename from doc/man/ccollect-logwrapper.text rename to doc/man/ccollect_logwrapper.text From bb08cd320848dfa222f1305fc208b31c3216f363 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Mar 2008 17:54:24 +0100 Subject: [PATCH 216/581] update changes --- doc/CHANGES | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/CHANGES b/doc/CHANGES index 3ac5681..0a6c223 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,12 @@ +0.6.2 to 0.7.0: + * Add capability to backup to a host + - updated documentation + * Changed "destination" format (use ... to convert pre 0.7.x configurations) + * Renamed tools to begin with "ccollect_" + * Updated ccollect_add_source.sh and added manpage + * Changed license to GPLv3 + + 0.6.1 to 0.6.2: * Added analyse-ccollect-logs.sh * Fixed bug: Removing of backups was broken since update to 0.6 From d44c3cabc577fe792d826e42b95e79c44d97039d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Mar 2008 18:05:15 +0100 Subject: [PATCH 217/581] add gpl3 header template --- doc/gpl3-header | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 doc/gpl3-header diff --git a/doc/gpl3-header b/doc/gpl3-header new file mode 100644 index 0000000..5d58165 --- /dev/null +++ b/doc/gpl3-header @@ -0,0 +1,17 @@ +# 2008 Nico Schottelius (nico-cinit at schottelius.org) +# +# This file is part of ccollect. +# +# cinit is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# From c6b49bc6942b54a1ef43ac3b63dd1b2c3d918aa9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Mar 2008 22:59:23 +0100 Subject: [PATCH 218/581] Add converter tool for 0.7 configuration --- tools/config-pre-0.7-to-0.7.sh | 35 ++++++++++++++++++ tools/config-pre-0.7-to-0.7.sub.sh | 57 ++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100755 tools/config-pre-0.7-to-0.7.sh create mode 100755 tools/config-pre-0.7-to-0.7.sub.sh diff --git a/tools/config-pre-0.7-to-0.7.sh b/tools/config-pre-0.7-to-0.7.sh new file mode 100755 index 0000000..f83341f --- /dev/null +++ b/tools/config-pre-0.7-to-0.7.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# +# 2008 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# Convert configuration to 0.6 layout + +if [ $# -ne 1 ]; then + echo "$0: ccollect-configuration directory" + echo "" + echo " Fix pre 0.7 configuration directories to match 0.7 style" + echo "" + exit 23 +fi + +dir="$1" +script=$(echo $0 | sed 's/\.sh$/.sub.sh/') + +find "${dir}/sources/" -name destination -exec "${script}" {} \; + +echo "Finished." diff --git a/tools/config-pre-0.7-to-0.7.sub.sh b/tools/config-pre-0.7-to-0.7.sub.sh new file mode 100755 index 0000000..4579924 --- /dev/null +++ b/tools/config-pre-0.7-to-0.7.sub.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# +# 2008 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# + +if [ $# -ne 1 ]; then + echo "$0: destination-file" + echo "" + echo " Fix pre 0.7 configuration directories to match 0.6 style (sub)" + echo "" + exit 23 +fi + +tmp=$(mktemp) +file="$1" + +echo "Working on $file ..." + +if [ -L "${file}" ]; then + echo "Converting ${file} ..." + dir="$(cd "${file}" && pwd)"; ret=$? + + if [ $ret -ne 0 ]; then + echo "ERROR: $file is a broken link" + exit 1 + else + echo "${dir}" > "${tmp}" + rm -f "${file}"; ret=$? + if [ $ret -ne 0 ]; then + echo "ERROR: Removing $file failed" + exit 1 + fi + mv "${tmp}" "${file}"; ret=$? + if [ $ret -ne 0 ]; then + echo "ERROR: Moving ${tmp} to ${file} failed, your source is broken." + exit 1 + fi + fi +else + echo "$file is not a link, not converting" + exit 1 +fi From f91c51d5fb19658c6286004b5d3d44f292170cba Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Mar 2008 23:01:27 +0100 Subject: [PATCH 219/581] remove cinit fragments --- doc/gpl3-header | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/gpl3-header b/doc/gpl3-header index 5d58165..5a1663d 100644 --- a/doc/gpl3-header +++ b/doc/gpl3-header @@ -1,8 +1,10 @@ -# 2008 Nico Schottelius (nico-cinit at schottelius.org) +#!/bin/sh +# +# 2008 Nico Schottelius (nico-ccollect at schottelius.org) # # This file is part of ccollect. # -# cinit is free software: you can redistribute it and/or modify +# ccollect is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. From 3819316fa2518297170f18e7ee4231268954e6f6 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Mar 2008 23:01:56 +0100 Subject: [PATCH 220/581] reflect manual change in makefile --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 677ba00..e8c302b 100644 --- a/Makefile +++ b/Makefile @@ -34,8 +34,8 @@ docdir=${dir}/doc # Asciidoc will be used to generate other formats later # MANDOCS = doc/man/ccollect.text \ - doc/man/add_ccollect_source.text \ - doc/man/delete_ccollect_source.text \ + doc/man/ccollect_add_source.text \ + doc/man/ccollect_delete_source.text \ doc/man/ccollect-logwrapper.text \ doc/man/list_ccollect_intervals.text From e87f4e9a92a2ade9d6c722c859919459c6834d0d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Mar 2008 23:03:55 +0100 Subject: [PATCH 221/581] add gpl3 header to ccollect --- ccollect.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 4fdca79..2a68079 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -1,8 +1,24 @@ #!/bin/sh -# Nico Schottelius +# +# 2005-2008 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# # Initially written for SyGroup (www.sygroup.ch) # Date: Mon Nov 14 11:45:11 CET 2005 -# Last Modified: (See ls -l or git) # # where to find our configuration and temporary file @@ -15,7 +31,7 @@ CPOSTEXEC="${CDEFAULTS}/post_exec" TMP=$(mktemp "/tmp/$(basename $0).XXXXXX") VERSION=0.7.0 -RELEASE="2008-09-XX" +RELEASE="2008-03-XX" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" From 213c15297ca2708a917c6d326f3bd4a7466051c0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Mar 2008 23:14:13 +0100 Subject: [PATCH 222/581] rename --- doc/man/{add_ccollect_source.text => ccollect_add_source.text} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename doc/man/{add_ccollect_source.text => ccollect_add_source.text} (100%) diff --git a/doc/man/add_ccollect_source.text b/doc/man/ccollect_add_source.text similarity index 100% rename from doc/man/add_ccollect_source.text rename to doc/man/ccollect_add_source.text From 16c2efa1b8ce1d5b740ef23261ed494f83a26d18 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Mar 2008 23:31:14 +0100 Subject: [PATCH 223/581] update ccollect_add_source - add gpl3 - add support for 0.7 configuration style - arrived at home with the bus 862, quite cold and snowy --- tools/ccollect_add_source.sh | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/tools/ccollect_add_source.sh b/tools/ccollect_add_source.sh index f431c7f..4a60d38 100755 --- a/tools/ccollect_add_source.sh +++ b/tools/ccollect_add_source.sh @@ -1,10 +1,27 @@ #!/bin/sh -# Nico Schottelius -# 2007-08-16 -# Written for Netstream (www.netstream.ch) +# +# 2007-2008 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# 2007-08-16: Written for Netstream (www.netstream.ch) +# # Creates a source from standard values specified in # /etc/ccollect/defaults/sources -# Copying: GPLv3 +# # standard values CCOLLECT_CONF="${CCOLLECT_CONF:-/etc/ccollect}" @@ -70,7 +87,7 @@ while [ $# -gt 0 ]; do # copy standard files for file in $standard_opts; do eval rfile=\"\$$file\" - eval filename=${SCONFIG}/${rfile} + eval filename="${SCONFIG}/${rfile}" if [ -e "${filename}" ]; then _echo Copying \"$rfile\" to ${fullname} ... cp -r "${filename}" "${fullname}/${rfile}" @@ -86,7 +103,7 @@ while [ $# -gt 0 ]; do source_source="${source_source}$(cat "${src_postfix}")" || _exit_err "${src_postfix}: Reading failed." fi _echo "Adding \"${source_source}\" as source for ${source}" - echo "${source_source}" > "${fullname}/source" + echo "${source_source}" > "${fullname}/source" || _exit_err "Creating ${fullname}/source: failed." # create destination directory absbase=$(cd "${destination_base}" 2>/dev/null && pwd -P) || \ @@ -97,9 +114,9 @@ while [ $# -gt 0 ]; do mkdir -p "${dest}" || _exit_err "${dest}: Cannot create." # link destination directory - dest_abs=$(cd "${dest}" && pwd -P) || _exit_err "${dest}: Changing to newly create dirctory failed." - ln -s "${dest_abs}" "${fullname}/destination" || \ - _exit_err "${fullname}/destination: Failed to link \"${dest_abs}\"" + dest_abs=$(cd "${dest}" && pwd -P) || _exit_err "${dest}: Changing to newly created directory failed." + echo "${dest_abs}" > "${fullname}/destination" || \ + _exit_err "${fullname}/destination: Failed to create." done From 332ce704f6b1d5821ec13b47669ae1adbd77e70b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 8 Mar 2008 00:03:58 +0100 Subject: [PATCH 224/581] Add report_success.sh --- tools/report_success.sh | 63 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 tools/report_success.sh diff --git a/tools/report_success.sh b/tools/report_success.sh new file mode 100755 index 0000000..82a6dc6 --- /dev/null +++ b/tools/report_success.sh @@ -0,0 +1,63 @@ +#!/bin/sh +# +# 2008 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# Sends feedback +# + +subject="==> success: ccollect" +to="nico-ccollect-success" +host="schottelius.org" +fullto="${to}@${host}" + +software="ccollect" +author="Nico Schottelius" +info="$(uname -s -v -r -m)" + +echo "Reporting success for $software to ${author}:" +echo "-----------------" +echo -n "Your name (leave free for anonymous): " +read name +echo -n "Your email (leave free for anonymous): " +read email +echo -n "Comment (leave free for no comment): " +read comment + +echo "" +echo "The following information will be send to ${author}:" +echo "" + +cat << eof +Name: $name (will be used to contact you and kept secret) +E-Mail: $email (will be used to contact you and kept secret) +Comment: $comment +Info: $info + +eof + +echo -n "Is it ok to send out that mail (press enter to send or ctrl-c to abort)? " +read yes + +cat << eof | mail -s "$subject" "$fullto" +Name: $name (will be used to contact you and kept secret) +E-Mail: $email (will be used to contact you and kept secret) +Comment: $comment +Info: $info +eof + +echo "Send. Thank you for your feedback." From de11135bfb81203fa6a303ca5a5ac97e960ba3a6 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 8 Mar 2008 09:29:59 +0100 Subject: [PATCH 225/581] update to 0.7, add hint to tools/report_success.sh --- README | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README b/README index 12bcdb3..cab53f1 100644 --- a/README +++ b/README @@ -2,10 +2,9 @@ ccollect.sh, Nico Schottelius, 2005-12-06 -------------------------------------------------------------------------------- -ccollect backups data from local or remote hosts to your local harddisk. +ccollect backups (local or remote) data to local or remote destinations. - -You can retriev the latest version of ccollect at [0]. +You can retrieve the latest version of ccollect at [0]. ccollect was inspired by rsnapshot [1], which has some problems: - configuration parameters has to be TAB seperated @@ -15,8 +14,10 @@ ccollect was inspired by rsnapshot [1], which has some problems: - does unecessary moving of backup directories - I didn't like the configuration at all, so I used the cconfig style [2]. +Please use tools/report_success.sh to report success, if you are successfully +using ccollect. -A small try to visualize the differnces in a table: +A small try to visualize the differences in a table: +---------------+-------------------------------------------------------------+ | What? | rsnapshot | ccollect | From 504b9c71439871497330377e21d335b2e2307e1a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 8 Mar 2008 09:43:03 +0100 Subject: [PATCH 226/581] move old tools to their own directory --- tools/{ => old}/ccollect_create_source.sh | 0 tools/{ => old}/ccollect_create_source2.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tools/{ => old}/ccollect_create_source.sh (100%) rename tools/{ => old}/ccollect_create_source2.sh (100%) diff --git a/tools/ccollect_create_source.sh b/tools/old/ccollect_create_source.sh similarity index 100% rename from tools/ccollect_create_source.sh rename to tools/old/ccollect_create_source.sh diff --git a/tools/ccollect_create_source2.sh b/tools/old/ccollect_create_source2.sh similarity index 100% rename from tools/ccollect_create_source2.sh rename to tools/old/ccollect_create_source2.sh From 33471a3c24b10318006e350ee3f5b93cb76aafc8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 9 Mar 2008 23:06:18 +0100 Subject: [PATCH 227/581] update ccollect_delete_source.sh to 0.7 style - and update manpages to the new names - on the way home from duebendorf - rapperswil - bellinzona - giubiasco - zuerich - gossau! --- doc/man/ccollect_add_source.text | 16 +++++++------ doc/man/ccollect_delete_source.text | 14 +++++------ tools/ccollect_delete_source.sh | 36 ++++++++++++++++++++--------- 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/doc/man/ccollect_add_source.text b/doc/man/ccollect_add_source.text index 98f4198..ba070d9 100644 --- a/doc/man/ccollect_add_source.text +++ b/doc/man/ccollect_add_source.text @@ -5,20 +5,21 @@ Nico Schottelius NAME ---- -add_ccollect_source - create new source for ccollect(1) +ccollect_add_source - create new source for ccollect(1) SYNOPSIS -------- -'add_ccollect_source.sh' +'ccollect_add_source.sh' DESCRIPTION ----------- -add_ccollect_source.sh creates a new backup source for use with ccollect(1). +ccollect_add_source.sh creates a new backup source for use with ccollect(1). It copies the files from to the source directory with the hostname below -'$CCOLLECT_CONF/sources'. +'$CCOLLECT_CONF/sources'. It is designed to run on a backup server to create +new directories for new hosts. FILES @@ -41,8 +42,9 @@ very_verbose:: destination_base:: A link to the directory where to store the backups. Below this directory - `add_ccollect_source.sh` will create a directory with the hostname you - specified on the command line. + `ccollect_add_source.sh` will create a directory with the hostname you + specified on the command line. A common valua for `destination_base` is + '/home/server/backup'. source_prefix:: source_postfix:: @@ -54,7 +56,7 @@ source_postfix:: SEE ALSO -------- ccollect(1), ccollect-logwrapper(1), -delete_ccollect_source(1), list_ccollect_intervals(1) +ccollect_delete_source(1), ccollect_list_intervals(1) AUTHOR diff --git a/doc/man/ccollect_delete_source.text b/doc/man/ccollect_delete_source.text index b6e05bc..36bdf9c 100644 --- a/doc/man/ccollect_delete_source.text +++ b/doc/man/ccollect_delete_source.text @@ -1,21 +1,21 @@ -delete_ccollect_source(1) +ccollect_delete_source(1) ========================= Nico Schottelius NAME ---- -delete_ccollect_source - delete sources from ccollect(1) +ccollect_delete_source - delete sources from ccollect(1) SYNOPSIS -------- -'delete_ccollect_source.sh' [-d] [-f] +'ccollect_delete_source.sh' [-d] [-f] DESCRIPTION ----------- -delete_ccollect_source.sh deletes backup sources from ccollect(1) and optional +ccollect_delete_source.sh deletes backup sources from ccollect(1) and optional also the backups created for that source. OPTIONS @@ -36,8 +36,8 @@ $CCOLLECT_CONF/sources:: SEE ALSO -------- -add_ccollect_source(1), ccollect(1), -ccollect-logwrapper(1), list_ccollect_intervals(1) +ccollect_add_source(1), ccollect(1), +ccollect-logwrapper(1), ccollect_list_intervals(1) AUTHOR @@ -52,5 +52,5 @@ Main web site: http://unix.schottelius.org/ccollect/[] COPYING ------- -Copyright \(C) 2007 Nico Schottelius. Free use of this software is +Copyright \(C) 2007-2008 Nico Schottelius. Free use of this software is granted under the terms of the GNU General Public License Version 3 (GPLv3). diff --git a/tools/ccollect_delete_source.sh b/tools/ccollect_delete_source.sh index 8a811d3..d7dd2e1 100755 --- a/tools/ccollect_delete_source.sh +++ b/tools/ccollect_delete_source.sh @@ -1,9 +1,24 @@ #!/bin/sh -# Nico Schottelius -# 2007-08-16 -# Written for Netstream (www.netstream.ch) +# +# 2007-2008 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# 2007-08-16 Written for Netstream (www.netstream.ch) # Delete sources and their backups (optionally). -# Copying: GPLv3 (See file COPYING in top directory) # standard values CCOLLECT_CONF="${CCOLLECT_CONF:-/etc/ccollect}" @@ -37,11 +52,10 @@ force="" backups="" while [ $# -gt 0 ]; do - if [ "$params_possible" ]; then case "$1" in "-f"|"--force") - force=yes + force="-r" shift; continue ;; "-d"|"--destination") @@ -81,14 +95,14 @@ while [ $# -gt 0 ]; do fi if [ "$backups" ]; then - ddir=$(cd "${fullname}/destination" && pwd -P) || _exit_err "Cannot change to ${fullname}/destination" - _echo "Deleting ${ddir} ..." - rm -r "${ddir}" + ddir="$(cat "${fullname}/destination")" + addir="$(cd && pwd -P)" || _exit_err "Cannot change to ${ddir}" + _echo "Deleting ${addir} ..." + rm -r $force "${addir}" fi _echo "Deleting ${fullname} ..." - rm -r "${fullname}" - + rm -r $force "${fullname}" done exit 0 From 9c67edbf5b4e27b365cfed69ee0fd5a2d3cee69c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 9 Mar 2008 23:09:11 +0100 Subject: [PATCH 228/581] add gpl3 header to ccollect_list_intervals.sh --- tools/ccollect_list_intervals.sh | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/tools/ccollect_list_intervals.sh b/tools/ccollect_list_intervals.sh index 47c1481..d95bbde 100755 --- a/tools/ccollect_list_intervals.sh +++ b/tools/ccollect_list_intervals.sh @@ -1,9 +1,23 @@ #!/bin/sh +# +# 2006-2008 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. # -# Nico Schottelius -# Date: 24-Jun-2006 -# Last Modified: - -# Copying: GPLv3 (See file COPYING in top directory) +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# Initially written on 24-Jun-2006 # CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} From 18c20b63158b7badede27aad7196771ed80bc21c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 9 Mar 2008 23:20:49 +0100 Subject: [PATCH 229/581] add gplv3 header to ccollect_logwrapper.sh --- tools/ccollect_logwrapper.sh | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tools/ccollect_logwrapper.sh b/tools/ccollect_logwrapper.sh index c2b0c2e..9afa557 100755 --- a/tools/ccollect_logwrapper.sh +++ b/tools/ccollect_logwrapper.sh @@ -1,7 +1,24 @@ #!/bin/sh -# Nico Schottelius -# written for Netstream (www.netstream.ch) -# Date: Fr 8. Jun 10:30:24 CEST 2007 +# +# 2007-2008 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# Written for Netstream (www.netstream.ch) on Fr 8. Jun 10:30:24 CEST 2007 +# # Call the log-wrapper instead of ccollect.sh and it will create nice logs # From 439a38533a09bab12c9ba0505ebafb84d755981d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 9 Mar 2008 23:25:02 +0100 Subject: [PATCH 230/581] add minimal header to ccollect-stats.sh --- tools/ccollect-stats.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/ccollect-stats.sh b/tools/ccollect-stats.sh index 5ce171b..273ca65 100644 --- a/tools/ccollect-stats.sh +++ b/tools/ccollect-stats.sh @@ -1,5 +1,13 @@ #!/bin/sh +# +# 2007 Daniel Aubry +# 2008 Nico Schottelius (added minimal header) +# +# Copying license unknown +# +# TODO: +# add variables, add copying, add configuration if [ ! -e /tmp/ccollect-stats.lock ] then From 4519ac85d63e6d7419d86211fa8d4eb2c6c9ba59 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 9 Mar 2008 23:25:28 +0100 Subject: [PATCH 231/581] rename it to include new prefix --- tools/{ccollect-stats.sh => ccollect_stats.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/{ccollect-stats.sh => ccollect_stats.sh} (100%) diff --git a/tools/ccollect-stats.sh b/tools/ccollect_stats.sh similarity index 100% rename from tools/ccollect-stats.sh rename to tools/ccollect_stats.sh From 95e33b844d665cb52f8bbbcd66312bda1e9af95d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 9 Mar 2008 23:28:51 +0100 Subject: [PATCH 232/581] move todos to new version --- doc/todo/{0.6.3 => 0.7.1} | 0 doc/todo/{netstream-1 => 0.7.2} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename doc/todo/{0.6.3 => 0.7.1} (100%) rename doc/todo/{netstream-1 => 0.7.2} (100%) diff --git a/doc/todo/0.6.3 b/doc/todo/0.7.1 similarity index 100% rename from doc/todo/0.6.3 rename to doc/todo/0.7.1 diff --git a/doc/todo/netstream-1 b/doc/todo/0.7.2 similarity index 100% rename from doc/todo/netstream-1 rename to doc/todo/0.7.2 From 65c329e89279f837a4d0d92cbdb93d81974dab30 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 10 Mar 2008 08:30:43 +0100 Subject: [PATCH 233/581] and also something todo for 0.7.3 --- doc/todo/0.7.3 | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 doc/todo/0.7.3 diff --git a/doc/todo/0.7.3 b/doc/todo/0.7.3 new file mode 100644 index 0000000..73e5ffc --- /dev/null +++ b/doc/todo/0.7.3 @@ -0,0 +1,2 @@ +- add -a (archive) to ccollect_delete_source.text +- add listing of intervals to ccollect_list_intervals From 4487f89fb14fdb8b00cd4107b05c2834793da952 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 10 Mar 2008 08:32:51 +0100 Subject: [PATCH 234/581] update manpages --- doc/man/ccollect.text | 10 ++++++---- doc/man/ccollect_add_source.text | 8 ++++---- doc/man/ccollect_delete_source.text | 7 ++++--- doc/man/ccollect_list_intervals.text | 6 +++--- doc/man/ccollect_logwrapper.text | 13 +++++++------ 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/doc/man/ccollect.text b/doc/man/ccollect.text index a246dbf..d824717 100644 --- a/doc/man/ccollect.text +++ b/doc/man/ccollect.text @@ -20,7 +20,8 @@ It does not depend on a specific shell, only `/bin/sh` needs to be bourne shell compatibel (like 'dash', 'ksh', 'zsh', 'bash', ...). For more information refer to the manual titled -"ccollect - Installing, Configuring and Using" (available as texinfo or html). +"ccollect - Installing, Configuring and Using" (available as text (asciidoc), +texinfo or html). OPTIONS @@ -37,10 +38,11 @@ OPTIONS -v, --verbose:: Be very verbose (uses set -x). + SEE ALSO -------- -add_ccollect_source(1), ccollect-logwrapper(1) -delete_ccollect_source(1), list_ccollect_intervals(1) +ccollect_add_source(1), ccollect_analyse_logs(1), ccollect_logwrapper(1) +ccollect_delete_source(1), ccollect_list_intervals(1) AUTHOR @@ -55,5 +57,5 @@ Main web site: http://unix.schottelius.org/ccollect/[] COPYING ------- -Copyright \(C) 2006-2007 Nico Schottelius. Free use of this software is +Copyright \(C) 2006-2008 Nico Schottelius. Free use of this software is granted under the terms of the GNU General Public License Version 3 (GPLv3). diff --git a/doc/man/ccollect_add_source.text b/doc/man/ccollect_add_source.text index ba070d9..25e58a3 100644 --- a/doc/man/ccollect_add_source.text +++ b/doc/man/ccollect_add_source.text @@ -1,4 +1,4 @@ -add_ccollect_source(1) +ccollect_add_source(1) ====================== Nico Schottelius @@ -55,8 +55,8 @@ source_postfix:: SEE ALSO -------- -ccollect(1), ccollect-logwrapper(1), -ccollect_delete_source(1), ccollect_list_intervals(1) +ccollect(1), ccollect_analyse_logs.sh, ccollect_delete_source(1), +ccollect_list_intervals(1), ccollect_logwrapper(1), AUTHOR @@ -71,5 +71,5 @@ Main web site: http://unix.schottelius.org/ccollect/[] COPYING ------- -Copyright \(C) 2007 Nico Schottelius. Free use of this software is +Copyright \(C) 2007-2008 Nico Schottelius. Free use of this software is granted under the terms of the GNU General Public License Version 3 (GPLv3). diff --git a/doc/man/ccollect_delete_source.text b/doc/man/ccollect_delete_source.text index 36bdf9c..9656271 100644 --- a/doc/man/ccollect_delete_source.text +++ b/doc/man/ccollect_delete_source.text @@ -18,6 +18,7 @@ DESCRIPTION ccollect_delete_source.sh deletes backup sources from ccollect(1) and optional also the backups created for that source. + OPTIONS ------- -d: @@ -26,7 +27,7 @@ OPTIONS it recursively. -f: Force deletion. Do not ask. Very handy for people who know what they do. - Very dangerous for everyone. + Very dangerous for everyone else. FILES @@ -36,8 +37,8 @@ $CCOLLECT_CONF/sources:: SEE ALSO -------- -ccollect_add_source(1), ccollect(1), -ccollect-logwrapper(1), ccollect_list_intervals(1) +ccollect(1), ccollect_add_source(1), ccollect_add_source(1), +ccollect_logwrapper(1), ccollect_list_intervals(1) AUTHOR diff --git a/doc/man/ccollect_list_intervals.text b/doc/man/ccollect_list_intervals.text index 1e6b0a9..051b087 100644 --- a/doc/man/ccollect_list_intervals.text +++ b/doc/man/ccollect_list_intervals.text @@ -10,7 +10,7 @@ ccollect_list_intervals - list available intervals from ccollect(1) SYNOPSIS -------- -'list_ccollect_intervals.sh' +'ccollect_list_intervals.sh' DESCRIPTION @@ -28,8 +28,8 @@ $CCOLLECT_CONF/intervals:: SEE ALSO -------- -ccollect_add_source(1), ccollect_analyse_logs(1), -ccollect_logwrapper(1), ccollect_delete_source(1), ccollect(1) +collect(1), ccollect_add_source(1), ccollect_analyse_logs(1), +ccollect_delete_source(1), ccollect_logwrapper(1) AUTHOR diff --git a/doc/man/ccollect_logwrapper.text b/doc/man/ccollect_logwrapper.text index e1a4d6c..6dca801 100644 --- a/doc/man/ccollect_logwrapper.text +++ b/doc/man/ccollect_logwrapper.text @@ -5,17 +5,17 @@ Nico Schottelius NAME ---- -ccollect-logwrapper - start ccollect(1) and create a unique log +ccollect_logwrapper - start ccollect(1) and create a unique logfile SYNOPSIS -------- -'ccollect-logwrapper.sh' +'ccollect_logwrapper.sh' DESCRIPTION ----------- -ccollect-logwrapper.sh creates a unique logfile below +ccollect_logwrapper.sh creates a unique logfile below '$CCOLLECT_CONF/logwrapper' and redirects ccollect(1) output (stdout and stderr) to it. @@ -33,10 +33,11 @@ $CCOLLECT_CONF/logwrapper:: $CCOLLECT_CONF/logwrapper/destination:: Link to the destination directory for the logfiles + SEE ALSO -------- -add_ccollect_source(1), ccollect(1), -delete_ccollect_source(1), list_ccollect_intervals(1) +ccollect(1), ccollect_add_source(1), ccollect_analyse_logs(1), +ccollect_delete_source(1), ccollect_list_intervals(1) AUTHOR @@ -51,5 +52,5 @@ Main web site: http://unix.schottelius.org/ccollect/[] COPYING ------- -Copyright \(C) 2007 Nico Schottelius. Free use of this software is +Copyright \(C) 2007-2008 Nico Schottelius. Free use of this software is granted under the terms of the GNU General Public License Version 3 (GPLv3). From d617cbcb26ccc73eacdf691d722fd7fd92c044c4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 13 Mar 2008 00:22:26 +0100 Subject: [PATCH 235/581] add gpl3 header to Makefile --- Makefile | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e8c302b..f519c6a 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,25 @@ # -# ccollect -# Nico Schottelius, Fri Jan 13 12:13:08 CET 2006 +# 2006-2008 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# Initially written on Fri Jan 13 12:13:08 CET 2006 # # FIXME: add prefix-support? +# INSTALL=install CCOLLECT_SOURCE=ccollect.sh @@ -35,9 +52,10 @@ docdir=${dir}/doc # MANDOCS = doc/man/ccollect.text \ doc/man/ccollect_add_source.text \ + doc/man/ccollect_analyse_logs.text \ doc/man/ccollect_delete_source.text \ - doc/man/ccollect-logwrapper.text \ - doc/man/list_ccollect_intervals.text + doc/man/ccollect_logwrapper.text \ + doc/man/ccollect_list_intervals.text DOCS = ${MANDOCS} doc/ccollect.text doc/ccollect-DE.text From 09876ee932b5c887494a4c580cab3f8bf45cb71b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 14 Mar 2008 06:48:33 +0100 Subject: [PATCH 236/581] add exec test script --- test/exec.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 test/exec.sh diff --git a/test/exec.sh b/test/exec.sh new file mode 100755 index 0000000..31d40db --- /dev/null +++ b/test/exec.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +host="home.schottelius.org" + +pcmd() +{ + if [ "$host" ]; then + ssh "$host" "$@" + else + "$@" + fi +} + +pcmd ls / +pcmd cd /; ls "/is not there" From 89b4c993a53ce0a853b9237225317a98d4afef3a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 14 Mar 2008 06:50:24 +0100 Subject: [PATCH 237/581] import new pcmd --- ccollect.sh | 62 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 2a68079..329c473 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -75,6 +75,15 @@ add_name() sed "s:^:\[${name}\] :" } +pcmd() +{ + if [ "$remote_server" ]; then + ssh "$host" "$@" + else + "$@" + fi +} + # # Version # @@ -273,6 +282,7 @@ while [ "${i}" -lt "${no_sources}" ]; do c_pre_exec="${backup}/pre_exec" c_post_exec="${backup}/post_exec" c_incomplete="${backup}/delete_incomplete" + c_remote_host="${backup}/remote_host" # # Marking backups: If we abort it's not removed => Backup is broken @@ -343,24 +353,47 @@ while [ "${i}" -lt "${no_sources}" ]; do if [ ! -f "${c_source}" ]; then _exit_err "Source description \"${c_source}\" is not a file. Skipping." else - source=$(cat "${c_source}"); ret=$? - if [ ${ret} -ne 0 ]; then + source=$(cat "${c_source}"); ret="$?" + if [ "${ret}" -ne 0 ]; then _exit_err "Source ${c_source} is not readable. Skipping." fi fi # - # destination can be anything rsync supports + # Destination is a path # if [ ! -f "${c_dest}" ]; then _exit_err "Destination ${c_dest} is not a file. Skipping." else - destination=$(cat "${c_dest}"); ret=$? + ddir=$(cat "${c_dest}"); ret="$?" if [ "${ret}" -ne 0 ]; then _exit_err "Destination ${c_dest} is not readable. Skipping." fi fi + # + # do we backup to a remote host? then set pre-cmd + # + if [ -f "${c_remote_host}" ]; then + # adjust ls and co + remote_host=$(cat "${c_remote_host}"); ret="$?" + if [ "${ret}" -ne 0 ]; then + _exit_err "Remote host file ${c_remote_host} exists, but is not readable. Skipping." + fi + pcmd="ssh ${remote_host}" + destination="${remote_host}:${ddir}" + else + pcmd="" + destination="${ddir}" + fi + + # + # check for existence / use real name + # + # FIXME: ssh / grouping + ddir=$($pcmd (cd "$ddir" || _exit_err "Cannot change to ${ddir}. Skipping." + + # # Check whether to delete incomplete backups # @@ -415,14 +448,17 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Check for incomplete backups # - ( cd "${c_dest}" 2>/dev/null && ls -1 "${INTERVAL}"*".${c_marker}" > "${TMP}" 2>/dev/null) + ( + $pcmd cd "${ddir}" 2>/dev/null && \ + $pcmd ls -1 "${INTERVAL}"*".${c_marker}" > "${TMP}" 2>/dev/null + ) while read incomplete; do realincomplete=$(echo ${incomplete} | sed "s/\\.${c_marker}\$//") _techo "Incomplete backup: ${realincomplete}" if [ "${DELETE_INCOMPLETE}" = "yes" ]; then _techo "Deleting ${realincomplete} ..." - rm $VVERBOSE -rf "${c_dest}/${realincomplete}" || \ + $pcmd rm $VVERBOSE -rf "${ddir}/${realincomplete}" || \ _exit_err "Removing ${realincomplete} failed." fi done < "${TMP}" @@ -432,7 +468,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # check if maximum number of backups is reached, if so remove # use grep and ls -p so we only look at directories # - count=$(cd "${c_dest}" && ls -p1 | grep "^${INTERVAL}\..*/\$" | wc -l \ + count=$($pcmd cd "${ddir}" && $pcmd ls -p1 | grep "^${INTERVAL}\..*/\$" | wc -l \ | sed 's/^ *//g') || _exit_err "Counting backups failed" _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" @@ -442,12 +478,12 @@ while [ "${i}" -lt "${no_sources}" ]; do remove=$((${count} - ${substract})) _techo "Removing ${remove} backup(s)..." - ( cd "${c_dest}" 2>/dev/null && ls -p1 | grep "^${INTERVAL}\..*/\$" | \ + ( $pcmd cd "${ddir}" 2>/dev/null && $pcmd ls -p1 | grep "^${INTERVAL}\..*/\$" | \ sort -n | head -n "${remove}" ) > "${TMP}" while read to_remove; do _techo "Removing ${to_remove} ..." - rm ${VVERBOSE} -rf "${c_dest}/${to_remove}" || \ + $pcmd rm ${VVERBOSE} -rf "${ddir}/${to_remove}" || \ _exit_err "Removing ${to_remove} failed." done < "${TMP}" fi @@ -459,14 +495,14 @@ while [ "${i}" -lt "${no_sources}" ]; do # Use ls -1c instead of -1t, because last modification maybe the same on all # and metadate update (-c) is updated by rsync locally. # - rel_last_dir="$(cd "${c_dest}" && ls -tcp1 | grep '/$' | head -n 1)" || \ - _exit_err "Failed to list contents of ${c_dest}." - last_dir="${c_dest}/${rel_last_dir}" + rel_last_dir="$($pcmd cd "${ddir}" && $pcmd ls -tcp1 | grep '/$' | head -n 1)" || \ + _exit_err "Failed to list contents of ${ddir}." # # clone from old backup, if existing # - if [ "${last_dir}" ]; then + if [ "${rel_last_dir}" ]; then + last_dir="${ddir}/${rel_last_dir}" # must be absolute, otherwise rsync uses it relative to # the destination directory. See rsync(1). abs_last_dir="$(cd "${last_dir}" && pwd -P)" || \ From 49ee2a24a31f527002cd791f4eabf4da737eeff0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 14 Mar 2008 07:53:11 +0100 Subject: [PATCH 238/581] remote support seems to work, even tested it ;-) --- ccollect.sh | 78 ++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 329c473..8c70c09 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -77,8 +77,8 @@ add_name() pcmd() { - if [ "$remote_server" ]; then - ssh "$host" "$@" + if [ "$remote_host" ]; then + ssh "$remote_host" "$@" else "$@" fi @@ -380,18 +380,17 @@ while [ "${i}" -lt "${no_sources}" ]; do if [ "${ret}" -ne 0 ]; then _exit_err "Remote host file ${c_remote_host} exists, but is not readable. Skipping." fi - pcmd="ssh ${remote_host}" destination="${remote_host}:${ddir}" else - pcmd="" + remote_host="" destination="${ddir}" fi + export remote_host # # check for existence / use real name # - # FIXME: ssh / grouping - ddir=$($pcmd (cd "$ddir" || _exit_err "Cannot change to ${ddir}. Skipping." + pcmd cd "$ddir" || _exit_err "Cannot change to ${ddir}. Skipping." # @@ -448,27 +447,29 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Check for incomplete backups # - ( - $pcmd cd "${ddir}" 2>/dev/null && \ - $pcmd ls -1 "${INTERVAL}"*".${c_marker}" > "${TMP}" 2>/dev/null - ) + pcmd ls -1 "$ddir/${INTERVAL}"*".${c_marker}" > "${TMP}" 2>/dev/null + i=0 while read incomplete; do - realincomplete=$(echo ${incomplete} | sed "s/\\.${c_marker}\$//") + eva incomplete_$i=$(echo ${incomplete} | sed "s/\\.${c_marker}\$//") + i=$(($i+1)) + done < "${TMP}" + + while [ $i -gt 0 ]; do + eval realincomplete=\"incomplete_$i\" _techo "Incomplete backup: ${realincomplete}" if [ "${DELETE_INCOMPLETE}" = "yes" ]; then _techo "Deleting ${realincomplete} ..." - $pcmd rm $VVERBOSE -rf "${ddir}/${realincomplete}" || \ + pcmd rm $VVERBOSE -rf "${ddir}/${realincomplete}" || \ _exit_err "Removing ${realincomplete} failed." fi - done < "${TMP}" - + done # # check if maximum number of backups is reached, if so remove # use grep and ls -p so we only look at directories # - count=$($pcmd cd "${ddir}" && $pcmd ls -p1 | grep "^${INTERVAL}\..*/\$" | wc -l \ + count=$(pcmd ls -p1 "${ddir}" | grep "^${INTERVAL}\..*/\$" | wc -l \ | sed 's/^ *//g') || _exit_err "Counting backups failed" _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" @@ -478,14 +479,21 @@ while [ "${i}" -lt "${no_sources}" ]; do remove=$((${count} - ${substract})) _techo "Removing ${remove} backup(s)..." - ( $pcmd cd "${ddir}" 2>/dev/null && $pcmd ls -p1 | grep "^${INTERVAL}\..*/\$" | \ - sort -n | head -n "${remove}" ) > "${TMP}" + pcmd ls -p1 "$ddir" | grep "^${INTERVAL}\..*/\$" | \ + sort -n | head -n "${remove}" > "${TMP}" + i=0 while read to_remove; do - _techo "Removing ${to_remove} ..." - $pcmd rm ${VVERBOSE} -rf "${ddir}/${to_remove}" || \ - _exit_err "Removing ${to_remove} failed." + eval remove_$i=\"${to_remove}\" + i=$(($i+1)) done < "${TMP}" + + while [ $i -gt 0 ]; do + eval to_remove=\"remove_$i\" + _techo "Removing ${to_remove} ..." + pcmd echo rm ${VVERBOSE} -rf "${to_remove}" || \ + _exit_err "Removing ${to_remove} failed." + done fi @@ -495,55 +503,47 @@ while [ "${i}" -lt "${no_sources}" ]; do # Use ls -1c instead of -1t, because last modification maybe the same on all # and metadate update (-c) is updated by rsync locally. # - rel_last_dir="$($pcmd cd "${ddir}" && $pcmd ls -tcp1 | grep '/$' | head -n 1)" || \ + last_dir="$(pcmd ls -tcp1 "${ddir}" | grep '/$' | head -n 1)" || \ _exit_err "Failed to list contents of ${ddir}." # # clone from old backup, if existing # - if [ "${rel_last_dir}" ]; then - last_dir="${ddir}/${rel_last_dir}" - # must be absolute, otherwise rsync uses it relative to - # the destination directory. See rsync(1). - abs_last_dir="$(cd "${last_dir}" && pwd -P)" || \ - _exit_err "Could not change to last dir ${last_dir}." - set -- "$@" "--link-dest=${abs_last_dir}" - _techo "Hard linking from ${rel_last_dir}" + if [ "${last_dir}" ]; then + set -- "$@" "--link-dest=${last_dir}" + _techo "Hard linking from ${last_dir}" fi # set time when we really begin to backup, not when we began to remove above destination_date=$(${CDATE}) - destination_dir="${c_dest}/${INTERVAL}.${destination_date}.$$" + destination_dir="${ddir}/${INTERVAL}.${destination_date}.$$" + destination_full="${destination}/${INTERVAL}.${destination_date}.$$" # give some info _techo "Beginning to backup, this may take some time..." _techo "Creating ${destination_dir} ..." - mkdir ${VVERBOSE} "${destination_dir}" || \ + pcmd mkdir ${VVERBOSE} "${destination_dir}" || \ _exit_err "Creating ${destination_dir} failed. Skipping." - # absulte now, it's existing - abs_destination_dir="$(cd "${destination_dir}" && pwd -P)" || \ - _exit_err "Changing to newly created ${destination_dir} failed. Skipping." - # # added marking in 0.6 (and remove it, if successful later) # - touch "${abs_destination_dir}.${c_marker}" + pcmd touch "${destination_dir}.${c_marker}" # # the rsync part # _techo "Transferring files..." - rsync "$@" "${source}" "${abs_destination_dir}"; ret=$? + rsync "$@" "${source}" "${destination_full}"; ret=$? # # remove marking here # - rm "${abs_destination_dir}.${c_marker}" || \ - _exit_err "Removing ${abs_destination_dir}/${c_marker} failed." + pcmd rm "${destination_dir}.${c_marker}" || \ + _exit_err "Removing ${destination_dir}/${c_marker} failed." _techo "Finished backup (rsync return code: $ret)." if [ "${ret}" -ne 0 ]; then From 6fe776d7a78e80c7805683cf2432bf14a9433edc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 14 Mar 2008 09:15:26 +0100 Subject: [PATCH 239/581] update changes --- doc/CHANGES | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/CHANGES b/doc/CHANGES index 0a6c223..f294f8b 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,9 +1,13 @@ 0.6.2 to 0.7.0: + * Added tools/report_success.sh (try it out!) + * Added ccollect_analyse_logs.sh (see ccollect_analyse_logs(1)) * Add capability to backup to a host - - updated documentation - * Changed "destination" format (use ... to convert pre 0.7.x configurations) - * Renamed tools to begin with "ccollect_" + - Also updated documentation + * Changed "destination" format + - Use tools/config-pre-0.7-to-0.7.sh to convert pre 0.7.x configurations + * Renamed all tools to begin with "ccollect_" * Updated ccollect_add_source.sh and added manpage + * Updated todos * Changed license to GPLv3 From 9de2d6d211e04d0620407c71fbbc2e49ad48206d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 14 Mar 2008 09:16:31 +0100 Subject: [PATCH 240/581] add new ccollect-0.7.0 configuration examples --- conf/sources/local1/destination | 1 + conf/sources/local1/exclude | 1 + conf/sources/local1/source | 1 + conf/sources/remote1/destination | 1 + conf/sources/remote1/exclude | 1 + conf/sources/remote1/remote_host | 1 + conf/sources/remote1/source | 1 + 7 files changed, 7 insertions(+) create mode 100644 conf/sources/local1/destination create mode 100644 conf/sources/local1/exclude create mode 100644 conf/sources/local1/source create mode 100644 conf/sources/remote1/destination create mode 100644 conf/sources/remote1/exclude create mode 100644 conf/sources/remote1/remote_host create mode 100644 conf/sources/remote1/source diff --git a/conf/sources/local1/destination b/conf/sources/local1/destination new file mode 100644 index 0000000..8cac69d --- /dev/null +++ b/conf/sources/local1/destination @@ -0,0 +1 @@ +/tmp/ccollect diff --git a/conf/sources/local1/exclude b/conf/sources/local1/exclude new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/conf/sources/local1/exclude @@ -0,0 +1 @@ +.git diff --git a/conf/sources/local1/source b/conf/sources/local1/source new file mode 100644 index 0000000..9686138 --- /dev/null +++ b/conf/sources/local1/source @@ -0,0 +1 @@ +/home/user/nico/bin diff --git a/conf/sources/remote1/destination b/conf/sources/remote1/destination new file mode 100644 index 0000000..8cac69d --- /dev/null +++ b/conf/sources/remote1/destination @@ -0,0 +1 @@ +/tmp/ccollect diff --git a/conf/sources/remote1/exclude b/conf/sources/remote1/exclude new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/conf/sources/remote1/exclude @@ -0,0 +1 @@ +.git diff --git a/conf/sources/remote1/remote_host b/conf/sources/remote1/remote_host new file mode 100644 index 0000000..3c2693c --- /dev/null +++ b/conf/sources/remote1/remote_host @@ -0,0 +1 @@ +home.schottelius.org diff --git a/conf/sources/remote1/source b/conf/sources/remote1/source new file mode 100644 index 0000000..9686138 --- /dev/null +++ b/conf/sources/remote1/source @@ -0,0 +1 @@ +/home/user/nico/bin From f99223d9bb5b2df4f9aa42141e0d262366decfd9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 14 Mar 2008 09:18:01 +0100 Subject: [PATCH 241/581] add test scripts --- test/local.sh | 1 + test/remote.sh | 1 + 2 files changed, 2 insertions(+) create mode 100755 test/local.sh create mode 100755 test/remote.sh diff --git a/test/local.sh b/test/local.sh new file mode 100755 index 0000000..c2430fd --- /dev/null +++ b/test/local.sh @@ -0,0 +1 @@ +CCOLLECT_CONF=./conf ./ccollect.sh daily -v local1 diff --git a/test/remote.sh b/test/remote.sh new file mode 100755 index 0000000..2af364e --- /dev/null +++ b/test/remote.sh @@ -0,0 +1 @@ +CCOLLECT_CONF=./conf ./ccollect.sh daily -v remote1 From 9a314d370e5af2b2cef93a8392463e1b309cd5c5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 14 Mar 2008 09:25:04 +0100 Subject: [PATCH 242/581] update exec.sh --- test/exec.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/exec.sh b/test/exec.sh index 31d40db..bdf601d 100755 --- a/test/exec.sh +++ b/test/exec.sh @@ -1,15 +1,18 @@ #!/bin/sh host="home.schottelius.org" - +host="" +set -x pcmd() { + echo "$#", "$@" if [ "$host" ]; then ssh "$host" "$@" else - "$@" + $@ fi } -pcmd ls / -pcmd cd /; ls "/is not there" +#pcmd ls / +#pcmd cd /; ls "/is not there" +pcmd cd / && ls From d15a13dac8be23eb79516920a91a7c0a7b33f05c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 14 Mar 2008 17:54:29 +0100 Subject: [PATCH 243/581] add braindumps --- doc/braindumps/LOCAL_vs._REMOTE | 35 +++++++++++++++++++++++++++++++++ doc/braindumps/README | 1 + 2 files changed, 36 insertions(+) create mode 100644 doc/braindumps/LOCAL_vs._REMOTE create mode 100644 doc/braindumps/README diff --git a/doc/braindumps/LOCAL_vs._REMOTE b/doc/braindumps/LOCAL_vs._REMOTE new file mode 100644 index 0000000..f2a40b7 --- /dev/null +++ b/doc/braindumps/LOCAL_vs._REMOTE @@ -0,0 +1,35 @@ + to Local to Remote + backup destination is exiting + pre/postexec runs locally + --link-dest? + /delete_incomplete - can chech ddir + + can check destination dir + -> dooooooo it before! + + + remote_host! + => rddir_ls: + incomplete: ls -1 "${INTERVAL}"*".${c_marker}" + + host support? + ssh-host-support? + + => ssh_host => save to host + execute commands there! + + rm! + + --link-dest? + + --link-dest=DIR + => remote dirs, rsync remote + => works!!!! + + local_destination + remote_destination + => remote_* + + both + configuration is local (what to where) + diff --git a/doc/braindumps/README b/doc/braindumps/README new file mode 100644 index 0000000..973addc --- /dev/null +++ b/doc/braindumps/README @@ -0,0 +1 @@ +Do not read the files in this directory From f8e36a89a867d8ef3ab3c2efbd7a3efd0bba3a26 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 14 Mar 2008 17:56:04 +0100 Subject: [PATCH 244/581] outdate the german documentation --- doc/ccollect-DE.text | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/ccollect-DE.text b/doc/ccollect-DE.text index 56ae62c..37a13bb 100644 --- a/doc/ccollect-DE.text +++ b/doc/ccollect-DE.text @@ -4,6 +4,8 @@ Julian Meier v0.1, Initiale Version vom 2006-03-04 :Author Initials: JM +DIESE ANLEITUNG IST NICHT AKTUELL UND MUSS +AKTUALISIERT WERDEN (siehe Englische Version) inkrementelle Datensicherung mit 'hardlinks' und 'rsync' From e6fe61aa0e28ae4c1a41271103e4965a1ce26f24 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Mar 2008 10:38:36 +0100 Subject: [PATCH 245/581] Update documentation for 0.7.0 --- doc/ccollect.text | 156 +++++++++++++++++++++++++++++++--------------- 1 file changed, 107 insertions(+), 49 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 3428fd0..7baba92 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -0.6, for ccollect 0.6 - 0.6.2, Initial Version from 2006-01-13 +0.7, for ccollect 0.7.0, Initial Version from 2006-01-13 :Author Initials: NS @@ -21,7 +21,7 @@ Supported and tested operating systems and architectures ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `ccollect` was successfully tested on the following platforms: -- GNU/Linux on amd64/hppa/i386 +- GNU/Linux on amd64/hppa/i386/ppc - NetBSD on amd64/i386/sparc/sparc64 - OpenBSD on amd64 @@ -29,13 +29,18 @@ It *should* run on any Unix that supports `rsync` and has a POSIX-compatible bourne shell. If your platform is not listed above and you have it successfully running, please drop me a mail. -Why you can only backup from remote hosts, not to them -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Why you COULD only backup from remote hosts, not to them +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ While considering the design of ccollect, I thought about enabling backup to *remote* hosts. Though this sounds like a nice feature ('Backup my notebook to the server now.'), in my opinion it is a bad idea to backup to a remote host. +But as more and more people requested this feature, it was implemented, +so you have the choice whether you want to use it or not. + + Reason ^^^^^^ If you want to backup *TO* a remote host, you have to loosen security on it. @@ -49,27 +54,41 @@ Your backup server will be compromised, too. And the attacker will have access to all data on the other webservers. + Doing it securely ^^^^^^^^^^^^^^^^^ Think of it the other way round: The backup server (now behind a -firewall using NAT and strong firewall rules) connects to the +firewall, not accessable from outside) connects to the webservers and pulls the data *from* them. If someone gets access to one of the webservers, this person will perhaps not even see your machine. If -the attacker does see connections from a host to the compromised -machine, he/she will not be able to log in on the backup machine. +the attacker sees connections from a host to the compromised +machine, she will not be able to log in on the backup machine. All other backups are still secure. Incompatibilities ~~~~~~~~~~~~~~~~~ + +Versions 0.6 and 0.7 +^^^^^^^^^^^^^^^^^^^^^ +.The format of `destination` changed: +- Before 0.7 it was a (link to a) directory +- As of 0.7 it is a textfile containing the destination + +You can update your configuration using `tools/config-pre-0.7-to-0.7.sh`. + +.Added 'remote_host' +- As of 0.7 it is possible to backup *to* hosts (see section remote_host below). + + Versions 0.5 and 0.6 ^^^^^^^^^^^^^^^^^^^^^ .The format of `rsync_options` changed: - Before 0.6 it was whitespace delimeted - As of 0.6 it is newline seperated (so you can pass whitespaces to `rsync`) -You can update your configuration using `tools/config-pre-0.6-to-0.6.sub.sh`. +You can update your configuration using `tools/config-pre-0.6-to-0.6.sh`. .The name of the backup directories changed: - Before 0.6: "date +%Y-%m-%d-%H%M" @@ -90,6 +109,7 @@ Not a real incompatibilty, but seems to fit in this section: anymore! + Versions < 0.4 and 0.4 ^^^^^^^^^^^^^^^^^^^^^^ @@ -119,10 +139,10 @@ For those who do not want to read the whole long document: -------------------------------------------------------------------------------- # get latest ccollect tarball from http://unix.schottelius.org/ccollect/ # replace value for CCV with the current version -export CCV=0.6 +export CCV=0.7.0 # -# replace 'wget' with fetch on bsd +# replace 'wget' with 'fetch' on bsd # holen=wget "$holen" http://unix.schottelius.org/ccollect/ccollect-${CCV}.tar.bz2 @@ -134,7 +154,7 @@ cd ccollect-${CCV} # create mini-configuration # first create directory structure mkdir -p miniconfig/defaults/intervals -mkdir miniconfig/sources +mkdir miniconfig/sources # create sample intervals echo 2 > miniconfig/defaults/intervals/testinterval @@ -145,9 +165,13 @@ mkdir ~/DASI # create sample source, which will be saved mkdir miniconfig/sources/testsource + # We will save '/bin' to the directory '~/DASI' echo '/bin' > miniconfig/sources/testsource/source -ln -s ~/DASI miniconfig/sources/testsource/destination + +# configure ccollect to use ~/DASI as destination +echo ~/DASI > miniconfig/sources/testsource/destination + # We want to see what happens and also a small summary at the end touch miniconfig/sources/testsource/verbose touch miniconfig/sources/testsource/summary @@ -169,6 +193,9 @@ CCOLLECT_CONF=./miniconfig ./ccollect.sh testinterval2 testsource echo "Let's see how much space we used with two backups and compare it to /bin" du -s ~/DASI /bin +# report success +echo "Please report success using ./tools/report_success.sh" + -------------------------------------------------------------------------------- Cutting and pasting the complete section above to your shell will result in @@ -204,9 +231,14 @@ $PATH and execute 'chmod *0755* /path/to/ccollect.sh'. If you would like to use the new management scripts (available since 0.6), copy the following scripts to a directory in $PATH: -- `tools/add_ccollect_source.sh` -- `tools/list_ccollect_intervals.sh` -- `tools/delete_ccollect_source.sh` +- `tools/ccollect_add_source.sh` +- `tools/ccollect_analyse_logs.sh.sh` +- `tools/ccollect_delete_source.sh` +- `tools/ccollect_list_intervals.sh` +- `tools/ccollect_logwrapper.sh` + +After having installed and used ccollect, report success using +'./tools/report_success.sh'. Configuring @@ -225,12 +257,13 @@ $ ( setenv CCOLLECT_CONF /your/config/dir ; ccollect.sh ... ) -------------------------------------------------------------------------------- When you start `ccollect`, you have to specify in which interval -to backup (daily, weekly, yearly; you can specify the names yourself, see below) and which sources to backup (or -a to backup all sources). +to backup (daily, weekly, yearly; you can specify the names yourself, see below) +and which sources to backup (or -a to backup all sources). The interval specifies how many backups are kept. -There are also some self-explanatory parameters you can pass to ccollect, simply use -`ccollect.sh --help` for info. +There are also some self-explanatory parameters you can pass to ccollect, +simply use `ccollect.sh --help` for info. General configuration @@ -297,7 +330,7 @@ The name you choose for the subdirectory describes the source. Each source contains at least the following files: - `source` (a text file containing the `rsync` compatible path to backup) - - `destination` (a link to the directory we should backup to) + - `destination` (a text file containing the directory we should backup to) Additionally a source may have the following files: @@ -312,6 +345,7 @@ Additionally a source may have the following files: - `post_exec` program to execute after backing up *this* source - `delete_incomplete` delete incomplete backups + - `remote_host` host to backup to Example: @@ -346,6 +380,35 @@ To use the `rsync` protocol without the `ssh`-tunnel, use of `rsync`(1). +Detailed description of "destination" +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +`destination` must be a text file containing the destination directory. +`destination` *USED* to be a link to the destination directory in +earlier versions, so do not be confused if you see such examples. + + +Example: +-------------------------------------------------------------------------------- + [11:36] zaphodbeeblebrox:ccollect-0.2% cat conf/sources/testsource2/destination + /home/nico/backupdir +-------------------------------------------------------------------------------- + + +Detailed description of "remote_host" +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +`remote_host` must be a text file containing the destination host. +If this file is existing, you are backing up your data *TO* this host +and *not* to you local host. + +Example: +-------------------------------------------------------------------------------- + [10:17] denkbrett:ccollect-0.7.0% cat conf/sources/remote1/remote_host + home.schottelius.org +-------------------------------------------------------------------------------- + +It may contain all the ssh-specific values like 'myuser@yourhost.ch'. + + Detailed description of "verbose" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `verbose` tells `ccollect` that the log should contain verbose messages. @@ -375,7 +438,6 @@ Example: Detailed description of "summary" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - If you create the file `summary` in the source definition, `ccollect` will present you a nice summary at the end. @@ -416,6 +478,7 @@ Detailed description of "exclude" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `exclude` specifies a list of paths to exclude. The entries are seperated by a newline (\n). + Example: -------------------------------------------------------------------------------- [11:35] zaphodbeeblebrox:ccollect-0.2% cat conf/sources/testsource2/exclude @@ -426,22 +489,6 @@ Example: -------------------------------------------------------------------------------- -Detailed description of "destination" -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -`destination` must be a link to the destination directory. - - -Example: --------------------------------------------------------------------------------- - [11:36] zaphodbeeblebrox:ccollect-0.2% ls -l conf/sources/testsource2/destination - lrwxrwxrwx 1 nico users 20 2005-11-17 16:44 conf/sources/testsource2/destination -> /home/nico/backupdir --------------------------------------------------------------------------------- - -To tell the truth, this is not fully correct. `ccollect` will also backup -your data if `destination` is a directory. But do you really want to have -a backup in /etc? - - Detailed description of "intervals/" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ When you create the subdirectory `intervals/` in your source configuration @@ -500,6 +547,7 @@ df -h df -h -------------------------------------------------------------------------------- + Detailed description of "delete_incomplete" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ If you create the file `delete_incomplete` in a source specification directory, @@ -592,6 +640,7 @@ When you exclude "/proc" or "/mnt" from your backup, you may run into trouble when you restore your backup. When you use "/proc/\*" or "/mnt/\*" instead, `ccollect` will backup empty directories. + [NOTE] =========================================== When those directories contain hidden files @@ -605,7 +654,8 @@ Re-using already created rsync-backups ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you used `rsync` directly before you use `ccollect`, you can use this old backup as initial backup for `ccollect`: You -simply move it into a subdirectory named "'interval'.0". +simply move it into a directory below the destination directory +and name it "'interval'.0". Example: @@ -626,15 +676,23 @@ Now you can use /home/backup/web1 as the `destination` for the backup. [NOTE] =============================================================================== -Do *not* name the first backup something like "daily.initial", but use -the "*0*" (or some number that is lower than the current year) -as extension. `ccollect` uses `sort` to find the latest backup. `ccollect` -itself uses 'interval.YEARMONTHDAY-HOURMINUTE.PID'. This notation will -*always* be before "daily.initial", as numbers are earlier in the list -which is produced by `sort`. So, if you have a directory named "daily.initial", -`ccollect` will always diff against this backup and transfer and delete +It does not matter anymore how you name your directory, as `ccollect` uses +the -c option from `ls` to find out which directory to clone from. +=============================================================================== + + +[NOTE] +=============================================================================== +Older versions (pre 0.6, iirc) had a problem, if you named the first backup +something like "daily.initial". It was needed to use the "*0*" (or some +number that is lower than the current year) as extension. `ccollect` +used `sort` to find the latest backup. `ccollect` itself uses +'interval.YEARMONTHDAY-HOURMINUTE.PID'. This notation was *always* before +"daily.initial", as numbers are earlier in the list +which is produced by `sort`. So, if you had a directory named "daily.initial", +`ccollect` always diffed against this backup and transfered and deleted files which where deleted in previous backups. This means you simply -waste resources, but your backup will be complete. +wasted resources, but your backup had beer complete anyway. =============================================================================== @@ -680,7 +738,8 @@ This leads to If the whole `ccollect` process was interrupted, `ccollect` (since 0.6) can detect that and remove the incomplete backups, so you can clone from a complete -backup instead. +backup instead + When backing up from localhost the destination is also included. Is this a bug? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -775,7 +834,7 @@ srwali01:/etc/ccollect/sources/local-root# cat > exclude << EOF > /sys > /mnt > EOF -srwali01:/etc/ccollect/sources/local-root# ln -s /mnt/hdbackup/local-root destination +srwali01:/etc/ccollect/sources/local-root# echo /mnt/hdbackup/local-root > destination srwali01:/etc/ccollect/sources/local-root# mkdir /mnt/hdbackup/local-root srwali01:/etc/ccollect/sources/local-root# ccollect.sh taeglich local-root /o> ccollect.sh: Beginning backup using interval taeglich @@ -809,7 +868,7 @@ srwali01:/etc/ccollect/sources/srwali03# cat > exclude << EOF > /home > EOF srwali01:/etc/ccollect/sources/srwali03# echo 'root@10.103.2.3:/' > source -srwali01:/etc/ccollect/sources/srwali03# ln -s /mnt/hdbackup/srwali03 destination +srwali01:/etc/ccollect/sources/srwali03# echo /mnt/hdbackup/srwali03 > destination srwali01:/etc/ccollect/sources/srwali03# mkdir /mnt/hdbackup/srwali03 -------------------------------------------------------------------------------- @@ -881,7 +940,6 @@ the hardlinks allocate. A collection of backups on the backup server ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - All the data of my important hosts is backuped to eiche into /mnt/schwarzesloch/backup: From 8597f011f93205a6cb978a884a9c5d9fe6512d3f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 17 Mar 2008 08:29:02 +0100 Subject: [PATCH 246/581] updated manpage for ccollect_analyse_logs --- doc/man/ccollect_analyse_logs.text | 56 ++++++++++++++++++++++++++++++ doc/todo/0.7.1 | 1 - 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 doc/man/ccollect_analyse_logs.text diff --git a/doc/man/ccollect_analyse_logs.text b/doc/man/ccollect_analyse_logs.text new file mode 100644 index 0000000..2638014 --- /dev/null +++ b/doc/man/ccollect_analyse_logs.text @@ -0,0 +1,56 @@ +ccollect_analyse_logs(1) +======================== +Nico Schottelius + + +NAME +---- +ccollect_analyse_logs - analyse logs produced by ccollect(1) + + +SYNOPSIS +-------- + +'ccollect_analyse_logs.sh' [iwe] + + +DESCRIPTION +----------- +ccollect_analyse_logs.sh reads the logfiles from stdin. You have to specify +at least one of the three loglevels (*i*nformational, *w*arning, *e*rror). Any +combination of them is allowed. + + +FILES +----- +ccollect log files:: + Are read from stdin + +EXAMPLES +-------- +cat /var/log/ccollect/single/* | ccollect_analyse_logs.sh iw:: + Displays warnings and informational parts +ccollect_analyse_logs.sh iw < /var/log/ccollect/all_together:: + Displays only error messages (useful for the morning mail) + + +SEE ALSO +-------- +ccollect(1), ccollect_add_source.sh, ccollect_delete_source(1), +ccollect_list_intervals(1), ccollect_logwrapper(1), + + +AUTHOR +------ +Nico Schottelius + + +RESOURCES +--------- +Main web site: http://unix.schottelius.org/ccollect/[] + + +COPYING +------- +Copyright \(C) 2007-2008 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License Version 3 (GPLv3). diff --git a/doc/todo/0.7.1 b/doc/todo/0.7.1 index 17ddd15..fb8d3a5 100644 --- a/doc/todo/0.7.1 +++ b/doc/todo/0.7.1 @@ -11,4 +11,3 @@ 09:32 < Obri> ping -c1 -q `cat /etc/ccollect/sources/$name/source | cut -d"@" -f2 | cut -d":" -f1` 09:33 < Obri> telmich: so bricht das backup ab wenn der host nicht erreichbar ist 09:33 < Obri> ohne dass ein altes backup entsorgt wird - From 5a7d12d254cb7b8af8f920714700edf63ff20637 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 17 Mar 2008 08:30:07 +0100 Subject: [PATCH 247/581] really mark the german documentation as outdated --- doc/ccollect-DE.text | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/ccollect-DE.text b/doc/ccollect-DE.text index 37a13bb..2fa6237 100644 --- a/doc/ccollect-DE.text +++ b/doc/ccollect-DE.text @@ -4,13 +4,16 @@ Julian Meier v0.1, Initiale Version vom 2006-03-04 :Author Initials: JM -DIESE ANLEITUNG IST NICHT AKTUELL UND MUSS -AKTUALISIERT WERDEN (siehe Englische Version) +*DIESE ANLEITUNG IST NICHT AKTUELL UND MUSS +AKTUALISIERT WERDEN (siehe Englische Version)* inkrementelle Datensicherung mit 'hardlinks' und 'rsync' Einleitung ---------- +*DIESE ANLEITUNG IST NICHT AKTUELL UND MUSS +AKTUALISIERT WERDEN (siehe Englische Version)* + 'ccollect' ist ein Backuptool geschrieben in der sh-skript Programmiersprache. Es braucht nichts besonderes nur die '/bin/sh'-Konsole (oder eine kompatible). From 0c141187bfe0f8cd5058b668da17510f9ef81dbe Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 17 Mar 2008 08:57:59 +0100 Subject: [PATCH 248/581] Add hints to tools and add another gpl3 header --- doc/ccollect.text | 4 ++++ tools/ccollect_analyse_logs.sh | 23 ++++++++++++++++++++--- tools/report_success.sh | 2 +- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 7baba92..b44c616 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -243,6 +243,10 @@ After having installed and used ccollect, report success using Configuring ----------- +For configuration aid have a look at the above mentioned tools, which can assist +you quite well. When you are successfully using `ccollect`, report success using +`tools/report_success.sh`. + Runtime options ~~~~~~~~~~~~~~~ diff --git a/tools/ccollect_analyse_logs.sh b/tools/ccollect_analyse_logs.sh index 6ceb414..b8128d0 100755 --- a/tools/ccollect_analyse_logs.sh +++ b/tools/ccollect_analyse_logs.sh @@ -1,7 +1,24 @@ #!/bin/sh -# Nico Schottelius -# written for Netstream (www.netstream.ch) -# Date: Di 21. Aug 17:10:15 CEST 2007 +# +# 2007-2008 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# Written for Netstream (www.netstream.ch) on Di 21. Aug 17:10:15 CEST 2007 +# # Analyse existing logs version=0.1 diff --git a/tools/report_success.sh b/tools/report_success.sh index 82a6dc6..b0f9d1b 100755 --- a/tools/report_success.sh +++ b/tools/report_success.sh @@ -29,7 +29,7 @@ software="ccollect" author="Nico Schottelius" info="$(uname -s -v -r -m)" -echo "Reporting success for $software to ${author}:" +echo "Reporting success for $software to ${author}" echo "-----------------" echo -n "Your name (leave free for anonymous): " read name From 20a549af7196b7abaabef0aca56da58aeac59943 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 17 Mar 2008 09:17:53 +0100 Subject: [PATCH 249/581] add more gpl3 headers / correct them --- release.sh | 19 ++++++++++++++++++- tools/README | 19 +++++++++++++++++++ tools/ccollect_analyse_logs.sh | 3 ++- tools/ccollect_delete_source.sh | 1 + tools/ccollect_logwrapper.sh | 1 + tools/ccollect_stats.sh | 22 +++++++++++----------- tools/config-pre-0.4-to-0.4.sh | 22 ++++++++++++++++++++-- tools/config-pre-0.4-to-0.4.sub.sh | 21 +++++++++++++++++++-- tools/config-pre-0.6-to-0.6.sh | 21 +++++++++++++++++++-- tools/config-pre-0.6-to-0.6.sub.sh | 21 +++++++++++++++++++-- tools/config-pre-0.7-to-0.7.sh | 3 ++- tools/config-pre-0.7-to-0.7.sub.sh | 2 ++ tools/gnu-du-backup-size-compare.sh | 21 ++++++++++++++++++--- 13 files changed, 151 insertions(+), 25 deletions(-) create mode 100644 tools/README diff --git a/release.sh b/release.sh index 7a758bb..e6ae08a 100755 --- a/release.sh +++ b/release.sh @@ -1,5 +1,22 @@ #!/bin/sh -# Nico Schottelius +# +# 200?-2008 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# # Standard release script for dummies like me # diff --git a/tools/README b/tools/README new file mode 100644 index 0000000..7312018 --- /dev/null +++ b/tools/README @@ -0,0 +1,19 @@ +Files and their tasks / destinations: + +ccollect_add_source.sh: bin +ccollect_analyse_logs.sh: bin +ccollect_create_source2.sh: ??? +ccollect_create_source.sh: ??? +ccollect_delete_source.sh: bin +ccollect_list_intervals.sh: bin +ccollect_logwrapper.sh: bin +ccollect-stats.sh: ??? +config-pre-0.4-to-0.4.BUGS: only to be used for converting +config-pre-0.4-to-0.4.sh: only to be used for converting +config-pre-0.4-to-0.4.sub.sh: only to be used for converting +config-pre-0.6-to-0.6.sh: only to be used for converting +config-pre-0.6-to-0.6.sub.sh: only to be used for converting +config-pre-0.7-to-0.7.sh: only to be used for converting +config-pre-0.7-to-0.7.sub.sh: only to be used for converting +gnu-du-backup-size-compare.sh +README diff --git a/tools/ccollect_analyse_logs.sh b/tools/ccollect_analyse_logs.sh index b8128d0..e1484a2 100755 --- a/tools/ccollect_analyse_logs.sh +++ b/tools/ccollect_analyse_logs.sh @@ -19,7 +19,8 @@ # # Written for Netstream (www.netstream.ch) on Di 21. Aug 17:10:15 CEST 2007 # -# Analyse existing logs +# Analyse logs +# version=0.1 date=2007-08-24 diff --git a/tools/ccollect_delete_source.sh b/tools/ccollect_delete_source.sh index d7dd2e1..636ce67 100755 --- a/tools/ccollect_delete_source.sh +++ b/tools/ccollect_delete_source.sh @@ -19,6 +19,7 @@ # # 2007-08-16 Written for Netstream (www.netstream.ch) # Delete sources and their backups (optionally). +# # standard values CCOLLECT_CONF="${CCOLLECT_CONF:-/etc/ccollect}" diff --git a/tools/ccollect_logwrapper.sh b/tools/ccollect_logwrapper.sh index 9afa557..ac7f496 100755 --- a/tools/ccollect_logwrapper.sh +++ b/tools/ccollect_logwrapper.sh @@ -20,6 +20,7 @@ # Written for Netstream (www.netstream.ch) on Fr 8. Jun 10:30:24 CEST 2007 # # Call the log-wrapper instead of ccollect.sh and it will create nice logs +# # # where to find our configuration and temporary file diff --git a/tools/ccollect_stats.sh b/tools/ccollect_stats.sh index 273ca65..f1f62ad 100644 --- a/tools/ccollect_stats.sh +++ b/tools/ccollect_stats.sh @@ -11,15 +11,15 @@ if [ ! -e /tmp/ccollect-stats.lock ] then - touch /tmp/ccollect-stats.lock - find /etc/ccollect/sources/ -type l | while read line - do - backupname=$(basename $(readlink $line)) - echo "====[Backup: $backupname]====" | tee -a /var/log/backup.log - du -sh $line/* | tee -a /var/log/backup.log - done - rm /tmp/ccollect-stats.lock + touch /tmp/ccollect-stats.lock + + # changes after license clearify + # for dest in /etc/ccollect/sources/ -type f -name destination | while read line + + find /etc/ccollect/sources/ -type l | while read line + d=$(basename $(readlink $line)) + echo "====[Backup: $backupname]====" | tee -a /var/log/backup.log + du -sh $line/* | tee -a /var/log/backup.log + done + rm /tmp/ccollect-stats.lock fi - - - diff --git a/tools/config-pre-0.4-to-0.4.sh b/tools/config-pre-0.4-to-0.4.sh index 9a7efd8..23b3307 100755 --- a/tools/config-pre-0.4-to-0.4.sh +++ b/tools/config-pre-0.4-to-0.4.sh @@ -1,6 +1,24 @@ #!/bin/sh -# Nico Schottelius -# Do Apr 27 09:13:26 CEST 2006 +# +# 2006-2008 Nico Schottelius (nico-ccollect at schottelius.org) +# +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# Written on Do Apr 27 09:13:26 CEST 2006 # if [ $# -ne 1 ]; then diff --git a/tools/config-pre-0.4-to-0.4.sub.sh b/tools/config-pre-0.4-to-0.4.sub.sh index 5b17a72..e28e718 100755 --- a/tools/config-pre-0.4-to-0.4.sub.sh +++ b/tools/config-pre-0.4-to-0.4.sub.sh @@ -1,6 +1,23 @@ #!/bin/sh -# Nico Schottelius -# Do Apr 27 09:13:26 CEST 2006 +# +# 2006-2008 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# Written on Do Apr 27 09:13:26 CEST 2006 # master=$(echo $0 | sed 's/\.sub//') diff --git a/tools/config-pre-0.6-to-0.6.sh b/tools/config-pre-0.6-to-0.6.sh index 5efce68..58a538a 100755 --- a/tools/config-pre-0.6-to-0.6.sh +++ b/tools/config-pre-0.6-to-0.6.sh @@ -1,7 +1,24 @@ #!/bin/sh -# Nico Schottelius, 20070816-2225 +# +# 2007-2008 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# Written on 20070816-2225 # Transfer configuration to 0.6 layout -# Copying: GPLv3 # if [ $# -ne 1 ]; then diff --git a/tools/config-pre-0.6-to-0.6.sub.sh b/tools/config-pre-0.6-to-0.6.sub.sh index b4e0bd3..7744f9e 100755 --- a/tools/config-pre-0.6-to-0.6.sub.sh +++ b/tools/config-pre-0.6-to-0.6.sub.sh @@ -1,7 +1,24 @@ #!/bin/sh -# Nico Schottelius, 20070816-2227 +# +# 2007-2008 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# Written on 20070816-2227 # Transfer configuration to 0.6 layout (subscript) -# Copying: GPLv3 # if [ $# -ne 1 ]; then diff --git a/tools/config-pre-0.7-to-0.7.sh b/tools/config-pre-0.7-to-0.7.sh index f83341f..6d540ab 100755 --- a/tools/config-pre-0.7-to-0.7.sh +++ b/tools/config-pre-0.7-to-0.7.sh @@ -17,7 +17,8 @@ # You should have received a copy of the GNU General Public License # along with ccollect. If not, see . # -# Convert configuration to 0.6 layout +# Convert configuration to 0.7 layout +# if [ $# -ne 1 ]; then echo "$0: ccollect-configuration directory" diff --git a/tools/config-pre-0.7-to-0.7.sub.sh b/tools/config-pre-0.7-to-0.7.sub.sh index 4579924..bb43285 100755 --- a/tools/config-pre-0.7-to-0.7.sub.sh +++ b/tools/config-pre-0.7-to-0.7.sub.sh @@ -17,6 +17,8 @@ # You should have received a copy of the GNU General Public License # along with ccollect. If not, see . # +# Helper script +# if [ $# -ne 1 ]; then echo "$0: destination-file" diff --git a/tools/gnu-du-backup-size-compare.sh b/tools/gnu-du-backup-size-compare.sh index 85b876b..cf3b194 100755 --- a/tools/gnu-du-backup-size-compare.sh +++ b/tools/gnu-du-backup-size-compare.sh @@ -1,8 +1,23 @@ #!/bin/sh +# +# 2007-2008 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. # -# Nico Schottelius -# Date: 2007-08-16 -# Last Modified: - +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# Written on 2007-08-16 # exit 1 From 036575df9da970e4ac97a047f68f510e89949ceb Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 17 Mar 2008 11:42:06 +0100 Subject: [PATCH 250/581] minor notice changes --- doc/CHANGES | 2 +- doc/man/ccollect_logwrapper.text | 2 +- doc/todo/0.7.2 | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/CHANGES b/doc/CHANGES index f294f8b..2c3f522 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -8,7 +8,7 @@ * Renamed all tools to begin with "ccollect_" * Updated ccollect_add_source.sh and added manpage * Updated todos - * Changed license to GPLv3 + * Changed license to GPLv3 (from GPLv2) 0.6.1 to 0.6.2: diff --git a/doc/man/ccollect_logwrapper.text b/doc/man/ccollect_logwrapper.text index 6dca801..ce1c5f6 100644 --- a/doc/man/ccollect_logwrapper.text +++ b/doc/man/ccollect_logwrapper.text @@ -1,4 +1,4 @@ -ccollect-logwrapper(1) +ccollect_logwrapper(1) ====================== Nico Schottelius diff --git a/doc/todo/0.7.2 b/doc/todo/0.7.2 index a0a6eba..9e43ba0 100644 --- a/doc/todo/0.7.2 +++ b/doc/todo/0.7.2 @@ -1,3 +1,9 @@ +-------------------------------------------------------------------------------- +Stats version +-------------------------------------------------------------------------------- + +Add tools/ccollect_stats.sh, clearify license +-------------------------------------------------------------------------------- Preamble: Netstream (www.netstream.ch) may consider using ccollect for backing up many unix servers and needs some clean reporting. The following things From 0d5cc4ddbca76857dea2fadec38dcfbf8f14e7f2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 17 Mar 2008 11:44:20 +0100 Subject: [PATCH 251/581] add ddir to --link-dest --- ccollect.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 8c70c09..32423b1 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -31,7 +31,7 @@ CPOSTEXEC="${CDEFAULTS}/post_exec" TMP=$(mktemp "/tmp/$(basename $0).XXXXXX") VERSION=0.7.0 -RELEASE="2008-03-XX" +RELEASE="2008-03-18" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" @@ -510,7 +510,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # clone from old backup, if existing # if [ "${last_dir}" ]; then - set -- "$@" "--link-dest=${last_dir}" + set -- "$@" "--link-dest=${ddir}/${last_dir}" _techo "Hard linking from ${last_dir}" fi From 8ace2a6520c8de3260314666c60a4b5ba008221d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 17 Mar 2008 12:06:17 +0100 Subject: [PATCH 252/581] fix endless loop --- ccollect.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 32423b1..b5ed4bc 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -451,18 +451,20 @@ while [ "${i}" -lt "${no_sources}" ]; do i=0 while read incomplete; do - eva incomplete_$i=$(echo ${incomplete} | sed "s/\\.${c_marker}\$//") + eval incomplete_$i=\"$(echo ${incomplete} | sed "s/\\.${c_marker}\$//")\" i=$(($i+1)) done < "${TMP}" - while [ $i -gt 0 ]; do - eval realincomplete=\"incomplete_$i\" + j=0 + while [ "$j" -lt "$i" ]; do + eval realincomplete=\"\$incomplete_$i\" _techo "Incomplete backup: ${realincomplete}" if [ "${DELETE_INCOMPLETE}" = "yes" ]; then _techo "Deleting ${realincomplete} ..." pcmd rm $VVERBOSE -rf "${ddir}/${realincomplete}" || \ _exit_err "Removing ${realincomplete} failed." fi + i=$((i+i)) done # From 4e47c881fb2356dd981b09a1b3b036f5cc9ea4ed Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 17 Mar 2008 12:08:40 +0100 Subject: [PATCH 253/581] add more quotes --- ccollect.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index b5ed4bc..5cfe168 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -464,15 +464,15 @@ while [ "${i}" -lt "${no_sources}" ]; do pcmd rm $VVERBOSE -rf "${ddir}/${realincomplete}" || \ _exit_err "Removing ${realincomplete} failed." fi - i=$((i+i)) + j=$((j+1)) done # # check if maximum number of backups is reached, if so remove # use grep and ls -p so we only look at directories # - count=$(pcmd ls -p1 "${ddir}" | grep "^${INTERVAL}\..*/\$" | wc -l \ - | sed 's/^ *//g') || _exit_err "Counting backups failed" + count="$(pcmd ls -p1 "${ddir}" | grep "^${INTERVAL}\..*/\$" | wc -l \ + | sed 's/^ *//g')" || _exit_err "Counting backups failed" _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" @@ -490,6 +490,7 @@ while [ "${i}" -lt "${no_sources}" ]; do i=$(($i+1)) done < "${TMP}" + j=0 while [ $i -gt 0 ]; do eval to_remove=\"remove_$i\" _techo "Removing ${to_remove} ..." From 96171314d78a473a1cc0956987f1272ae16c9b93 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 17 Mar 2008 12:09:30 +0100 Subject: [PATCH 254/581] add error detection to backup listing --- ccollect.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index 5cfe168..31ea2a8 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -482,7 +482,8 @@ while [ "${i}" -lt "${no_sources}" ]; do _techo "Removing ${remove} backup(s)..." pcmd ls -p1 "$ddir" | grep "^${INTERVAL}\..*/\$" | \ - sort -n | head -n "${remove}" > "${TMP}" + sort -n | head -n "${remove}" > "${TMP}" || \ + _exit_err "Listing old backups failed" i=0 while read to_remove; do From 842e668c4cea94b4befec5e356592a23bddaae6e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 17 Mar 2008 12:11:09 +0100 Subject: [PATCH 255/581] fix another endless loop --- ccollect.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 31ea2a8..61a0593 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -457,7 +457,7 @@ while [ "${i}" -lt "${no_sources}" ]; do j=0 while [ "$j" -lt "$i" ]; do - eval realincomplete=\"\$incomplete_$i\" + eval realincomplete=\"\$incomplete_$j\" _techo "Incomplete backup: ${realincomplete}" if [ "${DELETE_INCOMPLETE}" = "yes" ]; then _techo "Deleting ${realincomplete} ..." @@ -492,11 +492,12 @@ while [ "${i}" -lt "${no_sources}" ]; do done < "${TMP}" j=0 - while [ $i -gt 0 ]; do - eval to_remove=\"remove_$i\" + while [ "$j" -lt "$i" ]; do + eval to_remove=\"remove_$j\" _techo "Removing ${to_remove} ..." pcmd echo rm ${VVERBOSE} -rf "${to_remove}" || \ _exit_err "Removing ${to_remove} failed." + j=$((j+1)) done fi From 7b76e1ee65648b21175afc8ee0e4a8ddf82d5d27 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 17 Mar 2008 12:21:35 +0100 Subject: [PATCH 256/581] bugfix: removing old backups --- ccollect.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 61a0593..bd695e7 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -493,9 +493,9 @@ while [ "${i}" -lt "${no_sources}" ]; do j=0 while [ "$j" -lt "$i" ]; do - eval to_remove=\"remove_$j\" + eval to_remove=\"\$remove_$j\" _techo "Removing ${to_remove} ..." - pcmd echo rm ${VVERBOSE} -rf "${to_remove}" || \ + pcmd rm ${VVERBOSE} -rf "${ddir}/${to_remove}" || \ _exit_err "Removing ${to_remove} failed." j=$((j+1)) done From 0c2f5df28375d6370dd5cf94c9c6ad665b383eff Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 17 Mar 2008 18:23:44 +0100 Subject: [PATCH 257/581] update release date --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index bd695e7..1d71999 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -31,7 +31,7 @@ CPOSTEXEC="${CDEFAULTS}/post_exec" TMP=$(mktemp "/tmp/$(basename $0).XXXXXX") VERSION=0.7.0 -RELEASE="2008-03-18" +RELEASE="2008-03-17" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" From c60e2870c4180d6bd375fe22c7c4f9a31ed1d650 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 18 Mar 2008 14:03:09 +0100 Subject: [PATCH 258/581] add gpl2 info to ccollect_stats.sh --- tools/ccollect_stats.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ccollect_stats.sh b/tools/ccollect_stats.sh index f1f62ad..bfaefab 100644 --- a/tools/ccollect_stats.sh +++ b/tools/ccollect_stats.sh @@ -3,7 +3,7 @@ # 2007 Daniel Aubry # 2008 Nico Schottelius (added minimal header) # -# Copying license unknown +# Copying license: GPL2-only # # TODO: From de16d9556afd3eebd6125a4fe94f39cfb29d92d5 Mon Sep 17 00:00:00 2001 From: Lucky Date: Wed, 23 Apr 2008 11:19:07 +0200 Subject: [PATCH 259/581] Add required -P to pwd Signed-off-by: Nico Schottelius --- tools/config-pre-0.7-to-0.7.sub.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/config-pre-0.7-to-0.7.sub.sh b/tools/config-pre-0.7-to-0.7.sub.sh index bb43285..5bc6f75 100755 --- a/tools/config-pre-0.7-to-0.7.sub.sh +++ b/tools/config-pre-0.7-to-0.7.sub.sh @@ -35,7 +35,7 @@ echo "Working on $file ..." if [ -L "${file}" ]; then echo "Converting ${file} ..." - dir="$(cd "${file}" && pwd)"; ret=$? + dir="$(cd "${file}" && pwd -P)"; ret=$? if [ $ret -ne 0 ]; then echo "ERROR: $file is a broken link" From 6ea6e23df06af9b9d36d559f909231da0464a3c9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 26 Apr 2008 12:57:20 +0200 Subject: [PATCH 260/581] restructure changes list Signed-off-by: Nico Schottelius --- doc/{CHANGES => changes/pre-0.7.1} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename doc/{CHANGES => changes/pre-0.7.1} (100%) diff --git a/doc/CHANGES b/doc/changes/pre-0.7.1 similarity index 100% rename from doc/CHANGES rename to doc/changes/pre-0.7.1 From e8fc763b5c95aaafd3f7ee4f647d90b955a4ed5d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 26 Apr 2008 12:58:30 +0200 Subject: [PATCH 261/581] Begin changes for 0.7.1 Signed-off-by: Nico Schottelius --- doc/changes/0.7.1 | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changes/0.7.1 diff --git a/doc/changes/0.7.1 b/doc/changes/0.7.1 new file mode 100644 index 0000000..ece77fb --- /dev/null +++ b/doc/changes/0.7.1 @@ -0,0 +1 @@ +* Added support for global delete_incomplete option From f096e412eaa2a6ea110b59413d4aa26e1a8108ec Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 26 Apr 2008 12:59:24 +0200 Subject: [PATCH 262/581] Add support for global delete_incomplete to ccollect Signed-off-by: Nico Schottelius --- ccollect.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 1d71999..5fa2638 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -30,8 +30,8 @@ CPREEXEC="${CDEFAULTS}/pre_exec" CPOSTEXEC="${CDEFAULTS}/post_exec" TMP=$(mktemp "/tmp/$(basename $0).XXXXXX") -VERSION=0.7.0 -RELEASE="2008-03-17" +VERSION=0.7.1 +RELEASE="2008-04-XX" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" @@ -281,7 +281,8 @@ while [ "${i}" -lt "${no_sources}" ]; do c_summary="${backup}/summary" c_pre_exec="${backup}/pre_exec" c_post_exec="${backup}/post_exec" - c_incomplete="${backup}/delete_incomplete" + f_incomplete="delete_incomplete" + c_incomplete="${backup}/${f_incomplete}" c_remote_host="${backup}/remote_host" # @@ -396,7 +397,8 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Check whether to delete incomplete backups # - if [ -f "${c_incomplete}" ]; then + if [ -f "${c_incomplete}" + -o -f "${CDEFAULTS}/${f_incomplete}]; then DELETE_INCOMPLETE="yes" fi From 741650f926d96de76036b6cb29024cd50e7b1254 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 26 Apr 2008 13:01:54 +0200 Subject: [PATCH 263/581] add freebsd to supported os Signed-off-by: Nico Schottelius --- doc/ccollect.text | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/ccollect.text b/doc/ccollect.text index b44c616..1091712 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -22,6 +22,7 @@ Supported and tested operating systems and architectures `ccollect` was successfully tested on the following platforms: - GNU/Linux on amd64/hppa/i386/ppc +- FreeBSD on amd64/i386 - NetBSD on amd64/i386/sparc/sparc64 - OpenBSD on amd64 From 2627af97ad320c22fb48071fb58c346e3e4f1fc2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 26 Apr 2008 13:06:27 +0200 Subject: [PATCH 264/581] Todo for 0.8.0 Signed-off-by: Nico Schottelius --- doc/todo/0.8.0 | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 doc/todo/0.8.0 diff --git a/doc/todo/0.8.0 b/doc/todo/0.8.0 new file mode 100644 index 0000000..6c32c38 --- /dev/null +++ b/doc/todo/0.8.0 @@ -0,0 +1,5 @@ +- restructure code to easily allow global versus source options: + f_name=.... + check_option $f_name + => source + => defaults From ca5c9fc5fd0e4e31c9e43971d05d92f4594fca49 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 26 Apr 2008 13:08:50 +0200 Subject: [PATCH 265/581] Describe delete_incomplete Signed-off-by: Nico Schottelius --- doc/ccollect.text | 11 +++++++++-- doc/todo/0.8.0 | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 1091712..0785983 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -140,7 +140,7 @@ For those who do not want to read the whole long document: -------------------------------------------------------------------------------- # get latest ccollect tarball from http://unix.schottelius.org/ccollect/ # replace value for CCV with the current version -export CCV=0.7.0 +export CCV=0.7.1 # # replace 'wget' with 'fetch' on bsd @@ -254,7 +254,7 @@ Runtime options `ccollect` looks for its configuration in '/etc/ccollect' or, if set, in the directory specified by the variable '$CCOLLECT_CONF': -------------------------------------------------------------------------------- -# sh-compatible (zsh, mksh, ksh, bash, ...) +# sh-compatible (dash, zsh, mksh, ksh, bash, ...) $ CCOLLECT_CONF=/your/config/dir ccollect.sh ... # csh @@ -325,6 +325,13 @@ human readable format before and after the whole backup process: ------------------------------------------------------------------------- +General delete_incomplete +^^^^^^^^^^^^^^^^^^^^^^^^^ +If you add '$CCOLLECT_CONF/defaults/`delete_incomplete`', this +option applies for all sources. See below for a longer +explanation. + + Source configuration ~~~~~~~~~~~~~~~~~~~~ Each source configuration exists in '$CCOLLECT_CONF/sources/$name' or diff --git a/doc/todo/0.8.0 b/doc/todo/0.8.0 index 6c32c38..2b5130d 100644 --- a/doc/todo/0.8.0 +++ b/doc/todo/0.8.0 @@ -3,3 +3,4 @@ check_option $f_name => source => defaults +- support all senseful options as default and source specific From 2dc80fa971e66990698fdc940d905e31249d92c9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 26 Apr 2008 13:14:19 +0200 Subject: [PATCH 266/581] more changes --- doc/ccollect.text | 16 ++++++++++++++-- doc/changes/0.7.1 | 1 + doc/todo/0.7.2 | 4 ++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 0785983..37de4e8 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -595,7 +595,7 @@ host mx2.schottelius.org Port 2342 -------------------------------------------------------------------------------- -If you only use that port for backup and normally want to use another port, +If you only use that port for backup only and normally want to use another port, you can add 'HostName' and "HostKeyAlias" (if you also have different keys on the different ports): @@ -612,7 +612,6 @@ Host bruehe -------------------------------------------------------------------------------- - Using source names or interval in pre_/post_exec scripts ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The pre-/post_exec scripts can access some internal variables from `ccollect`: @@ -734,6 +733,19 @@ of different requirements, you can even omit creating `/etc/ccollect/default/intervals/daily`. +Comparing backups +~~~~~~~~~~~~~~~~~ +If you want to see what changed between two backups, you can use +`rsync` directly: + +-------------------------------------------------------------------------------- +[12:00] u0255:ddba034.netstream.ch# rsync -n -a --delete --stats --progress daily.20080324-0313.17841/ daily.20080325-0313.31148/ +-------------------------------------------------------------------------------- +This results in a listing of changes. Because we pass -n to rsync no transfer +is made (i.e. report only mode)" + +This hint was reported by Daniel Aubry. + F.A.Q. ------ diff --git a/doc/changes/0.7.1 b/doc/changes/0.7.1 index ece77fb..eda40bc 100644 --- a/doc/changes/0.7.1 +++ b/doc/changes/0.7.1 @@ -1 +1,2 @@ * Added support for global delete_incomplete option +* Updated documentation (more hints) diff --git a/doc/todo/0.7.2 b/doc/todo/0.7.2 index 9e43ba0..79a50aa 100644 --- a/doc/todo/0.7.2 +++ b/doc/todo/0.7.2 @@ -57,3 +57,7 @@ rsync_extra global! -------------------------------------------------------------------------------- Always report return code! +[12:00] u0255:ddba034.netstream.ch# rsync -n -a --delete --stats --progress daily.20080324-0313.17841/ daily.20080325-0313.31148/ + +$tool + From c01e6b9a16436e0cf5f34a1ea0005372ab0acdda Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 26 Apr 2008 13:21:37 +0200 Subject: [PATCH 267/581] update credits Signed-off-by: Nico Schottelius --- CREDITS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CREDITS b/CREDITS index 1616f6f..72d59cc 100644 --- a/CREDITS +++ b/CREDITS @@ -4,6 +4,8 @@ Thanks go to the following people: - for testing and debugging (those I mean should know ;-) * Alexey Maximov - for finding return-value and shell limitation bugs +* Daniel Aubry + - for reporting many hints * Markus Meier - for finding a really simple solution for choosing the right backup to clone from: Make it independent of the interval, simply choose the last From 5775bdb28da13f343fe7289d6a4d3514d1b2b875 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 3 Jun 2008 14:13:55 +0200 Subject: [PATCH 268/581] todo for 0.7.1 --- doc/todo/0.7.1 | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/doc/todo/0.7.1 b/doc/todo/0.7.1 index fb8d3a5..a0af574 100644 --- a/doc/todo/0.7.1 +++ b/doc/todo/0.7.1 @@ -1,8 +1,18 @@ -- add global delete_incomplete (/etc/ccollect/defaults/delete_incomplete) +- remove basename + -> include config from cconf! -> standard! + +-------------------------------------------------------------------------------- + + - add wrapper, to do logging and analyse * output filename in the wrapper, save into variable + => mktemp * call analyser -- fix german documentation! + => output stdout? + + +done: +- add global delete_incomplete (/etc/ccollect/defaults/delete_incomplete) 09:31 < Obri> telmich: hab nen kleinen tipp für ccollect 09:32 < Obri> telmich: ich habe hier hosts die nicht immer online sind, das ist dumm weil so das backup @@ -11,3 +21,9 @@ 09:32 < Obri> ping -c1 -q `cat /etc/ccollect/sources/$name/source | cut -d"@" -f2 | cut -d":" -f1` 09:33 < Obri> telmich: so bricht das backup ab wenn der host nicht erreichbar ist 09:33 < Obri> ohne dass ein altes backup entsorgt wird + + + +reject: +- fix german documentation! + => I'm the coder, somebody else can fix it. From d5c7b57b092b2b489dff5eea3f258c818bd51e62 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 3 Jun 2008 14:16:11 +0200 Subject: [PATCH 269/581] =?UTF-8?q?makefile=20/=20hinweise=20f=C3=BCr=20to?= =?UTF-8?q?ols/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nico Schottelius --- ccollect.sh | 3 +-- doc/ccollect.text | 25 ++++++++++++++++++++++++- doc/todo/0.7.1 | 6 ++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 5fa2638..d0c272e 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -397,8 +397,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Check whether to delete incomplete backups # - if [ -f "${c_incomplete}" - -o -f "${CDEFAULTS}/${f_incomplete}]; then + if [ -f "${c_incomplete}" -o -f "${CDEFAULTS}/${f_incomplete}" ]; then DELETE_INCOMPLETE="yes" fi diff --git a/doc/ccollect.text b/doc/ccollect.text index 37de4e8..8b2588c 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -0.7, for ccollect 0.7.0, Initial Version from 2006-01-13 +0.7.1, for ccollect 0.7.1, Initial Version from 2006-01-13 :Author Initials: NS @@ -746,6 +746,29 @@ is made (i.e. report only mode)" This hint was reported by Daniel Aubry. + +Testing for host reachabilty +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +If you want to test whether the host you try to backup is reachable, you can use +the following script as source specific pre-exec: + +-------------------------------------------------------------------------------- +#!/bin/sh +# ping -c1 -q `cat "/etc/ccollect/sources/$name/source" | cut -d"@" -f2 | cut -d":" -f1` +-------------------------------------------------------------------------------- + +This hint was reported by Daniel Aubry. + + +Easy check for errors +~~~~~~~~~~~~~~~~~~~~~ +If you want to see whether there have been any errors while doing the backup, +you can run `ccollect` together with `ccollect_analyse_logs.sh`: +-------------------------------------------------------------------------------- +$ ccollect | ccollect_analyse_logs.sh e +-------------------------------------------------------------------------------- + + F.A.Q. ------ diff --git a/doc/todo/0.7.1 b/doc/todo/0.7.1 index a0af574..f76ba6d 100644 --- a/doc/todo/0.7.1 +++ b/doc/todo/0.7.1 @@ -1,6 +1,12 @@ - remove basename -> include config from cconf! -> standard! +14:15 also alle tools/ccollect_* +14:15 mach mal n besseres Makefile :) +14:15 hatte die extra deswegen umbenannt +14:15 nehme ich mal als hinweis für 0.7.1 + + -------------------------------------------------------------------------------- From 085ba484973ed51a8a1c94ce52cfb3860c44fab2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 13 Jun 2008 10:29:38 +0200 Subject: [PATCH 270/581] add three new error messages to ccollect_analyse_logs.sh Signed-off-by: Nico Schottelius --- tools/ccollect_analyse_logs.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/ccollect_analyse_logs.sh b/tools/ccollect_analyse_logs.sh index e1484a2..82af6cc 100755 --- a/tools/ccollect_analyse_logs.sh +++ b/tools/ccollect_analyse_logs.sh @@ -68,6 +68,9 @@ if [ "$search_err" ]; then set -- "$@" "-e" 'rsync: .*: Input/output error (5)$' set -- "$@" "-e" 'cannot send long-named file "' set -- "$@" "-e" 'ERROR: .* failed verification -- update discarded.$' + set -- "$@" "-e" 'Host key verification failed.' + set -- "$@" "-e" 'rsync error: unexplained error (code 255)' + set -- "$@" "-e" 'rsync: connection unexpectedly closed' fi # known error strings: @@ -77,6 +80,11 @@ fi #[zrha165.netstream.ch] Read from remote host zrha165.netstream.ch: Connection reset by peer #[ddba017.netstream.ch] receiving file list ... cannot send long-named file "/usr/local/www/apache22/cgi-bin/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/ backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/bac kup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup /backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/ba ckup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backu p/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/backup/back" #[ddba033.netstream.ch] ERROR: usr/local/inetpub2/netstream/adsl.netstream.ch/mrtg/lbswiss.rrd failed verification -- update discarded. +# [ddba034.netstream.ch] Host key verification failed. +# [ddba034.netstream.ch] rsync error: unexplained error (code 255) at io.c(454) [receiver=2.6.9] +# [ddba034.netstream.ch] rsync: connection unexpectedly closed (0 bytes received so far) [receiver] + + # From cdebda1c32a6c51c7408b9c31679bfc9aee0ec92 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 13 Jun 2008 10:30:46 +0200 Subject: [PATCH 271/581] also update date Signed-off-by: Nico Schottelius --- tools/ccollect_analyse_logs.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/ccollect_analyse_logs.sh b/tools/ccollect_analyse_logs.sh index 82af6cc..ddcbec8 100755 --- a/tools/ccollect_analyse_logs.sh +++ b/tools/ccollect_analyse_logs.sh @@ -22,8 +22,8 @@ # Analyse logs # -version=0.1 -date=2007-08-24 +version=0.2 +date=2008-06-13 fullversion="${version} (${date})" args=iwe From a9dd91ffef732873765d9df669914c314f6c6fbe Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 13 Jun 2008 10:49:20 +0200 Subject: [PATCH 272/581] also report ssh timeouts Signed-off-by: Nico Schottelius --- tools/ccollect_analyse_logs.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/ccollect_analyse_logs.sh b/tools/ccollect_analyse_logs.sh index ddcbec8..7ff9916 100755 --- a/tools/ccollect_analyse_logs.sh +++ b/tools/ccollect_analyse_logs.sh @@ -69,6 +69,7 @@ if [ "$search_err" ]; then set -- "$@" "-e" 'cannot send long-named file "' set -- "$@" "-e" 'ERROR: .* failed verification -- update discarded.$' set -- "$@" "-e" 'Host key verification failed.' + set -- "$@" "-e" 'ssh: connect to host .*: Connection timed out' set -- "$@" "-e" 'rsync error: unexplained error (code 255)' set -- "$@" "-e" 'rsync: connection unexpectedly closed' fi From 8f2af0e4669a66bac5cb360d40557a008ebe25fc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 13 Jun 2008 11:14:39 +0200 Subject: [PATCH 273/581] update changes for 0.7.1 Signed-off-by: Nico Schottelius --- doc/changes/0.7.1 | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changes/0.7.1 b/doc/changes/0.7.1 index eda40bc..cd61318 100644 --- a/doc/changes/0.7.1 +++ b/doc/changes/0.7.1 @@ -1,2 +1,3 @@ * Added support for global delete_incomplete option +* Updated tools/ccollect_analyse_logs.sh: Added more error strings to find * Updated documentation (more hints) From 5caad132b554777231a2dac01960442b748ba168 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 13 Jun 2008 11:18:44 +0200 Subject: [PATCH 274/581] add hint: prevent backup deletion for unreachable hosts Signed-off-by: Nico Schottelius --- doc/ccollect.text | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/ccollect.text b/doc/ccollect.text index 8b2588c..f6b0c77 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -757,6 +757,8 @@ the following script as source specific pre-exec: # ping -c1 -q `cat "/etc/ccollect/sources/$name/source" | cut -d"@" -f2 | cut -d":" -f1` -------------------------------------------------------------------------------- +This prevents the deletion of old backups, if the host is not reachable. + This hint was reported by Daniel Aubry. From fef686b449f89041312868ba8c4629d3b4a72601 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 13 Jun 2008 11:28:43 +0200 Subject: [PATCH 275/581] remove basename - use standard vars defined in cconf Signed-off-by: Nico Schottelius --- ccollect.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index d0c272e..2856df3 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -20,6 +20,13 @@ # Initially written for SyGroup (www.sygroup.ch) # Date: Mon Nov 14 11:45:11 CET 2005 +# +# Standard variables (stolen from cconf) +# +__pwd="$(pwd -P)" +__mydir="${0%/*}"; __abs_mydir="$(cd "$__mydir" && pwd -P)" +__myname=${0##*/}; __abs_myname="$__abs_mydir/$__myname" + # # where to find our configuration and temporary file # @@ -29,7 +36,7 @@ CDEFAULTS=${CCOLLECT_CONF}/defaults CPREEXEC="${CDEFAULTS}/pre_exec" CPOSTEXEC="${CDEFAULTS}/post_exec" -TMP=$(mktemp "/tmp/$(basename $0).XXXXXX") +TMP=$(mktemp "/tmp/${__myname}.XXXXXX") VERSION=0.7.1 RELEASE="2008-04-XX" HALF_VERSION="ccollect ${VERSION}" @@ -98,7 +105,7 @@ display_version() # usage() { - echo "$(basename $0): [args] " + echo "${__myname}: [args] " echo "" echo " ccollect creates (pseudo) incremental backups" echo "" From 40cef5f7a4a98a1eac2ffc129ba91c8191730afe Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 13 Jun 2008 11:30:36 +0200 Subject: [PATCH 276/581] update changes/todo Signed-off-by: Nico Schottelius --- doc/changes/0.7.1 | 1 + doc/todo/0.7.1 | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/changes/0.7.1 b/doc/changes/0.7.1 index cd61318..89110e0 100644 --- a/doc/changes/0.7.1 +++ b/doc/changes/0.7.1 @@ -1,3 +1,4 @@ * Added support for global delete_incomplete option * Updated tools/ccollect_analyse_logs.sh: Added more error strings to find +* Removed use of 'basename': Replaced it with standard variables from cconf * Updated documentation (more hints) diff --git a/doc/todo/0.7.1 b/doc/todo/0.7.1 index f76ba6d..8afae7e 100644 --- a/doc/todo/0.7.1 +++ b/doc/todo/0.7.1 @@ -1,5 +1,3 @@ -- remove basename - -> include config from cconf! -> standard! 14:15 also alle tools/ccollect_* 14:15 mach mal n besseres Makefile :) @@ -7,7 +5,6 @@ 14:15 nehme ich mal als hinweis für 0.7.1 --------------------------------------------------------------------------------- - add wrapper, to do logging and analyse @@ -17,7 +14,9 @@ => output stdout? +-------------------------------------------------------------------------------- done: + - add global delete_incomplete (/etc/ccollect/defaults/delete_incomplete) 09:31 < Obri> telmich: hab nen kleinen tipp für ccollect @@ -29,7 +28,10 @@ done: 09:33 < Obri> ohne dass ein altes backup entsorgt wird +- remove basename + -> include config from cconf! -> standard! reject: +-------------------------------------------------------------------------------- - fix german documentation! => I'm the coder, somebody else can fix it. From 5809571ca0a7047bb8a1dbc25f2d4b9f7bda239b Mon Sep 17 00:00:00 2001 From: Jeroen Bruijning Date: Fri, 13 Jun 2008 11:34:43 +0200 Subject: [PATCH 277/581] Fix bug in shell arithmetic 1. I got a syntax error in ccollect.sh once in a while, i think at rollover. I changed the line j=$((j+1)) to j=$(($j+1)) (twice) and the error went away. --- ccollect.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 2856df3..cbef116 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -472,7 +472,7 @@ while [ "${i}" -lt "${no_sources}" ]; do pcmd rm $VVERBOSE -rf "${ddir}/${realincomplete}" || \ _exit_err "Removing ${realincomplete} failed." fi - j=$((j+1)) + j=$(($j+1)) done # @@ -505,7 +505,7 @@ while [ "${i}" -lt "${no_sources}" ]; do _techo "Removing ${to_remove} ..." pcmd rm ${VVERBOSE} -rf "${ddir}/${to_remove}" || \ _exit_err "Removing ${to_remove} failed." - j=$((j+1)) + j=$(($j+1)) done fi From ca408a22cc53f95ffe70327daad43a07305f7273 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 13 Jun 2008 11:46:07 +0200 Subject: [PATCH 278/581] add hint: ssh access required for remote_host Signed-off-by: Nico Schottelius --- doc/ccollect.text | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/ccollect.text b/doc/ccollect.text index f6b0c77..b6e18c0 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -412,6 +412,12 @@ Detailed description of "remote_host" If this file is existing, you are backing up your data *TO* this host and *not* to you local host. +*Warning*: You need to have `ssh` access to the remote host. `rsync` and +`ccollect` will connect to that host via `ssh`. `ccollect` needs the shell +access, because it needs to find out how many backups exist on the remote +host and to be able to delete them. + + Example: -------------------------------------------------------------------------------- [10:17] denkbrett:ccollect-0.7.0% cat conf/sources/remote1/remote_host From 6af6c8d229287daa5ad3f78714bad44cfb82ebc4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 13 Jun 2008 12:04:22 +0200 Subject: [PATCH 279/581] more changes for 0.7.1 Signed-off-by: Nico Schottelius --- doc/changes/0.7.1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/changes/0.7.1 b/doc/changes/0.7.1 index 89110e0..cc68e79 100644 --- a/doc/changes/0.7.1 +++ b/doc/changes/0.7.1 @@ -1,4 +1,7 @@ * Added support for global delete_incomplete option * Updated tools/ccollect_analyse_logs.sh: Added more error strings to find * Removed use of 'basename': Replaced it with standard variables from cconf -* Updated documentation (more hints) +* Updated documentation + * More hints + * Updated remote_host description +* Bugfix in shell artihmetic (Jeroen Bruijning) From cfe5433e7af593df3cf2ebf076fc639a66133464 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 13 Jun 2008 12:07:43 +0200 Subject: [PATCH 280/581] todo for 0.7.4 Signed-off-by: Nico Schottelius --- doc/todo/0.7.4 | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/todo/0.7.4 diff --git a/doc/todo/0.7.4 b/doc/todo/0.7.4 new file mode 100644 index 0000000..70515e7 --- /dev/null +++ b/doc/todo/0.7.4 @@ -0,0 +1 @@ +add support for wipe From 26b8df48258d122ec4ace1ac8999c7a4e0a16905 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 25 Jun 2008 11:38:24 +0200 Subject: [PATCH 281/581] begin to make tools more modular in makefile Signed-off-by: Nico Schottelius --- Makefile | 18 ++++++++++++++++++ doc/todo/0.7.1 | 3 --- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index f519c6a..7cb8d80 100644 --- a/Makefile +++ b/Makefile @@ -113,6 +113,24 @@ install-manlink: install-man ${INSTALL} -d -m 0755 ${manlink} for man in ${mandest}/*; do ${LN} $$man ${manlink}; done +# +# Tools +# +TOOLS=ccollect_add_source.sh \ + ccollect_analyse_logs.sh \ + ccollect_delete_source.sh \ + ccollect_logwrapper.sh \ + ccollect_list_intervals.sh + +TOOLSMAN1 = $(subst ccollect,doc/man/ccollect,$(TOOLS)) +TOOLSMAN = $(subst .sh,.text,$(TOOLSMAN1)) + +TOOLSFP = $(subst ccollect,tools/ccollect,$(TOOLS)) + +#t2: $(TOOLSMAN) +t2: + echo $(TOOLS) - $(TOOLSMAN) - $(TOOLSFP) + # docbook gets .htm, asciidoc directly .html %.htm: %.docbook diff --git a/doc/todo/0.7.1 b/doc/todo/0.7.1 index 8afae7e..4f4b3e6 100644 --- a/doc/todo/0.7.1 +++ b/doc/todo/0.7.1 @@ -4,9 +4,6 @@ 14:15 hatte die extra deswegen umbenannt 14:15 nehme ich mal als hinweis für 0.7.1 - - - - add wrapper, to do logging and analyse * output filename in the wrapper, save into variable => mktemp From 45d85601102aa689edad291cd5ede0b2d46c2daa Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 4 Jul 2008 15:22:28 +0200 Subject: [PATCH 282/581] beginn restore doc Signed-off-by: Nico Schottelius --- doc/ccollect-restoring.text | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 doc/ccollect-restoring.text diff --git a/doc/ccollect-restoring.text b/doc/ccollect-restoring.text new file mode 100644 index 0000000..3f4c543 --- /dev/null +++ b/doc/ccollect-restoring.text @@ -0,0 +1,23 @@ +ccollect - Restoring backups +============================ +Nico Schottelius +0.1, for all ccollect version, Initial Version from 2008-07-04 +:Author Initials: NS + + +Having backups is half the way to success on a failure. +Knowing how to restore the systems is the other half. + + +Introduction +------------ +You made your backup and now you want to restore + +Example recoveries +------------------ + +Restoring a complete FreeBSD system +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Restoring a complete Linux system +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 7cc669ba0a827fad2b044683ea34d86c73fb9726 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 4 Jul 2008 13:35:52 +0200 Subject: [PATCH 283/581] begin to structure it Signed-off-by: Nico Schottelius --- doc/ccollect-restoring.text | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/doc/ccollect-restoring.text b/doc/ccollect-restoring.text index 3f4c543..f9721a0 100644 --- a/doc/ccollect-restoring.text +++ b/doc/ccollect-restoring.text @@ -11,13 +11,30 @@ Knowing how to restore the systems is the other half. Introduction ------------ -You made your backup and now you want to restore +You made your backup and now you want to restore your +data. If you backuped only parts of a computer and need +only to restore them, it is pretty easy to achieve. +Restoring a whole system is a little bit more +difficult and needs some knowledge of the operating system. -Example recoveries ------------------- +Restoring parts of a system +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Log into your backupserver. Change into the +backup directory you want to restore from +(the one named source.intervall.datetime, like +...). +Do Restoring a complete FreeBSD system ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Restoring a complete Linux system ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Future +------ +I think about automating full system recoveries in the future. +I think it could be easily done and here are some hints for +people who would like to implement it. + + From 1a8752814f99b0ae35cf9994ef34bb7db1b974e9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 21 Jul 2008 11:24:03 +0200 Subject: [PATCH 284/581] add template for ccollect_check_config Signed-off-by: Nico Schottelius --- tools/ccollect_check_config.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tools/ccollect_check_config.sh diff --git a/tools/ccollect_check_config.sh b/tools/ccollect_check_config.sh new file mode 100644 index 0000000..ac7fa2c --- /dev/null +++ b/tools/ccollect_check_config.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# +# 2008 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# + +################################################################################ +# standard vars stolen from cconf +__pwd="$(pwd -P)" +__mydir="${0%/*}"; __abs_mydir="$(cd "$__mydir" && pwd -P)" +__myname=${0##*/}; __abs_myname="$__abs_mydir/$__myname" + From ba61d0b6cecc6d99845676a6cf9a5511ceccee5a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 23 Jul 2008 11:29:44 +0200 Subject: [PATCH 285/581] continue freebsd restore Signed-off-by: Nico Schottelius --- doc/ccollect-restoring.text | 130 ++++++++++++++++++++++++++++++++++-- 1 file changed, 126 insertions(+), 4 deletions(-) diff --git a/doc/ccollect-restoring.text b/doc/ccollect-restoring.text index f9721a0..fb2af9e 100644 --- a/doc/ccollect-restoring.text +++ b/doc/ccollect-restoring.text @@ -17,16 +17,138 @@ only to restore them, it is pretty easy to achieve. Restoring a whole system is a little bit more difficult and needs some knowledge of the operating system. + Restoring parts of a system ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Log into your backupserver. Change into the -backup directory you want to restore from -(the one named source.intervall.datetime, like -...). -Do +backup directory you want to restore from. +Do `rsync -av './files/to/be/recovered/' 'sourcehost:/files/to/be/recovered/'. + +Restoring a complete system (general) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Boot the system to be rescued from a media that contains low level tools +for your OS (like partitioning, formatting) and the necessary tools +(ssh, tar or rsync). +Use +- create the necessary partition table (or however it is called + +Get a live-cd, that ships with +- rsync / tar +- ssh (d) -> from backupserver +- support for the filesystems + + Restoring a complete FreeBSD system ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Get a FreeBSD-live-cd (I used the FreeBSD 7.0 live CD, +but FreeSBIE (http://www.freesbie.org/), +Frenzy (http://frenzy.org.ua/en/) or the +FreeBSD LiveCD (http://livecd.sourceforge.net/) +may also be helpful. The following way uses the FreeBSD 7.0 +live cd. + +So boot it up, select your language. After that select +*Custom* then *Partition*. Create the slice like you want +to have it. Then let the installer write into the MBR, +select *BootMgr*. + +After that create the necessary labels, select *Label* and +make sure "Newfs" flag is set to "Y". + +Finally, select *Commit* and choose an installation type +that must fail, because we want the installer only to write +the partitions and labels, but not to install anything on it. + +At this point we have created the base for restoring the whole +system. Move back to the main menu and select *Fixit*, then +*CDROM/DVD*. This starts a shell on TTY4, which can be reached +by pressing *ALT+F4*. Then enter the following data: + +-------------------------------------------------------------------------------- + rootdir=/ccollect + rootdev=/dev/ad0s1a + backupserver=192.42.23.5 + + # create destination directory + mkdir "$rootdir" + + # mount root; add other mounts if you created more labels + mount "$rootdev" "$rootdir" + + # find out which network devices exist + ifconfig + + # create the directory, because dhclient needs it + mkdir /var/db + + # retrieve an ip address + dhclient fxp0 + + # test connection + ssh "$backupserver" + + # go back + backupserver% exit +-------------------------------------------------------------------------------- + +Now we've prepared everything for the real backup. The next problem maybe, +that we cannot (should not) be able to login as root to the backup server. +Additionally the system to be restored may not reachable from the backup server, +because it is behind a firewall or nat. +Thus I describe a way, that is a little bit more complicated for those, that +do not have these limitations, but works in both scenarios. + +I just start netcat on the local machine, pipe its output to tar and put +both into the background. Then I create a ssh tunnel to the backupserver, +which is then able to connect to my netcat "directly". +-------------------------------------------------------------------------------- + # user to connect to the backupserver + myuser=nico + + # our name in the backup + restorehost=server1 + + # the instance to be used + backup="weekly.20080718-2327.23053" + + # Need to setup lo0 first, the livecd did not do it for me + ifconfig lo0 127.0.0.1 up + + # change to the destination directory + cd "$rootdir" + + # start listener + ( nc -l 127.0.0.1 4242 | tar xvf - ) & + + # verify that it runs correctly + sockstat -4l + + # connect as a normal user to the backupserver + ssh -R4242:127.0.0.1:4242 "$myuser@$backupserver" + + # become root + backupserver% su - + + # change to the source directory + backupserver# cd /home/server/backup/$restorehost/$backup + + # begin the backup + backup # tar cf - . | nc 127.0.0.1 4242 + + # wait until it finishes, press ctrl-c to kill netcat + # logoff the backupserver + backupserver# exit + backupserver% exit + + # maybe fix fstab: /dev/twed0s1a may not be present in + # maybe fix network devices, may have other name + umount + reboot # hope the best! + I cannot connet + + +Partition table Restoring a complete Linux system ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From c5545e3c459b90aa6e8ac57ab1affc6fde24b310 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 23 Jul 2008 11:31:01 +0200 Subject: [PATCH 286/581] continue check script Signed-off-by: Nico Schottelius --- tools/ccollect_check_config.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/ccollect_check_config.sh b/tools/ccollect_check_config.sh index ac7fa2c..c24a400 100644 --- a/tools/ccollect_check_config.sh +++ b/tools/ccollect_check_config.sh @@ -24,3 +24,17 @@ __pwd="$(pwd -P)" __mydir="${0%/*}"; __abs_mydir="$(cd "$__mydir" && pwd -P)" __myname=${0##*/}; __abs_myname="$__abs_mydir/$__myname" + +################################################################################ +# ccollect standard vars +CCOLLECT_CONF="${CCOLLECT_CONF:-/etc/ccollect}" +CDEFAULTS="${CCOLLECT_CONF}/defaults" +CLOGDIR="${CDEFAULTS}/logdir" +CRONTAB="${CRONTAB:-/etc/crontab}" + +# Parameters: +# -c, --crontab +# -f, --fix +# -l, --logs + + From 218f846479aedb2a69edad078eda54a3cbe6639f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 23 Jul 2008 11:39:01 +0200 Subject: [PATCH 287/581] finished description for freebsd Signed-off-by: Nico Schottelius --- doc/ccollect-restoring.text | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/doc/ccollect-restoring.text b/doc/ccollect-restoring.text index fb2af9e..5e7e9b5 100644 --- a/doc/ccollect-restoring.text +++ b/doc/ccollect-restoring.text @@ -37,8 +37,6 @@ Get a live-cd, that ships with - ssh (d) -> from backupserver - support for the filesystems - - Restoring a complete FreeBSD system ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Get a FreeBSD-live-cd (I used the FreeBSD 7.0 live CD, @@ -102,6 +100,7 @@ do not have these limitations, but works in both scenarios. I just start netcat on the local machine, pipe its output to tar and put both into the background. Then I create a ssh tunnel to the backupserver, which is then able to connect to my netcat "directly". + -------------------------------------------------------------------------------- # user to connect to the backupserver myuser=nico @@ -140,23 +139,30 @@ which is then able to connect to my netcat "directly". # logoff the backupserver backupserver# exit backupserver% exit +-------------------------------------------------------------------------------- - # maybe fix fstab: /dev/twed0s1a may not be present in - # maybe fix network devices, may have other name - umount - reboot # hope the best! - I cannot connet +Now we are just right next to be finished. Still, we have to take care about +some things: +- Do the block devices still have the same names? If not, correct /etc/fstab. +- Do the network devices still have the same names? If not, correct /etc/rc.conf. -Partition table +If everything is fixed, let us finish the restore: + +-------------------------------------------------------------------------------- + # cleanly umount it + umount "$rootdir" + + # reboot, remove the cd and bootup the restored system + reboot +-------------------------------------------------------------------------------- Restoring a complete Linux system ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +TO BE DONE Future ------ I think about automating full system recoveries in the future. I think it could be easily done and here are some hints for people who would like to implement it. - - From 05544bf02f0c54a6274321326edc3082f1684931 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 23 Jul 2008 18:05:35 +0200 Subject: [PATCH 288/581] begin integration of linux restore Signed-off-by: Nico Schottelius --- doc/ccollect-restoring.text | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/doc/ccollect-restoring.text b/doc/ccollect-restoring.text index 5e7e9b5..33208c0 100644 --- a/doc/ccollect-restoring.text +++ b/doc/ccollect-restoring.text @@ -159,6 +159,30 @@ If everything is fixed, let us finish the restore: Restoring a complete Linux system ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Knoppix + knoppix 2 at boot prompt + + rootdir=/ccollect + dev=/dev/hda + rootdev="${dev}1" + fs=jfs + tar + + # create the needed partitions + cfdisk $dev + + mkfs.$fs $rootdev + + mkdir $rootdir + + mount $rootdev $rootdir + + cd $rootdir + + pump + ifconfig + + TO BE DONE Future From c704d7d9b84d468b4ee5fdc177b3195e45dd2cd0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 19 Aug 2008 15:25:46 +0200 Subject: [PATCH 289/581] +nc Signed-off-by: Nico Schottelius --- doc/ccollect-restoring.text | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/ccollect-restoring.text b/doc/ccollect-restoring.text index 33208c0..7bb29ea 100644 --- a/doc/ccollect-restoring.text +++ b/doc/ccollect-restoring.text @@ -182,6 +182,10 @@ Knoppix pump ifconfig + # start listener (from now on it is the same as + ( nc -l 127.0.0.1 4242 | tar xvf - ) & + + TO BE DONE From 4f088f84c3369abd465b2bbc001dfc4af4ebf8be Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 12 Dec 2008 00:42:17 +0100 Subject: [PATCH 290/581] add example interval "normal" Signed-off-by: Nico Schottelius --- conf/defaults/intervals/normal | 1 + 1 file changed, 1 insertion(+) create mode 100644 conf/defaults/intervals/normal diff --git a/conf/defaults/intervals/normal b/conf/defaults/intervals/normal new file mode 100644 index 0000000..7273c0f --- /dev/null +++ b/conf/defaults/intervals/normal @@ -0,0 +1 @@ +25 From d7ec63052a198ad9ba1ee2c7b8500a3ea3554073 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 12 Dec 2008 00:42:41 +0100 Subject: [PATCH 291/581] add real world example for my notebook --- conf/sources/ikn/README | 1 + conf/sources/ikn/destination | 1 + conf/sources/ikn/exclude | 1 + conf/sources/ikn/source | 1 + conf/sources/ikn/summary | 0 conf/sources/ikn/verbose | 0 6 files changed, 4 insertions(+) create mode 100644 conf/sources/ikn/README create mode 100644 conf/sources/ikn/destination create mode 100644 conf/sources/ikn/exclude create mode 100644 conf/sources/ikn/source create mode 100644 conf/sources/ikn/summary create mode 100644 conf/sources/ikn/verbose diff --git a/conf/sources/ikn/README b/conf/sources/ikn/README new file mode 100644 index 0000000..6b192a6 --- /dev/null +++ b/conf/sources/ikn/README @@ -0,0 +1 @@ +This is a production example I use for my notebook. diff --git a/conf/sources/ikn/destination b/conf/sources/ikn/destination new file mode 100644 index 0000000..8ac51bc --- /dev/null +++ b/conf/sources/ikn/destination @@ -0,0 +1 @@ +/home/server/raid/backup/ikn diff --git a/conf/sources/ikn/exclude b/conf/sources/ikn/exclude new file mode 100644 index 0000000..f5b5b7c --- /dev/null +++ b/conf/sources/ikn/exclude @@ -0,0 +1 @@ +/home/server/raid diff --git a/conf/sources/ikn/source b/conf/sources/ikn/source new file mode 100644 index 0000000..b498fd4 --- /dev/null +++ b/conf/sources/ikn/source @@ -0,0 +1 @@ +/ diff --git a/conf/sources/ikn/summary b/conf/sources/ikn/summary new file mode 100644 index 0000000..e69de29 diff --git a/conf/sources/ikn/verbose b/conf/sources/ikn/verbose new file mode 100644 index 0000000..e69de29 From 582018adbb6295a814e90b63d7d064c796491e13 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 13 Jan 2009 11:58:45 +0100 Subject: [PATCH 292/581] alpha/netbsd added Signed-off-by: Nico Schottelius --- doc/ccollect.text | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index b6e18c0..150803a 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -23,7 +23,7 @@ Supported and tested operating systems and architectures - GNU/Linux on amd64/hppa/i386/ppc - FreeBSD on amd64/i386 -- NetBSD on amd64/i386/sparc/sparc64 +- NetBSD on alpha/amd64/i386/sparc/sparc64 - OpenBSD on amd64 It *should* run on any Unix that supports `rsync` and has a POSIX-compatible From b8b0ca107adf18beddc372c9a394c96c3a974cf9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 16 Jan 2009 14:44:59 +0100 Subject: [PATCH 293/581] [BUGFIX] cd must be in subshell, otherwise breaks later Due to wrong WD Signed-off-by: Nico Schottelius --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index cbef116..f3c3e91 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -398,7 +398,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # # check for existence / use real name # - pcmd cd "$ddir" || _exit_err "Cannot change to ${ddir}. Skipping." + ( pcmd cd "$ddir" ) || _exit_err "Cannot change to ${ddir}. Skipping." # From bfcc1ebfc4e126a53087c5fd25a85a687e03b018 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 16 Jan 2009 14:45:25 +0100 Subject: [PATCH 294/581] update makefile for new server Signed-off-by: Nico Schottelius --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7cb8d80..cdfdf94 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ path_destination=${path_dir}/${CCOLLECT_DEST} # where to publish host=home.schottelius.org -dir=www/org/schottelius/unix/www/ccollect/ +dir=/home/server/www/nico/unix.schottelius.org/www/ccollect/ docdir=${dir}/doc # From e5e1cc865a8240e1b4a798949c1b4ae7683744fd Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 2 Feb 2009 11:45:59 +0100 Subject: [PATCH 295/581] more testing in makefile Signed-off-by: Nico Schottelius --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index cdfdf94..329ec5b 100644 --- a/Makefile +++ b/Makefile @@ -189,4 +189,6 @@ distclean: clean dist: distclean documentation test: ccollect.sh documentation + mkdir /tmp/ccollect CCOLLECT_CONF=./conf ./ccollect.sh daily "source with spaces" + CCOLLECT_CONF=./conf ./ccollect.sh normal 'local1&with-ampersand' From 337fec115b5b492e872956da8082b4f8195a1853 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 2 Feb 2009 11:46:48 +0100 Subject: [PATCH 296/581] +tab Signed-off-by: Nico Schottelius --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 329ec5b..84ffb69 100644 --- a/Makefile +++ b/Makefile @@ -189,6 +189,6 @@ distclean: clean dist: distclean documentation test: ccollect.sh documentation - mkdir /tmp/ccollect + mkdir -p /tmp/ccollect CCOLLECT_CONF=./conf ./ccollect.sh daily "source with spaces" - CCOLLECT_CONF=./conf ./ccollect.sh normal 'local1&with-ampersand' + CCOLLECT_CONF=./conf ./ccollect.sh normal 'local1&with-ampersand' From b3ad86f270d4680e9900651d3dc40c4a7f85273c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 2 Feb 2009 11:47:45 +0100 Subject: [PATCH 297/581] [BUGFIX] allow "&" in sourcepath MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug description: From: Tiziano Müller Subject: Notiz: Probleme mit Ampersand in source Date: Tue, 07 Oct 2008 16:11:10 +0000 Hoi Nico Kleine Notiz wie im IRC besprochen: - Hat es in /etc/ccollect/sources/$BACKUPNAME/source ein Ampersand muss dieses Escaped werden, da sonst folgender Fehler auftritt: *snip* [volumes_ForschungEntwicklung] 2008-10-05-03:10:03: Beginning to backup, this may take some time... [volumes_ForschungEntwicklung] 2008-10-05-03:10:03: Creating /home/backup/volumes/Forschung&Entwicklung/daily.20081005-0310.15173 ... [volumes_ForschungEntwicklung] 2008-10-05-03:10:03: Transferring files... [volumes_ForschungEntwicklung] bash: Entwicklung/*: No such file or directory [volumes_ForschungEntwicklung] rsync: connection unexpectedly closed (4 bytes received so far) [receiver] [volumes_ForschungEntwicklung] rsync error: error in rsync protocol data stream (code 12) at io.c(635) [receiver=3.0.2] [volumes_ForschungEntwicklung] 2008-10-05-03:10:03: Finished backup (rsync return code: 12). [volumes_ForschungEntwicklung] 2008-10-05-03:10:03: Warning: rsync exited non-zero, the backup may be broken (see rsync errors). *snip* - ein "&" im Namen fürs Backup, also: /etc/ccollect/sources/volumes_Forschung&Entwicklung/ wird beim Anzeigen (wie oben zu sehen) verschluckt. Cheers, Tiziano Signed-off-by: Nico Schottelius --- ccollect.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index f3c3e91..837a895 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# 2005-2008 Nico Schottelius (nico-ccollect at schottelius.org) +# 2005-2009 Nico Schottelius (nico-ccollect at schottelius.org) # # This file is part of ccollect. # @@ -38,7 +38,7 @@ CPOSTEXEC="${CDEFAULTS}/post_exec" TMP=$(mktemp "/tmp/${__myname}.XXXXXX") VERSION=0.7.1 -RELEASE="2008-04-XX" +RELEASE="2009-XX-XX" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" @@ -79,7 +79,7 @@ _exit_err() add_name() { - sed "s:^:\[${name}\] :" + awk "{ print \"[${name}] \" \$0 }" } pcmd() From af242905af7f33b216006a0bb4b97ec7c855a57b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 2 Feb 2009 11:49:12 +0100 Subject: [PATCH 298/581] add testsource for &-test Signed-off-by: Nico Schottelius --- conf/sources/local1&with-ampersand/destination | 1 + conf/sources/local1&with-ampersand/exclude | 1 + conf/sources/local1&with-ampersand/source | 1 + 3 files changed, 3 insertions(+) create mode 100644 conf/sources/local1&with-ampersand/destination create mode 100644 conf/sources/local1&with-ampersand/exclude create mode 100644 conf/sources/local1&with-ampersand/source diff --git a/conf/sources/local1&with-ampersand/destination b/conf/sources/local1&with-ampersand/destination new file mode 100644 index 0000000..8cac69d --- /dev/null +++ b/conf/sources/local1&with-ampersand/destination @@ -0,0 +1 @@ +/tmp/ccollect diff --git a/conf/sources/local1&with-ampersand/exclude b/conf/sources/local1&with-ampersand/exclude new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/conf/sources/local1&with-ampersand/exclude @@ -0,0 +1 @@ +.git diff --git a/conf/sources/local1&with-ampersand/source b/conf/sources/local1&with-ampersand/source new file mode 100644 index 0000000..9686138 --- /dev/null +++ b/conf/sources/local1&with-ampersand/source @@ -0,0 +1 @@ +/home/user/nico/bin From c133ba5df9768eb12a577d260df68def114113e8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 2 Feb 2009 12:10:48 +0100 Subject: [PATCH 299/581] add release date Signed-off-by: Nico Schottelius --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index 837a895..e14dcfc 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -38,7 +38,7 @@ CPOSTEXEC="${CDEFAULTS}/post_exec" TMP=$(mktemp "/tmp/${__myname}.XXXXXX") VERSION=0.7.1 -RELEASE="2009-XX-XX" +RELEASE="2009-02-02" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" From 0516749a0cba1885cc8c3529f1897a080ba86355 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 2 Feb 2009 12:10:56 +0100 Subject: [PATCH 300/581] update changes Signed-off-by: Nico Schottelius --- doc/changes/0.7.1 | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changes/0.7.1 b/doc/changes/0.7.1 index cc68e79..9ab676a 100644 --- a/doc/changes/0.7.1 +++ b/doc/changes/0.7.1 @@ -5,3 +5,4 @@ * More hints * Updated remote_host description * Bugfix in shell artihmetic (Jeroen Bruijning) +* Bugfix: Allow "&" in sourcename (Reported by Tiziano Müller) From 00c1303fb225261839577bb0adf25430331f8f8c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 2 Feb 2009 12:14:34 +0100 Subject: [PATCH 301/581] add ccollect_list_intervals.sh to the tools Signed-off-by: Nico Schottelius --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 84ffb69..cfafa7a 100644 --- a/Makefile +++ b/Makefile @@ -119,6 +119,7 @@ install-manlink: install-man TOOLS=ccollect_add_source.sh \ ccollect_analyse_logs.sh \ ccollect_delete_source.sh \ + ccollect_list_intervals.sh \ ccollect_logwrapper.sh \ ccollect_list_intervals.sh From bf22075407790d1a3fc78b481e55d7ac24698c17 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 2 Feb 2009 12:16:04 +0100 Subject: [PATCH 302/581] update todo and changes Signed-off-by: Nico Schottelius --- doc/changes/0.7.1 | 1 + doc/todo/0.7.1 | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/doc/changes/0.7.1 b/doc/changes/0.7.1 index 9ab676a..adf9ff4 100644 --- a/doc/changes/0.7.1 +++ b/doc/changes/0.7.1 @@ -6,3 +6,4 @@ * Updated remote_host description * Bugfix in shell artihmetic (Jeroen Bruijning) * Bugfix: Allow "&" in sourcename (Reported by Tiziano Müller) +* Added ccollect_list_intervals.sh to list intervals with values diff --git a/doc/todo/0.7.1 b/doc/todo/0.7.1 index 4f4b3e6..49df154 100644 --- a/doc/todo/0.7.1 +++ b/doc/todo/0.7.1 @@ -1,18 +1,13 @@ + +-------------------------------------------------------------------------------- +done: +- tools in makefile 14:15 also alle tools/ccollect_* 14:15 mach mal n besseres Makefile :) 14:15 hatte die extra deswegen umbenannt 14:15 nehme ich mal als hinweis für 0.7.1 -- add wrapper, to do logging and analyse - * output filename in the wrapper, save into variable - => mktemp - * call analyser - => output stdout? - - --------------------------------------------------------------------------------- -done: - add global delete_incomplete (/etc/ccollect/defaults/delete_incomplete) @@ -32,3 +27,9 @@ reject: -------------------------------------------------------------------------------- - fix german documentation! => I'm the coder, somebody else can fix it. +- add wrapper, to do logging and analyse + * output filename in the wrapper, save into variable + => mktemp + * call analyser + => output stdout? + => no use for that currently From 1943bfd244ed98103c4fd8e025df4c3e33258b44 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 2 Feb 2009 12:39:42 +0100 Subject: [PATCH 303/581] update release script Signed-off-by: Nico Schottelius --- release.sh | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/release.sh b/release.sh index e6ae08a..976a5c4 100755 --- a/release.sh +++ b/release.sh @@ -20,38 +20,39 @@ # Standard release script for dummies like me # -if [ $# -ne 1 ]; then - echo "$0: ccollect dir" +if [ $# -ne 2 ]; then + echo "$0: version description" exit 23 fi echo "Did you change version and date information in the script?" read bla -NAME=$1 +VERSION="$1"; shift +DESCRIPTION="$1"; shift +NAME=ccollect-${VERSION} TARNAME=${NAME}.tar.bz2 - +TARLOCAL=../${TARNAME} DHOST=nico@home.schottelius.org -DDIR=www/org/schottelius/unix/www/ccollect/ +DDIR=www/unix.schottelius.org/www/ccollect/ DESTINATION="$DHOST:$DDIR" -# create documentation for the end user -( - cd "$NAME" - make dist - make publish-doc -) +set -e +set -x +git tag -m "$DESCRIPTION" "$VERSION" +git push --mirror +git archive --prefix="${NAME}/" "$VERSION" | bzip2 > "$TARLOCAL" +scp "${TARLOCAL}" "$DESTINATION" -tar cvfj "$TARNAME" \ - --exclude=.git \ - --exclude="conf/sources/*/destination/*" "$NAME" +# create & publish documentation for the end user +make publish-doc -scp "${TARNAME}" "$DESTINATION" -ssh "$DHOST" "( cd $DDIR; tar xfj \"$TARNAME\" )" +ssh "$DHOST" "( cd "$DDIR" &&; tar xfj \"$TARNAME\" )" echo "setting paranoid permissions to public..." -ssh "$DHOST" "( cd $DDIR; find -type d -exec chmod 0755 {} \; )" -ssh "$DHOST" "( cd $DDIR; find -type f -exec chmod 0644 {} \; )" +ssh "$DHOST" "( cd "$DDIR" && find -type d -exec chmod 0755 {} \; )" +ssh "$DHOST" "( cd "$DDIR" &&; find -type f -exec chmod 0644 {} \; )" -cat "${NAME}/doc/release-checklist" +cat "doc/release-checklist" +exit 0 From 6de3c9877c776eacf669d0dfe8d2c8b40719ad81 Mon Sep 17 00:00:00 2001 From: Tonnerre Lombard Date: Wed, 4 Feb 2009 08:25:35 +0100 Subject: [PATCH 304/581] Keep a symlink to the current backup around. This allows us to establish automatic restore features (e.g. through Puppet file facts). --- ccollect.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ccollect.sh b/ccollect.sh index e14dcfc..77f2c5c 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -561,6 +561,9 @@ while [ "${i}" -lt "${no_sources}" ]; do _techo "Finished backup (rsync return code: $ret)." if [ "${ret}" -ne 0 ]; then _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." + else + [ -e "${destination}/${INTERVAL}.current" ] && rm -f "${destination}/${INTERVAL}.current" + ln -s "$(basename "${destination_full}")" "${destination}/${INTERVAL}.current" fi # From 38ca0a15463fcf07698d4980df7e0f9abb48135d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 4 Feb 2009 15:12:27 +0100 Subject: [PATCH 305/581] Revert "Keep a symlink to the current backup around. This allows us to" This patch is broken for non local destinations. This reverts commit 6de3c9877c776eacf669d0dfe8d2c8b40719ad81. --- ccollect.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 77f2c5c..e14dcfc 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -561,9 +561,6 @@ while [ "${i}" -lt "${no_sources}" ]; do _techo "Finished backup (rsync return code: $ret)." if [ "${ret}" -ne 0 ]; then _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." - else - [ -e "${destination}/${INTERVAL}.current" ] && rm -f "${destination}/${INTERVAL}.current" - ln -s "$(basename "${destination_full}")" "${destination}/${INTERVAL}.current" fi # From 27c838163a9378be5776b5c1426ebea62d09e742 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 4 Feb 2009 16:28:57 +0100 Subject: [PATCH 306/581] add macosx as tested Signed-off-by: Nico Schottelius --- doc/ccollect.text | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/ccollect.text b/doc/ccollect.text index 150803a..124f060 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -23,6 +23,7 @@ Supported and tested operating systems and architectures - GNU/Linux on amd64/hppa/i386/ppc - FreeBSD on amd64/i386 +- Mac OS X 10.5 - NetBSD on alpha/amd64/i386/sparc/sparc64 - OpenBSD on amd64 From 8cc0f04874fb21deb62e2662d72c88e146a070a7 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 23 May 2009 14:34:09 +0200 Subject: [PATCH 307/581] add patched version of ccollect-0.7.1 by John Lawless Signed-off-by: Nico Schottelius --- contrib/ccollect-0.7.1-jlawless.sh | 683 +++++++++++++++++++++++++++++ 1 file changed, 683 insertions(+) create mode 100755 contrib/ccollect-0.7.1-jlawless.sh diff --git a/contrib/ccollect-0.7.1-jlawless.sh b/contrib/ccollect-0.7.1-jlawless.sh new file mode 100755 index 0000000..5c8952e --- /dev/null +++ b/contrib/ccollect-0.7.1-jlawless.sh @@ -0,0 +1,683 @@ +#!/bin/sh +# +# 2005-2009 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# Initially written for SyGroup (www.sygroup.ch) +# Date: Mon Nov 14 11:45:11 CET 2005 + +# +# Standard variables (stolen from cconf) +# +__pwd="$(pwd -P)" +__mydir="${0%/*}"; __abs_mydir="$(cd "$__mydir" && pwd -P)" +__myname=${0##*/}; __abs_myname="$__abs_mydir/$__myname" + +# +# where to find our configuration and temporary file +# +CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} +CSOURCES=${CCOLLECT_CONF}/sources +CDEFAULTS=${CCOLLECT_CONF}/defaults +CPREEXEC="${CDEFAULTS}/pre_exec" +CPOSTEXEC="${CDEFAULTS}/post_exec" + +TMP=$(mktemp "/tmp/${__myname}.XXXXXX") +VERSION=0.7.1 +RELEASE="2009-02-02" +HALF_VERSION="ccollect ${VERSION}" +FULL_VERSION="ccollect ${VERSION} (${RELEASE})" + +#TSORT="tc" ; NEWER="cnewer" +TSORT="t" ; NEWER="newer" + +# +# CDATE: how we use it for naming of the archives +# DDATE: how the user should see it in our output (DISPLAY) +# +CDATE="date +%Y%m%d-%H%M" +DDATE="date +%Y-%m-%d-%H:%M:%S" + +# +# unset parallel execution +# +PARALLEL="" + +# +# catch signals +# +trap "rm -f \"${TMP}\"" 1 2 15 + +# +# Functions +# + +# time displaying echo +_techo() +{ + echo "$(${DDATE}): $@" +} + +# exit on error +_exit_err() +{ + _techo "$@" + rm -f "${TMP}" + exit 1 +} + +add_name() +{ + awk "{ print \"[${name}] \" \$0 }" +} + +pcmd() +{ + if [ "$remote_host" ]; then + ssh "$remote_host" "$@" + else + "$@" + fi +} + +# +# Version +# +display_version() +{ + echo "${FULL_VERSION}" + exit 0 +} + +# +# Tell how to use us +# +usage() +{ + echo "${__myname}: [args] " + echo "" + echo " ccollect creates (pseudo) incremental backups" + echo "" + echo " -h, --help: Show this help screen" + echo " -p, --parallel: Parallelise backup processes" + echo " -a, --all: Backup all sources specified in ${CSOURCES}" + echo " -v, --verbose: Be very verbose (uses set -x)" + echo " -V, --version: Print version information" + echo "" + echo " This is version ${VERSION}, released on ${RELEASE}" + echo " (the first version was written on 2005-12-05 by Nico Schottelius)." + echo "" + echo " Retrieve latest ccollect at http://unix.schottelius.org/ccollect/" + exit 0 +} + +# +# Select interval if AUTO +# +# For this to work nicely, you have to choose interval names that sort nicely +# such as int1, int2, int3 or a_daily, b_weekly, c_monthly, etc. +# +auto_interval() +{ + if [ -d "${backup}/intervals" -a -n "$(ls "${backup}/intervals" 2>/dev/null)" ] ; then + intervals_dir="${backup}/intervals" + elif [ -d "${CDEFAULTS}/intervals" -a -n "$(ls "${CDEFAULTS}/intervals" 2>/dev/null)" ] ; then + intervals_dir="${CDEFAULTS}/intervals" + else + _exit_err "No intervals are defined. Skipping." + fi + echo intervals_dir=${intervals_dir} + + trial_interval="$(ls -1r "${intervals_dir}/" | head -n 1)" || \ + _exit_err "Failed to list contents of ${intervals_dir}/." + _techo "Considering interval ${trial_interval}" + most_recent="$(pcmd ls -${TSORT}p1 "${ddir}" | grep "^${trial_interval}.*/$" | head -n 1)" || \ + _exit_err "Failed to list contents of ${ddir}/." + _techo " Most recent ${trial_interval}: '${most_recent}'" + if [ -n "${most_recent}" ]; then + no_intervals="$(ls -1 "${intervals_dir}/" | wc -l)" + n=1 + while [ "${n}" -le "${no_intervals}" ]; do + trial_interval="$(ls -p1 "${intervals_dir}/" | tail -n+${n} | head -n 1)" + _techo "Considering interval '${trial_interval}'" + c_interval="$(cat "${intervals_dir}/${trial_interval}" 2>/dev/null)" + m=$((${n}+1)) + set -- "${ddir}" -maxdepth 1 + while [ "${m}" -le "${no_intervals}" ]; do + interval_m="$(ls -1 "${intervals_dir}/" | tail -n+${m} | head -n 1)" + most_recent="$(pcmd ls -${TSORT}p1 "${ddir}" | grep "^${interval_m}\..*/$" | head -n 1)" + _techo " Most recent ${interval_m}: '${most_recent}'" + if [ -n "${most_recent}" ] ; then + set -- "$@" -$NEWER "${ddir}/${most_recent}" + fi + m=$((${m}+1)) + done + count=$(pcmd find "$@" -iname "${trial_interval}*" | wc -l) + _techo " Found $count more recent backups of ${trial_interval} (limit: ${c_interval})" + if [ "$count" -lt "${c_interval}" ] ; then + break + fi + n=$((${n}+1)) + done + fi + export INTERVAL="${trial_interval}" + D_FILE_INTERVAL="${intervals_dir}/${INTERVAL}" + D_INTERVAL=$(cat "${D_FILE_INTERVAL}" 2>/dev/null) +} + +# +# need at least interval and one source or --all +# +if [ $# -lt 2 ]; then + if [ "$1" = "-V" -o "$1" = "--version" ]; then + display_version + else + usage + fi +fi + +# +# check for configuraton directory +# +[ -d "${CCOLLECT_CONF}" ] || _exit_err "No configuration found in " \ + "\"${CCOLLECT_CONF}\" (is \$CCOLLECT_CONF properly set?)" + +# +# Filter arguments +# +export INTERVAL="$1"; shift +i=1 +no_sources=0 + +# +# Create source "array" +# +while [ "$#" -ge 1 ]; do + eval arg=\"\$1\"; shift + + if [ "${NO_MORE_ARGS}" = 1 ]; then + eval source_${no_sources}=\"${arg}\" + no_sources=$((${no_sources}+1)) + + # make variable available for subscripts + eval export source_${no_sources} + else + case "${arg}" in + -a|--all) + ALL=1 + ;; + -v|--verbose) + VERBOSE=1 + ;; + -p|--parallel) + PARALLEL=1 + ;; + -h|--help) + usage + ;; + --) + NO_MORE_ARGS=1 + ;; + *) + eval source_${no_sources}=\"$arg\" + no_sources=$(($no_sources+1)) + ;; + esac + fi + + i=$(($i+1)) +done + +# also export number of sources +export no_sources + +# +# be really, really, really verbose +# +if [ "${VERBOSE}" = 1 ]; then + set -x +fi + +# +# Look, if we should take ALL sources +# +if [ "${ALL}" = 1 ]; then + # reset everything specified before + no_sources=0 + + # + # get entries from sources + # + cwd=$(pwd -P) + ( cd "${CSOURCES}" && ls > "${TMP}" ); ret=$? + + [ "${ret}" -eq 0 ] || _exit_err "Listing of sources failed. Aborting." + + while read tmp; do + eval source_${no_sources}=\"${tmp}\" + no_sources=$((${no_sources}+1)) + done < "${TMP}" +fi + +# +# Need at least ONE source to backup +# +if [ "${no_sources}" -lt 1 ]; then + usage +else + _techo "${HALF_VERSION}: Beginning backup using interval ${INTERVAL}" +fi + +# +# Look for pre-exec command (general) +# +if [ -x "${CPREEXEC}" ]; then + _techo "Executing ${CPREEXEC} ..." + "${CPREEXEC}"; ret=$? + _techo "Finished ${CPREEXEC} (return code: ${ret})." + + [ "${ret}" -eq 0 ] || _exit_err "${CPREEXEC} failed. Aborting" +fi + +# +# check default configuration +# + +D_FILE_INTERVAL="${CDEFAULTS}/intervals/${INTERVAL}" +D_INTERVAL=$(cat "${D_FILE_INTERVAL}" 2>/dev/null) + + +# +# Let's do the backup +# +i=0 +while [ "${i}" -lt "${no_sources}" ]; do + + # + # Get current source + # + eval name=\"\$source_${i}\" + i=$((${i}+1)) + + export name + + # + # start ourself, if we want parallel execution + # + if [ "${PARALLEL}" ]; then + "$0" "${INTERVAL}" "${name}" & + continue + fi + +# +# Start subshell for easy log editing +# +( + # + # Stderr to stdout, so we can produce nice logs + # + exec 2>&1 + + # + # Configuration + # + backup="${CSOURCES}/${name}" + c_source="${backup}/source" + c_dest="${backup}/destination" + c_exclude="${backup}/exclude" + c_verbose="${backup}/verbose" + c_vverbose="${backup}/very_verbose" + c_rsync_extra="${backup}/rsync_options" + c_summary="${backup}/summary" + c_pre_exec="${backup}/pre_exec" + c_post_exec="${backup}/post_exec" + f_incomplete="delete_incomplete" + c_incomplete="${backup}/${f_incomplete}" + c_remote_host="${backup}/remote_host" + + # + # Marking backups: If we abort it's not removed => Backup is broken + # + c_marker=".ccollect-marker" + + # + # Times + # + begin_s=$(date +%s) + + # + # unset possible options + # + EXCLUDE="" + RSYNC_EXTRA="" + SUMMARY="" + VERBOSE="" + VVERBOSE="" + DELETE_INCOMPLETE="" + + _techo "Beginning to backup" + + # + # Standard configuration checks + # + if [ ! -e "${backup}" ]; then + _exit_err "Source does not exist." + fi + + # + # configuration _must_ be a directory + # + if [ ! -d "${backup}" ]; then + _exit_err "\"${name}\" is not a cconfig-directory. Skipping." + fi + + # + # first execute pre_exec, which may generate destination or other + # parameters + # + if [ -x "${c_pre_exec}" ]; then + _techo "Executing ${c_pre_exec} ..." + "${c_pre_exec}"; ret="$?" + _techo "Finished ${c_pre_exec} (return code ${ret})." + + if [ "${ret}" -ne 0 ]; then + _exit_err "${c_pre_exec} failed. Skipping." + fi + fi + + # + # Destination is a path + # + if [ ! -f "${c_dest}" ]; then + _exit_err "Destination ${c_dest} is not a file. Skipping." + else + ddir=$(cat "${c_dest}"); ret="$?" + if [ "${ret}" -ne 0 ]; then + _exit_err "Destination ${c_dest} is not readable. Skipping." + fi + fi + + # + # interval definition: First try source specific, fallback to default + # + if [ ${INTERVAL} = "AUTO" ] ; then + auto_interval + _techo "Selected interval: '$INTERVAL'" + fi + c_interval="$(cat "${backup}/intervals/${INTERVAL}" 2>/dev/null)" + + if [ -z "${c_interval}" ]; then + c_interval="${D_INTERVAL}" + + if [ -z "${c_interval}" ]; then + _exit_err "No definition for interval \"${INTERVAL}\" found. Skipping." + fi + fi + + # + # Source checks + # + if [ ! -f "${c_source}" ]; then + _exit_err "Source description \"${c_source}\" is not a file. Skipping." + else + source=$(cat "${c_source}"); ret="$?" + if [ "${ret}" -ne 0 ]; then + _exit_err "Source ${c_source} is not readable. Skipping." + fi + fi + # Verify source is up and accepting connections before deleting any old backups + rsync "$source" >/dev/null || _exit_err "Source ${source} is not readable. Skipping." + + # + # do we backup to a remote host? then set pre-cmd + # + if [ -f "${c_remote_host}" ]; then + # adjust ls and co + remote_host=$(cat "${c_remote_host}"); ret="$?" + if [ "${ret}" -ne 0 ]; then + _exit_err "Remote host file ${c_remote_host} exists, but is not readable. Skipping." + fi + destination="${remote_host}:${ddir}" + else + remote_host="" + destination="${ddir}" + fi + export remote_host + + # + # check for existence / use real name + # + ( pcmd cd "$ddir" ) || _exit_err "Cannot change to ${ddir}. Skipping." + + + # + # Check whether to delete incomplete backups + # + if [ -f "${c_incomplete}" -o -f "${CDEFAULTS}/${f_incomplete}" ]; then + DELETE_INCOMPLETE="yes" + fi + + # NEW method as of 0.6: + # - insert ccollect default parameters + # - insert options + # - insert user options + + # + # rsync standard options + # + + set -- "$@" "--archive" "--delete" "--numeric-ids" "--relative" \ + "--delete-excluded" "--sparse" + + # + # exclude list + # + if [ -f "${c_exclude}" ]; then + set -- "$@" "--exclude-from=${c_exclude}" + fi + + # + # Output a summary + # + if [ -f "${c_summary}" ]; then + set -- "$@" "--stats" + fi + + # + # Verbosity for rsync + # + if [ -f "${c_vverbose}" ]; then + set -- "$@" "-vv" + elif [ -f "${c_verbose}" ]; then + set -- "$@" "-v" + fi + + # + # extra options for rsync provided by the user + # + if [ -f "${c_rsync_extra}" ]; then + while read line; do + set -- "$@" "$line" + done < "${c_rsync_extra}" + fi + + # + # Check for incomplete backups + # + pcmd ls -1 "$ddir/${INTERVAL}"*".${c_marker}" > "${TMP}" 2>/dev/null + + i=0 + while read incomplete; do + eval incomplete_$i=\"$(echo ${incomplete} | sed "s/\\.${c_marker}\$//")\" + i=$(($i+1)) + done < "${TMP}" + + j=0 + while [ "$j" -lt "$i" ]; do + eval realincomplete=\"\$incomplete_$j\" + _techo "Incomplete backup: ${realincomplete}" + if [ "${DELETE_INCOMPLETE}" = "yes" ]; then + _techo "Deleting ${realincomplete} ..." + pcmd rm $VVERBOSE -rf "${ddir}/${realincomplete}" || \ + _exit_err "Removing ${realincomplete} failed." + fi + j=$(($j+1)) + done + + # + # check if maximum number of backups is reached, if so remove + # use grep and ls -p so we only look at directories + # + count="$(pcmd ls -p1 "${ddir}" | grep "^${INTERVAL}\..*/\$" | wc -l \ + | sed 's/^ *//g')" || _exit_err "Counting backups failed" + + _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" + + if [ "${count}" -ge "${c_interval}" ]; then + substract=$((${c_interval} - 1)) + remove=$((${count} - ${substract})) + _techo "Removing ${remove} backup(s)..." + + pcmd ls -${TSORT}p1r "$ddir" | grep "^${INTERVAL}\..*/\$" | \ + head -n "${remove}" > "${TMP}" || \ + _exit_err "Listing old backups failed" + + i=0 + while read to_remove; do + eval remove_$i=\"${to_remove}\" + i=$(($i+1)) + done < "${TMP}" + + j=0 + while [ "$j" -lt "$i" ]; do + eval to_remove=\"\$remove_$j\" + _techo "Removing ${to_remove} ..." + pcmd rm ${VVERBOSE} -rf "${ddir}/${to_remove}" || \ + _exit_err "Removing ${to_remove} failed." + j=$(($j+1)) + done + fi + + + # + # Check for backup directory to clone from: Always clone from the latest one! + # + # Depending on your file system, you may want to sort on: + # 1. mtime (modification time) with TSORT=t, or + # 2. ctime (last change time, usually) with TSORT=tc + last_dir="$(pcmd ls -${TSORT}p1 "${ddir}" | grep '/$' | head -n 1)" || \ + _exit_err "Failed to list contents of ${ddir}." + + # + # clone from old backup, if existing + # + if [ "${last_dir}" ]; then + set -- "$@" "--link-dest=${ddir}/${last_dir}" + _techo "Hard linking from ${last_dir}" + fi + + + # set time when we really begin to backup, not when we began to remove above + destination_date=$(${CDATE}) + destination_dir="${ddir}/${INTERVAL}.${destination_date}.$$" + destination_full="${destination}/${INTERVAL}.${destination_date}.$$" + + # give some info + _techo "Beginning to backup, this may take some time..." + + _techo "Creating ${destination_dir} ..." + pcmd mkdir ${VVERBOSE} "${destination_dir}" || \ + _exit_err "Creating ${destination_dir} failed. Skipping." + + # + # added marking in 0.6 (and remove it, if successful later) + # + pcmd touch "${destination_dir}.${c_marker}" + + # + # the rsync part + # + _techo "Transferring files..." + rsync "$@" "${source}" "${destination_full}"; ret=$? + # Correct the modification time: + pcmd touch "${destination_dir}" + + # + # remove marking here + # + if [ "$ret" -ne 12 ] ; then + pcmd rm "${destination_dir}.${c_marker}" || \ + _exit_err "Removing ${destination_dir}/${c_marker} failed." + fi + + _techo "Finished backup (rsync return code: $ret)." + if [ "${ret}" -ne 0 ]; then + _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." + fi + + # + # post_exec + # + if [ -x "${c_post_exec}" ]; then + _techo "Executing ${c_post_exec} ..." + "${c_post_exec}"; ret=$? + _techo "Finished ${c_post_exec}." + + if [ ${ret} -ne 0 ]; then + _exit_err "${c_post_exec} failed." + fi + fi + + # Calculation + end_s=$(date +%s) + + full_seconds=$((${end_s} - ${begin_s})) + hours=$((${full_seconds} / 3600)) + seconds=$((${full_seconds} - (${hours} * 3600))) + minutes=$((${seconds} / 60)) + seconds=$((${seconds} - (${minutes} * 60))) + + _techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" + +) | add_name +done + +# +# Be a good parent and wait for our children, if they are running wild parallel +# +if [ "${PARALLEL}" ]; then + _techo "Waiting for children to complete..." + wait +fi + +# +# Look for post-exec command (general) +# +if [ -x "${CPOSTEXEC}" ]; then + _techo "Executing ${CPOSTEXEC} ..." + "${CPOSTEXEC}"; ret=$? + _techo "Finished ${CPOSTEXEC} (return code: ${ret})." + + if [ ${ret} -ne 0 ]; then + _techo "${CPOSTEXEC} failed." + fi +fi + +rm -f "${TMP}" +_techo "Finished ${WE}" + +# vim: set shiftwidth=3 tabstop=3 expandtab : From ae23a0492506308257246af6fabda8ac7b0f6b47 Mon Sep 17 00:00:00 2001 From: John Lawless Date: Mon, 18 May 2009 22:22:15 -0700 Subject: [PATCH 308/581] First, I added the following before any old backup gets deleted: > # Verify source is up and accepting connections before deleting any old backups > rsync "$source" >/dev/null || _exit_err "Source ${source} is not readable. Skipping." I think that this quick test is a much better than, say, pinging the source in a pre-exec script: this tests not only that the source is up and connected to the net, it also verifies (1) that ssh is up and accepting our key (if we are using ssh), and (2) that the source directory is mounted (if it needs to be mounted) and readable. --- ccollect.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ccollect.sh b/ccollect.sh index e14dcfc..0444ff0 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -366,6 +366,8 @@ while [ "${i}" -lt "${no_sources}" ]; do _exit_err "Source ${c_source} is not readable. Skipping." fi fi + # Verify source is up and accepting connections before deleting any old backups + rsync "$source" >/dev/null || _exit_err "Source ${source} is not readable. Skipping." # # Destination is a path From a030a989826e398dcc432b62384fbaeb3c57cc3a Mon Sep 17 00:00:00 2001 From: John Lawless Date: Mon, 18 May 2009 22:22:15 -0700 Subject: [PATCH 309/581] First, I added the following before any old backup gets deleted: > # Verify source is up and accepting connections before deleting any old backups > rsync "$source" >/dev/null || _exit_err "Source ${source} is not readable. Skipping." I think that this quick test is a much better than, say, pinging the source in a pre-exec script: this tests not only that the source is up and connected to the net, it also verifies (1) that ssh is up and accepting our key (if we are using ssh), and (2) that the source directory is mounted (if it needs to be mounted) and readable. --- ccollect.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ccollect.sh b/ccollect.sh index e14dcfc..0444ff0 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -366,6 +366,8 @@ while [ "${i}" -lt "${no_sources}" ]; do _exit_err "Source ${c_source} is not readable. Skipping." fi fi + # Verify source is up and accepting connections before deleting any old backups + rsync "$source" >/dev/null || _exit_err "Source ${source} is not readable. Skipping." # # Destination is a path From bce57a1ac1e068ba5f586de645dd103f7aa46c0f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 10 Jun 2009 09:50:05 +0200 Subject: [PATCH 310/581] Introduce consistent time sorting Based on patches by John Lawless . Skipped the sort changing part (from -tc to -t) c.patch: --- ccollect-0.7.1-b.sh 2009-05-24 21:32:00.000000000 -0700 +++ ccollect-0.7.1-c.sh 2009-05-24 21:39:43.000000000 -0700 @@ -40,10 +40,13 @@ VERSION=0.7.1 RELEASE="2009-02-02" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" +#TSORT="tc" ; NEWER="cnewer" +TSORT="t" ; NEWER="newer" + # # CDATE: how we use it for naming of the archives # DDATE: how the user should see it in our output (DISPLAY) # CDATE="date +%Y%m%d-%H%M" @@ -513,14 +516,14 @@ # # Check for backup directory to clone from: Always clone from the latest one! # - # Use ls -1c instead of -1t, because last modification maybe the same on all - # and metadate update (-c) is updated by rsync locally. - # - last_dir="$(pcmd ls -tcp1 "${ddir}" | grep '/$' | head -n 1)" || \ + # Depending on your file system, you may want to sort on: + # 1. mtime (modification time) with TSORT=t, or + # 2. ctime (last change time, usually) with TSORT=tc + last_dir="$(pcmd ls -${TSORT}p1 "${ddir}" | grep '/$' | head -n 1)" || \ _exit_err "Failed to list contents of ${ddir}." # # clone from old backup, if existing # d.patch: --- ccollect-0.7.1-c.sh 2009-05-24 21:39:43.000000000 -0700 +++ ccollect-0.7.1-d.sh 2009-05-24 21:47:09.000000000 -0700 @@ -492,12 +492,12 @@ if [ "${count}" -ge "${c_interval}" ]; then substract=$((${c_interval} - 1)) remove=$((${count} - ${substract})) _techo "Removing ${remove} backup(s)..." - pcmd ls -p1 "$ddir" | grep "^${INTERVAL}\..*/\$" | \ - sort -n | head -n "${remove}" > "${TMP}" || \ + pcmd ls -${TSORT}p1r "$ddir" | grep "^${INTERVAL}\..*/\$" | \ + head -n "${remove}" > "${TMP}" || \ _exit_err "Listing old backups failed" i=0 while read to_remove; do eval remove_$i=\"${to_remove}\" Signed-off-by: Nico Schottelius --- ccollect.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 0444ff0..e1555ea 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -45,9 +45,11 @@ FULL_VERSION="ccollect ${VERSION} (${RELEASE})" # # CDATE: how we use it for naming of the archives # DDATE: how the user should see it in our output (DISPLAY) +# TSORT: how to sort: tc = ctime, t = mtime # CDATE="date +%Y%m%d-%H%M" DDATE="date +%Y-%m-%d-%H:%M:%S" +TSORT="tc" # # unset parallel execution @@ -491,8 +493,8 @@ while [ "${i}" -lt "${no_sources}" ]; do remove=$((${count} - ${substract})) _techo "Removing ${remove} backup(s)..." - pcmd ls -p1 "$ddir" | grep "^${INTERVAL}\..*/\$" | \ - sort -n | head -n "${remove}" > "${TMP}" || \ + pcmd ls -${TSORT}p1r "$ddir" | grep "^${INTERVAL}\..*/\$" | \ + head -n "${remove}" > "${TMP}" || \ _exit_err "Listing old backups failed" i=0 @@ -518,7 +520,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # Use ls -1c instead of -1t, because last modification maybe the same on all # and metadate update (-c) is updated by rsync locally. # - last_dir="$(pcmd ls -tcp1 "${ddir}" | grep '/$' | head -n 1)" || \ + last_dir="$(pcmd ls -${TSORT}p1 "${ddir}" | grep '/$' | head -n 1)" || \ _exit_err "Failed to list contents of ${ddir}." # From 62e8190a941731a006cbe45673c6287fe400f41b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 10 Jun 2009 09:50:05 +0200 Subject: [PATCH 311/581] Introduce consistent time sorting Based on patches by John Lawless . Skipped the sort changing part (from -tc to -t) c.patch: --- ccollect-0.7.1-b.sh 2009-05-24 21:32:00.000000000 -0700 +++ ccollect-0.7.1-c.sh 2009-05-24 21:39:43.000000000 -0700 @@ -40,10 +40,13 @@ VERSION=0.7.1 RELEASE="2009-02-02" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" +#TSORT="tc" ; NEWER="cnewer" +TSORT="t" ; NEWER="newer" + # # CDATE: how we use it for naming of the archives # DDATE: how the user should see it in our output (DISPLAY) # CDATE="date +%Y%m%d-%H%M" @@ -513,14 +516,14 @@ # # Check for backup directory to clone from: Always clone from the latest one! # - # Use ls -1c instead of -1t, because last modification maybe the same on all - # and metadate update (-c) is updated by rsync locally. - # - last_dir="$(pcmd ls -tcp1 "${ddir}" | grep '/$' | head -n 1)" || \ + # Depending on your file system, you may want to sort on: + # 1. mtime (modification time) with TSORT=t, or + # 2. ctime (last change time, usually) with TSORT=tc + last_dir="$(pcmd ls -${TSORT}p1 "${ddir}" | grep '/$' | head -n 1)" || \ _exit_err "Failed to list contents of ${ddir}." # # clone from old backup, if existing # d.patch: --- ccollect-0.7.1-c.sh 2009-05-24 21:39:43.000000000 -0700 +++ ccollect-0.7.1-d.sh 2009-05-24 21:47:09.000000000 -0700 @@ -492,12 +492,12 @@ if [ "${count}" -ge "${c_interval}" ]; then substract=$((${c_interval} - 1)) remove=$((${count} - ${substract})) _techo "Removing ${remove} backup(s)..." - pcmd ls -p1 "$ddir" | grep "^${INTERVAL}\..*/\$" | \ - sort -n | head -n "${remove}" > "${TMP}" || \ + pcmd ls -${TSORT}p1r "$ddir" | grep "^${INTERVAL}\..*/\$" | \ + head -n "${remove}" > "${TMP}" || \ _exit_err "Listing old backups failed" i=0 while read to_remove; do eval remove_$i=\"${to_remove}\" Signed-off-by: Nico Schottelius --- ccollect.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 0444ff0..e1555ea 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -45,9 +45,11 @@ FULL_VERSION="ccollect ${VERSION} (${RELEASE})" # # CDATE: how we use it for naming of the archives # DDATE: how the user should see it in our output (DISPLAY) +# TSORT: how to sort: tc = ctime, t = mtime # CDATE="date +%Y%m%d-%H%M" DDATE="date +%Y-%m-%d-%H:%M:%S" +TSORT="tc" # # unset parallel execution @@ -491,8 +493,8 @@ while [ "${i}" -lt "${no_sources}" ]; do remove=$((${count} - ${substract})) _techo "Removing ${remove} backup(s)..." - pcmd ls -p1 "$ddir" | grep "^${INTERVAL}\..*/\$" | \ - sort -n | head -n "${remove}" > "${TMP}" || \ + pcmd ls -${TSORT}p1r "$ddir" | grep "^${INTERVAL}\..*/\$" | \ + head -n "${remove}" > "${TMP}" || \ _exit_err "Listing old backups failed" i=0 @@ -518,7 +520,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # Use ls -1c instead of -1t, because last modification maybe the same on all # and metadate update (-c) is updated by rsync locally. # - last_dir="$(pcmd ls -tcp1 "${ddir}" | grep '/$' | head -n 1)" || \ + last_dir="$(pcmd ls -${TSORT}p1 "${ddir}" | grep '/$' | head -n 1)" || \ _exit_err "Failed to list contents of ${ddir}." # From ba538ea6237a9d0733f54e9145b9b968023e6b96 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 10 Jun 2009 09:55:38 +0200 Subject: [PATCH 312/581] Beautify a comment Signed-off-by: Nico Schottelius --- ccollect.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index e1555ea..cd13ac8 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -368,8 +368,11 @@ while [ "${i}" -lt "${no_sources}" ]; do _exit_err "Source ${c_source} is not readable. Skipping." fi fi + + # # Verify source is up and accepting connections before deleting any old backups - rsync "$source" >/dev/null || _exit_err "Source ${source} is not readable. Skipping." + # + rsync "${source}" >/dev/null || _exit_err "Source ${source} is not readable. Skipping." # # Destination is a path From 382c159b413ce00a05d49f881e509a5234bdd259 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 10 Jun 2009 09:55:38 +0200 Subject: [PATCH 313/581] Beautify a comment Signed-off-by: Nico Schottelius --- ccollect.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index e1555ea..cd13ac8 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -368,8 +368,11 @@ while [ "${i}" -lt "${no_sources}" ]; do _exit_err "Source ${c_source} is not readable. Skipping." fi fi + + # # Verify source is up and accepting connections before deleting any old backups - rsync "$source" >/dev/null || _exit_err "Source ${source} is not readable. Skipping." + # + rsync "${source}" >/dev/null || _exit_err "Source ${source} is not readable. Skipping." # # Destination is a path From 02264020f5b61097400b115a664335bd218b3553 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 10 Jun 2009 09:56:13 +0200 Subject: [PATCH 314/581] add changes for the next release Signed-off-by: Nico Schottelius --- doc/changes/next | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 doc/changes/next diff --git a/doc/changes/next b/doc/changes/next new file mode 100644 index 0000000..0d7bd1f --- /dev/null +++ b/doc/changes/next @@ -0,0 +1,2 @@ +* Introduce consistenst time sorting (John Lawless) +* Check for source connectivity before trying backup (John Lawless) From 2b31f8f229ffd02d53fa82f4fc9e8adc1de275ed Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 10 Jun 2009 09:56:13 +0200 Subject: [PATCH 315/581] add changes for the next release Signed-off-by: Nico Schottelius --- doc/changes/next | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 doc/changes/next diff --git a/doc/changes/next b/doc/changes/next new file mode 100644 index 0000000..0d7bd1f --- /dev/null +++ b/doc/changes/next @@ -0,0 +1,2 @@ +* Introduce consistenst time sorting (John Lawless) +* Check for source connectivity before trying backup (John Lawless) From 6595fe7b9770948e14bde77c228a42fc53d2f787 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 16 Jun 2009 10:32:05 +0200 Subject: [PATCH 316/581] add updated patches from john Signed-off-by: Nico Schottelius --- contrib/jlawless-2009-06-03/README_g-i.txt | 15 + .../ccollect-f.sh} | 0 contrib/jlawless-2009-06-03/ccollect-i.sh | 663 +++++++++++++++++ contrib/jlawless-2009-06-03/g.patch | 74 ++ contrib/jlawless-2009-06-03/h.patch | 18 + contrib/jlawless-2009-06-03/i.patch | 134 ++++ .../jlawless-2009-06-03/old/README_a-f.txt | 296 ++++++++ contrib/jlawless-2009-06-03/old/a.patch | 15 + contrib/jlawless-2009-06-03/old/b.patch | 15 + contrib/jlawless-2009-06-03/old/c.patch | 35 + .../jlawless-2009-06-03/old/ccollect-0.7.1.sh | 615 ++++++++++++++++ contrib/jlawless-2009-06-03/old/ccollect-f.sh | 683 ++++++++++++++++++ contrib/jlawless-2009-06-03/old/d.patch | 17 + contrib/jlawless-2009-06-03/old/e.patch | 19 + contrib/jlawless-2009-06-03/old/f.patch | 119 +++ 15 files changed, 2718 insertions(+) create mode 100644 contrib/jlawless-2009-06-03/README_g-i.txt rename contrib/{ccollect-0.7.1-jlawless.sh => jlawless-2009-06-03/ccollect-f.sh} (100%) create mode 100755 contrib/jlawless-2009-06-03/ccollect-i.sh create mode 100644 contrib/jlawless-2009-06-03/g.patch create mode 100644 contrib/jlawless-2009-06-03/h.patch create mode 100644 contrib/jlawless-2009-06-03/i.patch create mode 100644 contrib/jlawless-2009-06-03/old/README_a-f.txt create mode 100644 contrib/jlawless-2009-06-03/old/a.patch create mode 100644 contrib/jlawless-2009-06-03/old/b.patch create mode 100644 contrib/jlawless-2009-06-03/old/c.patch create mode 100755 contrib/jlawless-2009-06-03/old/ccollect-0.7.1.sh create mode 100755 contrib/jlawless-2009-06-03/old/ccollect-f.sh create mode 100644 contrib/jlawless-2009-06-03/old/d.patch create mode 100644 contrib/jlawless-2009-06-03/old/e.patch create mode 100644 contrib/jlawless-2009-06-03/old/f.patch diff --git a/contrib/jlawless-2009-06-03/README_g-i.txt b/contrib/jlawless-2009-06-03/README_g-i.txt new file mode 100644 index 0000000..b782d63 --- /dev/null +++ b/contrib/jlawless-2009-06-03/README_g-i.txt @@ -0,0 +1,15 @@ +Hello Nico, + + I have attached three more patches for ccollect. Each patch +has comments explaining its motivation. + + All of these patches work-for-me (but I continue to test +them). I would be interested in your opinion on, for example, the +general approach used in i.patch which changes the way options are +handled. I think it is a big improvement. If, however, you wanted +the code to go in a different direction, let me know before we +diverge too far. + +Regards, + +John diff --git a/contrib/ccollect-0.7.1-jlawless.sh b/contrib/jlawless-2009-06-03/ccollect-f.sh similarity index 100% rename from contrib/ccollect-0.7.1-jlawless.sh rename to contrib/jlawless-2009-06-03/ccollect-f.sh diff --git a/contrib/jlawless-2009-06-03/ccollect-i.sh b/contrib/jlawless-2009-06-03/ccollect-i.sh new file mode 100755 index 0000000..58fab09 --- /dev/null +++ b/contrib/jlawless-2009-06-03/ccollect-i.sh @@ -0,0 +1,663 @@ +#!/bin/sh +# +# 2005-2009 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# Initially written for SyGroup (www.sygroup.ch) +# Date: Mon Nov 14 11:45:11 CET 2005 + +# +# Standard variables (stolen from cconf) +# +__pwd="$(pwd -P)" +__mydir="${0%/*}"; __abs_mydir="$(cd "$__mydir" && pwd -P)" +__myname=${0##*/}; __abs_myname="$__abs_mydir/$__myname" + +# +# where to find our configuration and temporary file +# +CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} +CSOURCES=${CCOLLECT_CONF}/sources +CDEFAULTS=${CCOLLECT_CONF}/defaults +CPREEXEC="${CDEFAULTS}/pre_exec" +CPOSTEXEC="${CDEFAULTS}/post_exec" + +TMP=$(mktemp "/tmp/${__myname}.XXXXXX") +VERSION=0.7.1 +RELEASE="2009-02-02" +HALF_VERSION="ccollect ${VERSION}" +FULL_VERSION="ccollect ${VERSION} (${RELEASE})" + +#TSORT="tc" ; NEWER="cnewer" +TSORT="t" ; NEWER="newer" + +# +# CDATE: how we use it for naming of the archives +# DDATE: how the user should see it in our output (DISPLAY) +# +CDATE="date +%Y%m%d-%H%M" +DDATE="date +%Y-%m-%d-%H:%M:%S" + +# +# unset parallel execution +# +PARALLEL="" + +# +# catch signals +# +trap "rm -f \"${TMP}\"" 1 2 15 + +# +# Functions +# + +# time displaying echo +_techo() +{ + echo "$(${DDATE}): $@" +} + +# exit on error +_exit_err() +{ + _techo "$@" + rm -f "${TMP}" + exit 1 +} + +add_name() +{ + awk "{ print \"[${name}] \" \$0 }" +} + +pcmd() +{ + if [ "$remote_host" ]; then + ssh "$remote_host" "$@" + else + "$@" + fi +} + +# +# Version +# +display_version() +{ + echo "${FULL_VERSION}" + exit 0 +} + +# +# Tell how to use us +# +usage() +{ + echo "${__myname}: [args] " + echo "" + echo " ccollect creates (pseudo) incremental backups" + echo "" + echo " -h, --help: Show this help screen" + echo " -p, --parallel: Parallelise backup processes" + echo " -a, --all: Backup all sources specified in ${CSOURCES}" + echo " -v, --verbose: Be very verbose (uses set -x)" + echo " -V, --version: Print version information" + echo "" + echo " This is version ${VERSION}, released on ${RELEASE}" + echo " (the first version was written on 2005-12-05 by Nico Schottelius)." + echo "" + echo " Retrieve latest ccollect at http://unix.schottelius.org/ccollect/" + exit 0 +} + +# +# Select interval if AUTO +# +# For this to work nicely, you have to choose interval names that sort nicely +# such as int1, int2, int3 or a_daily, b_weekly, c_monthly, etc. +# +auto_interval() +{ + if [ -d "${backup}/intervals" -a -n "$(ls "${backup}/intervals" 2>/dev/null)" ] ; then + intervals_dir="${backup}/intervals" + elif [ -d "${CDEFAULTS}/intervals" -a -n "$(ls "${CDEFAULTS}/intervals" 2>/dev/null)" ] ; then + intervals_dir="${CDEFAULTS}/intervals" + else + _exit_err "No intervals are defined. Skipping." + fi + echo intervals_dir=${intervals_dir} + + trial_interval="$(ls -1r "${intervals_dir}/" | head -n 1)" || \ + _exit_err "Failed to list contents of ${intervals_dir}/." + _techo "Considering interval ${trial_interval}" + most_recent="$(pcmd ls -${TSORT}p1 "${ddir}" | grep "^${trial_interval}.*/$" | head -n 1)" || \ + _exit_err "Failed to list contents of ${ddir}/." + _techo " Most recent ${trial_interval}: '${most_recent}'" + if [ -n "${most_recent}" ]; then + no_intervals="$(ls -1 "${intervals_dir}/" | wc -l)" + n=1 + while [ "${n}" -le "${no_intervals}" ]; do + trial_interval="$(ls -p1 "${intervals_dir}/" | tail -n+${n} | head -n 1)" + _techo "Considering interval '${trial_interval}'" + c_interval="$(cat "${intervals_dir}/${trial_interval}" 2>/dev/null)" + m=$((${n}+1)) + set -- "${ddir}" -maxdepth 1 + while [ "${m}" -le "${no_intervals}" ]; do + interval_m="$(ls -1 "${intervals_dir}/" | tail -n+${m} | head -n 1)" + most_recent="$(pcmd ls -${TSORT}p1 "${ddir}" | grep "^${interval_m}\..*/$" | head -n 1)" + _techo " Most recent ${interval_m}: '${most_recent}'" + if [ -n "${most_recent}" ] ; then + set -- "$@" -$NEWER "${ddir}/${most_recent}" + fi + m=$((${m}+1)) + done + count=$(pcmd find "$@" -iname "${trial_interval}*" | wc -l) + _techo " Found $count more recent backups of ${trial_interval} (limit: ${c_interval})" + if [ "$count" -lt "${c_interval}" ] ; then + break + fi + n=$((${n}+1)) + done + fi + export INTERVAL="${trial_interval}" + D_FILE_INTERVAL="${intervals_dir}/${INTERVAL}" + D_INTERVAL=$(cat "${D_FILE_INTERVAL}" 2>/dev/null) +} + +# +# need at least interval and one source or --all +# +if [ $# -lt 2 ]; then + if [ "$1" = "-V" -o "$1" = "--version" ]; then + display_version + else + usage + fi +fi + +# +# check for configuraton directory +# +[ -d "${CCOLLECT_CONF}" ] || _exit_err "No configuration found in " \ + "\"${CCOLLECT_CONF}\" (is \$CCOLLECT_CONF properly set?)" + +# +# Filter arguments +# +export INTERVAL="$1"; shift +i=1 +no_sources=0 + +# +# Create source "array" +# +while [ "$#" -ge 1 ]; do + eval arg=\"\$1\"; shift + + if [ "${NO_MORE_ARGS}" = 1 ]; then + eval source_${no_sources}=\"${arg}\" + no_sources=$((${no_sources}+1)) + + # make variable available for subscripts + eval export source_${no_sources} + else + case "${arg}" in + -a|--all) + ALL=1 + ;; + -v|--verbose) + VERBOSE=1 + ;; + -p|--parallel) + PARALLEL=1 + ;; + -h|--help) + usage + ;; + --) + NO_MORE_ARGS=1 + ;; + *) + eval source_${no_sources}=\"$arg\" + no_sources=$(($no_sources+1)) + ;; + esac + fi + + i=$(($i+1)) +done + +# also export number of sources +export no_sources + +# +# be really, really, really verbose +# +if [ "${VERBOSE}" = 1 ]; then + set -x +fi + +# +# Look, if we should take ALL sources +# +if [ "${ALL}" = 1 ]; then + # reset everything specified before + no_sources=0 + + # + # get entries from sources + # + cwd=$(pwd -P) + ( cd "${CSOURCES}" && ls > "${TMP}" ); ret=$? + + [ "${ret}" -eq 0 ] || _exit_err "Listing of sources failed. Aborting." + + while read tmp; do + eval source_${no_sources}=\"${tmp}\" + no_sources=$((${no_sources}+1)) + done < "${TMP}" +fi + +# +# Need at least ONE source to backup +# +if [ "${no_sources}" -lt 1 ]; then + usage +else + _techo "${HALF_VERSION}: Beginning backup using interval ${INTERVAL}" +fi + +# +# Look for pre-exec command (general) +# +if [ -x "${CPREEXEC}" ]; then + _techo "Executing ${CPREEXEC} ..." + "${CPREEXEC}"; ret=$? + _techo "Finished ${CPREEXEC} (return code: ${ret})." + + [ "${ret}" -eq 0 ] || _exit_err "${CPREEXEC} failed. Aborting" +fi + +# +# check default configuration +# + +D_FILE_INTERVAL="${CDEFAULTS}/intervals/${INTERVAL}" +D_INTERVAL=$(cat "${D_FILE_INTERVAL}" 2>/dev/null) + + +# +# Let's do the backup +# +i=0 +while [ "${i}" -lt "${no_sources}" ]; do + + # + # Get current source + # + eval name=\"\$source_${i}\" + i=$((${i}+1)) + + export name + + # + # start ourself, if we want parallel execution + # + if [ "${PARALLEL}" ]; then + "$0" "${INTERVAL}" "${name}" & + continue + fi + +# +# Start subshell for easy log editing +# +( + # + # Stderr to stdout, so we can produce nice logs + # + exec 2>&1 + + # + # Configuration + # + backup="${CSOURCES}/${name}" + c_source="${backup}/source" + c_dest="${backup}/destination" + c_pre_exec="${backup}/pre_exec" + c_post_exec="${backup}/post_exec" + for opt in exclude verbose very_verbose rsync_options summary delete_incomplete remote_host ; do + if [ -f "${backup}/$opt" -o -f "${backup}/no_$opt" ]; then + eval c_$opt=\"${backup}/$opt\" + else + eval c_$opt=\"${CDEFAULTS}/$opt\" + fi + done + + # + # Marking backups: If we abort it's not removed => Backup is broken + # + c_marker=".ccollect-marker" + + # + # Times + # + begin_s=$(date +%s) + + # + # unset possible options + # + VERBOSE="" + VVERBOSE="" + + _techo "Beginning to backup" + + # + # Standard configuration checks + # + if [ ! -e "${backup}" ]; then + _exit_err "Source does not exist." + fi + + # + # configuration _must_ be a directory + # + if [ ! -d "${backup}" ]; then + _exit_err "\"${name}\" is not a cconfig-directory. Skipping." + fi + + # + # first execute pre_exec, which may generate destination or other + # parameters + # + if [ -x "${c_pre_exec}" ]; then + _techo "Executing ${c_pre_exec} ..." + "${c_pre_exec}"; ret="$?" + _techo "Finished ${c_pre_exec} (return code ${ret})." + + if [ "${ret}" -ne 0 ]; then + _exit_err "${c_pre_exec} failed. Skipping." + fi + fi + + # + # Destination is a path + # + if [ ! -f "${c_dest}" ]; then + _exit_err "Destination ${c_dest} is not a file. Skipping." + else + ddir=$(cat "${c_dest}"); ret="$?" + if [ "${ret}" -ne 0 ]; then + _exit_err "Destination ${c_dest} is not readable. Skipping." + fi + fi + + # + # interval definition: First try source specific, fallback to default + # + if [ "${INTERVAL}" = "AUTO" ] ; then + auto_interval + _techo "Selected interval: '$INTERVAL'" + fi + c_interval="$(cat "${backup}/intervals/${INTERVAL}" 2>/dev/null)" + + if [ -z "${c_interval}" ]; then + c_interval="${D_INTERVAL}" + + if [ -z "${c_interval}" ]; then + _exit_err "No definition for interval \"${INTERVAL}\" found. Skipping." + fi + fi + + # + # Source checks + # + if [ ! -f "${c_source}" ]; then + _exit_err "Source description \"${c_source}\" is not a file. Skipping." + else + source=$(cat "${c_source}"); ret="$?" + if [ "${ret}" -ne 0 ]; then + _exit_err "Source ${c_source} is not readable. Skipping." + fi + fi + # Verify source is up and accepting connections before deleting any old backups + rsync "$source" >/dev/null || _exit_err "Source ${source} is not readable. Skipping." + + # + # do we backup to a remote host? then set pre-cmd + # + if [ -f "${c_remote_host}" ]; then + # adjust ls and co + remote_host=$(cat "${c_remote_host}"); ret="$?" + if [ "${ret}" -ne 0 ]; then + _exit_err "Remote host file ${c_remote_host} exists, but is not readable. Skipping." + fi + destination="${remote_host}:${ddir}" + else + remote_host="" + destination="${ddir}" + fi + export remote_host + + # + # check for existence / use real name + # + ( pcmd cd "$ddir" ) || _exit_err "Cannot change to ${ddir}. Skipping." + + + # NEW method as of 0.6: + # - insert ccollect default parameters + # - insert options + # - insert user options + + # + # rsync standard options + # + + set -- "$@" "--archive" "--delete" "--numeric-ids" "--relative" \ + "--delete-excluded" "--sparse" + + # + # exclude list + # + if [ -f "${c_exclude}" ]; then + set -- "$@" "--exclude-from=${c_exclude}" + fi + + # + # Output a summary + # + if [ -f "${c_summary}" ]; then + set -- "$@" "--stats" + fi + + # + # Verbosity for rsync + # + if [ -f "${c_very_verbose}" ]; then + set -- "$@" "-vv" + elif [ -f "${c_verbose}" ]; then + set -- "$@" "-v" + fi + + # + # extra options for rsync provided by the user + # + if [ -f "${c_rsync_options}" ]; then + while read line; do + set -- "$@" "$line" + done < "${c_rsync_options}" + fi + + # + # Check for incomplete backups + # + pcmd ls -1 "$ddir/${INTERVAL}"*".${c_marker}" 2>/dev/null | while read marker; do + incomplete="$(echo ${marker} | sed "s/\\.${c_marker}\$//")" + _techo "Incomplete backup: ${incomplete}" + if [ -f "${c_delete_incomplete}" ]; then + _techo "Deleting ${incomplete} ..." + pcmd rm $VVERBOSE -rf "${incomplete}" || \ + _exit_err "Removing ${incomplete} failed." + pcmd rm $VVERBOSE -f "${marker}" || \ + _exit_err "Removing ${marker} failed." + fi + done + + # + # check if maximum number of backups is reached, if so remove + # use grep and ls -p so we only look at directories + # + count="$(pcmd ls -p1 "${ddir}" | grep "^${INTERVAL}\..*/\$" | wc -l \ + | sed 's/^ *//g')" || _exit_err "Counting backups failed" + + _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" + + if [ "${count}" -ge "${c_interval}" ]; then + substract=$((${c_interval} - 1)) + remove=$((${count} - ${substract})) + _techo "Removing ${remove} backup(s)..." + + pcmd ls -${TSORT}p1r "$ddir" | grep "^${INTERVAL}\..*/\$" | \ + head -n "${remove}" > "${TMP}" || \ + _exit_err "Listing old backups failed" + + i=0 + while read to_remove; do + eval remove_$i=\"${to_remove}\" + i=$(($i+1)) + done < "${TMP}" + + j=0 + while [ "$j" -lt "$i" ]; do + eval to_remove=\"\$remove_$j\" + _techo "Removing ${to_remove} ..." + pcmd rm ${VVERBOSE} -rf "${ddir}/${to_remove}" || \ + _exit_err "Removing ${to_remove} failed." + j=$(($j+1)) + done + fi + + + # + # Check for backup directory to clone from: Always clone from the latest one! + # + # Depending on your file system, you may want to sort on: + # 1. mtime (modification time) with TSORT=t, or + # 2. ctime (last change time, usually) with TSORT=tc + last_dir="$(pcmd ls -${TSORT}p1 "${ddir}" | grep '/$' | head -n 1)" || \ + _exit_err "Failed to list contents of ${ddir}." + + # + # clone from old backup, if existing + # + if [ "${last_dir}" ]; then + set -- "$@" "--link-dest=${ddir}/${last_dir}" + _techo "Hard linking from ${last_dir}" + fi + + + # set time when we really begin to backup, not when we began to remove above + destination_date=$(${CDATE}) + destination_dir="${ddir}/${INTERVAL}.${destination_date}.$$" + destination_full="${destination}/${INTERVAL}.${destination_date}.$$" + + # give some info + _techo "Beginning to backup, this may take some time..." + + _techo "Creating ${destination_dir} ..." + pcmd mkdir ${VVERBOSE} "${destination_dir}" || \ + _exit_err "Creating ${destination_dir} failed. Skipping." + + # + # added marking in 0.6 (and remove it, if successful later) + # + pcmd touch "${destination_dir}.${c_marker}" + + # + # the rsync part + # + _techo "Transferring files..." + rsync "$@" "${source}" "${destination_full}"; ret=$? + # Correct the modification time: + pcmd touch "${destination_dir}" + + # + # remove marking here + # + if [ "$ret" -ne 12 ] ; then + pcmd rm "${destination_dir}.${c_marker}" || \ + _exit_err "Removing ${destination_dir}/${c_marker} failed." + fi + + _techo "Finished backup (rsync return code: $ret)." + if [ "${ret}" -ne 0 ]; then + _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." + fi + + # + # post_exec + # + if [ -x "${c_post_exec}" ]; then + _techo "Executing ${c_post_exec} ..." + "${c_post_exec}"; ret=$? + _techo "Finished ${c_post_exec}." + + if [ ${ret} -ne 0 ]; then + _exit_err "${c_post_exec} failed." + fi + fi + + # Calculation + end_s=$(date +%s) + + full_seconds=$((${end_s} - ${begin_s})) + hours=$((${full_seconds} / 3600)) + seconds=$((${full_seconds} - (${hours} * 3600))) + minutes=$((${seconds} / 60)) + seconds=$((${seconds} - (${minutes} * 60))) + + _techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" + +) | add_name +done + +# +# Be a good parent and wait for our children, if they are running wild parallel +# +if [ "${PARALLEL}" ]; then + _techo "Waiting for children to complete..." + wait +fi + +# +# Look for post-exec command (general) +# +if [ -x "${CPOSTEXEC}" ]; then + _techo "Executing ${CPOSTEXEC} ..." + "${CPOSTEXEC}"; ret=$? + _techo "Finished ${CPOSTEXEC} (return code: ${ret})." + + if [ ${ret} -ne 0 ]; then + _techo "${CPOSTEXEC} failed." + fi +fi + +rm -f "${TMP}" +_techo "Finished ${WE}" + +# vim: set shiftwidth=3 tabstop=3 expandtab : diff --git a/contrib/jlawless-2009-06-03/g.patch b/contrib/jlawless-2009-06-03/g.patch new file mode 100644 index 0000000..0c9a73e --- /dev/null +++ b/contrib/jlawless-2009-06-03/g.patch @@ -0,0 +1,74 @@ +# I found that ccollect was not deleting incomplete backups despite the +# delete_incomplete option being specified. I traced the problem to: +# +# < pcmd rm $VVERBOSE -rf "${ddir}/${realincomplete}" || \ +# +# which, at least on all the systems I tested, should read: +# +# > pcmd rm $VVERBOSE -rf "${realincomplete}" || \ +# +# Also, the marker file is not deleted. I didn't see any reason to keep +# those files around (what do you think?), so I deleted them also: +# +# > pcmd rm $VVERBOSE -rf "${ddir}/${realincomplete}" || \ +# > _exit_err "Removing ${realincomplete} failed." +# +# As long as I was messing with the delete incomplete code and therefore need +# to test it, I took the liberty of simplifying it. The v0.7.1 code uses +# multiple loops with multiple loop counters and creates many variables. I +# simplified that to a single loop: +# +# > pcmd ls -1 "$ddir/${INTERVAL}"*".${c_marker}" 2>/dev/null | while read marker; do +# > incomplete="$(echo ${marker} | sed "s/\\.${c_marker}\$//")" +# > _techo "Incomplete backup: ${incomplete}" +# > if [ "${DELETE_INCOMPLETE}" = "yes" ]; then +# > _techo "Deleting ${incomplete} ..." +# > pcmd rm $VVERBOSE -rf "${incomplete}" || \ +# > _exit_err "Removing ${incomplete} failed." +# > pcmd rm $VVERBOSE -f "${marker}" || \ +# > _exit_err "Removing ${marker} failed." +# > fi +# > done +# +# The final code (a) fixes the delete bug, (b) also deletes the marker, and +# (c) is eight lines shorter than the original. +# +--- ccollect-f.sh 2009-05-12 12:49:28.000000000 -0700 ++++ ccollect-g.sh 2009-06-03 14:32:03.000000000 -0700 +@@ -516,28 +516,20 @@ + fi + + # + # Check for incomplete backups + # +- pcmd ls -1 "$ddir/${INTERVAL}"*".${c_marker}" > "${TMP}" 2>/dev/null +- +- i=0 +- while read incomplete; do +- eval incomplete_$i=\"$(echo ${incomplete} | sed "s/\\.${c_marker}\$//")\" +- i=$(($i+1)) +- done < "${TMP}" +- +- j=0 +- while [ "$j" -lt "$i" ]; do +- eval realincomplete=\"\$incomplete_$j\" +- _techo "Incomplete backup: ${realincomplete}" ++ pcmd ls -1 "$ddir/${INTERVAL}"*".${c_marker}" 2>/dev/null | while read marker; do ++ incomplete="$(echo ${marker} | sed "s/\\.${c_marker}\$//")" ++ _techo "Incomplete backup: ${incomplete}" + if [ "${DELETE_INCOMPLETE}" = "yes" ]; then +- _techo "Deleting ${realincomplete} ..." +- pcmd rm $VVERBOSE -rf "${ddir}/${realincomplete}" || \ +- _exit_err "Removing ${realincomplete} failed." ++ _techo "Deleting ${incomplete} ..." ++ pcmd rm $VVERBOSE -rf "${incomplete}" || \ ++ _exit_err "Removing ${incomplete} failed." ++ pcmd rm $VVERBOSE -f "${marker}" || \ ++ _exit_err "Removing ${marker} failed." + fi +- j=$(($j+1)) + done + + # + # check if maximum number of backups is reached, if so remove + # use grep and ls -p so we only look at directories diff --git a/contrib/jlawless-2009-06-03/h.patch b/contrib/jlawless-2009-06-03/h.patch new file mode 100644 index 0000000..b850b73 --- /dev/null +++ b/contrib/jlawless-2009-06-03/h.patch @@ -0,0 +1,18 @@ +# A line in my f.patch was missing needed quotation marks. +# This fixes that. +# +--- ccollect-g.sh 2009-06-03 14:32:03.000000000 -0700 ++++ ccollect-h.sh 2009-06-03 14:32:19.000000000 -0700 +@@ -412,11 +412,11 @@ + fi + + # + # interval definition: First try source specific, fallback to default + # +- if [ ${INTERVAL} = "AUTO" ] ; then ++ if [ "${INTERVAL}" = "AUTO" ] ; then + auto_interval + _techo "Selected interval: '$INTERVAL'" + fi + c_interval="$(cat "${backup}/intervals/${INTERVAL}" 2>/dev/null)" + diff --git a/contrib/jlawless-2009-06-03/i.patch b/contrib/jlawless-2009-06-03/i.patch new file mode 100644 index 0000000..e8edbaf --- /dev/null +++ b/contrib/jlawless-2009-06-03/i.patch @@ -0,0 +1,134 @@ +# I have many sources that use the same options so I put those +# options in the defaults directory. I found that ccollect was +# ignoring most of them. I thought that this was a bug so I wrote +# some code to correct this: +# +# > for opt in exclude verbose very_verbose rsync_options summary delete_incomplete remote_host ; do +# > if [ -f "${backup}/$opt" -o -f "${backup}/no_$opt" ]; then +# > eval c_$opt=\"${backup}/$opt\" +# > else +# > eval c_$opt=\"${CDEFAULTS}/$opt\" +# > fi +# > done +# +# This also adds a new feature: if some option, say verbose, is +# specified in the defaults directory, it can be turned off for +# particular sources by specifying no_verbose as a source option. +# +# A side effect of this approach is that it forces script variable +# names to be consistent with option file names. Thus, there are +# several changes such as: +# +# < if [ -f "${c_rsync_extra}" ]; then +# > if [ -f "${c_rsync_options}" ]; then +# +# and +# +# < if [ -f "${c_vverbose}" ]; then +# > if [ -f "${c_very_verbose}" ]; then +# +# After correcting the bug and adding the "no_" feature, the code is +# 12 lines shorter. +# +--- ccollect-h.sh 2009-06-01 15:59:11.000000000 -0700 ++++ ccollect-i.sh 2009-06-03 14:27:58.000000000 -0700 +@@ -336,20 +336,19 @@ + # Configuration + # + backup="${CSOURCES}/${name}" + c_source="${backup}/source" + c_dest="${backup}/destination" +- c_exclude="${backup}/exclude" +- c_verbose="${backup}/verbose" +- c_vverbose="${backup}/very_verbose" +- c_rsync_extra="${backup}/rsync_options" +- c_summary="${backup}/summary" + c_pre_exec="${backup}/pre_exec" + c_post_exec="${backup}/post_exec" +- f_incomplete="delete_incomplete" +- c_incomplete="${backup}/${f_incomplete}" +- c_remote_host="${backup}/remote_host" ++ for opt in exclude verbose very_verbose rsync_options summary delete_incomplete remote_host ; do ++ if [ -f "${backup}/$opt" -o -f "${backup}/no_$opt" ]; then ++ eval c_$opt=\"${backup}/$opt\" ++ else ++ eval c_$opt=\"${CDEFAULTS}/$opt\" ++ fi ++ done + + # + # Marking backups: If we abort it's not removed => Backup is broken + # + c_marker=".ccollect-marker" +@@ -360,16 +359,12 @@ + begin_s=$(date +%s) + + # + # unset possible options + # +- EXCLUDE="" +- RSYNC_EXTRA="" +- SUMMARY="" + VERBOSE="" + VVERBOSE="" +- DELETE_INCOMPLETE="" + + _techo "Beginning to backup" + + # + # Standard configuration checks +@@ -462,17 +457,10 @@ + # check for existence / use real name + # + ( pcmd cd "$ddir" ) || _exit_err "Cannot change to ${ddir}. Skipping." + + +- # +- # Check whether to delete incomplete backups +- # +- if [ -f "${c_incomplete}" -o -f "${CDEFAULTS}/${f_incomplete}" ]; then +- DELETE_INCOMPLETE="yes" +- fi +- + # NEW method as of 0.6: + # - insert ccollect default parameters + # - insert options + # - insert user options + +@@ -498,32 +486,32 @@ + fi + + # + # Verbosity for rsync + # +- if [ -f "${c_vverbose}" ]; then ++ if [ -f "${c_very_verbose}" ]; then + set -- "$@" "-vv" + elif [ -f "${c_verbose}" ]; then + set -- "$@" "-v" + fi + + # + # extra options for rsync provided by the user + # +- if [ -f "${c_rsync_extra}" ]; then ++ if [ -f "${c_rsync_options}" ]; then + while read line; do + set -- "$@" "$line" +- done < "${c_rsync_extra}" ++ done < "${c_rsync_options}" + fi + + # + # Check for incomplete backups + # + pcmd ls -1 "$ddir/${INTERVAL}"*".${c_marker}" 2>/dev/null | while read marker; do + incomplete="$(echo ${marker} | sed "s/\\.${c_marker}\$//")" + _techo "Incomplete backup: ${incomplete}" +- if [ "${DELETE_INCOMPLETE}" = "yes" ]; then ++ if [ -f "${c_delete_incomplete}" ]; then + _techo "Deleting ${incomplete} ..." + pcmd rm $VVERBOSE -rf "${incomplete}" || \ + _exit_err "Removing ${incomplete} failed." + pcmd rm $VVERBOSE -f "${marker}" || \ + _exit_err "Removing ${marker} failed." diff --git a/contrib/jlawless-2009-06-03/old/README_a-f.txt b/contrib/jlawless-2009-06-03/old/README_a-f.txt new file mode 100644 index 0000000..e3bfe57 --- /dev/null +++ b/contrib/jlawless-2009-06-03/old/README_a-f.txt @@ -0,0 +1,296 @@ +Dear Nico Schottelius, + + I have started using ccollect and I very much like its design: +it is elegant and effective. + + In the process of getting ccollect setup and running, I made +five changes, including one major new feature, that I hope you will +find useful. + + First, I added the following before any old backup gets deleted: + +> # Verify source is up and accepting connections before deleting any old backups +> rsync "$source" >/dev/null || _exit_err "Source ${source} is not readable. Skipping." + +I think that this quick test is a much better than, say, pinging +the source in a pre-exec script: this tests not only that the +source is up and connected to the net, it also verifies (1) that +ssh is up and accepting our key (if we are using ssh), and (2) that +the source directory is mounted (if it needs to be mounted) and +readable. + + Second, I found ccollect's use of ctime problematic. After +copying an old backup over to my ccollect destination, I adjusted +mtime and atime where needed using touch, e.g.: + +touch -d"28 Apr 2009 3:00" destination/daily.01 + +However, as far as I know, there is no way to correct a bad ctime. +I ran into this issue repeatedly while adjusting my backup +configuration. (For example, "cp -a" preserves mtime but not +ctime. Even worse, "cp -al old new" also changes ctime on old.) + + Another potential problem with ctime is that it is file-system +dependent: I have read that Windows sets ctime to create-time not +last change-time. + + However, It is simple to give a new backup the correct mtime. +After the rsync step, I added the command: + +553a616,617 +> # Correct the modification time: +> pcmd touch "${destination_dir}" + +Even if ccollect continues to use ctime for sorting, I see no +reason not to have the backup directory have the correct mtime. + + To allow the rest of the code to use either ctime or mtime, I +added definitions: + +44a45,47 +> #TSORT="tc" ; NEWER="cnewer" +> TSORT="t" ; NEWER="newer" + +(It would be better if this choice was user-configurable because +those with existing backup directories should continue to use ctime +until the mtimes of their directories are correct. The correction +would happen passively over time as new backups created using the +above touch command and the old ones are deleted.) + +With these definitions, the proper link-dest directory can then be +found using this minor change (and comment update): + +516,519c579,582 +< # Use ls -1c instead of -1t, because last modification maybe the same on all +< # and metadate update (-c) is updated by rsync locally. +< # +< last_dir="$(pcmd ls -tcp1 "${ddir}" | grep '/$' | head -n 1)" || \ +--- +> # Depending on your file system, you may want to sort on: +> # 1. mtime (modification time) with TSORT=t, or +> # 2. ctime (last change time, usually) with TSORT=tc +> last_dir="$(pcmd ls -${TSORT}p1 "${ddir}" | grep '/$' | head -n 1)" || \ + + Thirdly, after I copied my old backups over to my ccollect +destination directory, I found that ccollect would delete a +recent backup not an old backup! My problem was that, unknown to +me, the algorithm to find the oldest backup (for deletion) was +inconsistent with that used to find the newest (for link-dest). I +suggest that these two should be consistent. Because time-sorting +seemed more consistent with the ccollect documentation, I suggest: + +492,493c555,556 +< pcmd ls -p1 "$ddir" | grep "^${INTERVAL}\..*/\$" | \ +< sort -n | head -n "${remove}" > "${TMP}" || \ +--- +> pcmd ls -${TSORT}p1r "$ddir" | grep "^${INTERVAL}\..*/\$" | \ +> head -n "${remove}" > "${TMP}" || \ + + Fourthly, in my experience, rsync error code 12 means complete +failure, usually because the source refuses the ssh connection. +So, I left the marker in that case: + +558,559c622,625 +< pcmd rm "${destination_dir}.${c_marker}" || \ +< _exit_err "Removing ${destination_dir}/${c_marker} failed." +--- +> if [ "$ret" -ne 12 ] ; then +> pcmd rm "${destination_dir}.${c_marker}" || \ +> _exit_err "Removing ${destination_dir}/${c_marker} failed." +> fi + +(A better solution might allow a user-configurable list of error +codes that are treated the same as a fail.) + + Fifth, because I was frustrated by the problems of having a +cron-job decide which interval to backup, I added a major new +feature: the modified ccollect can now automatically select an +interval to use for backup. + + Cron-job controlled backup works well if all machines are up and +running all the time and nothing ever goes wrong. I have, however, +some machines that are occasionally turned off, or that are mobile +and only sometimes connected to local net. For these machines, the +use of cron-jobs to select intervals can be a disaster. + + There are several ways one could automatically choose an +appropriate interval. The method I show below has the advantage +that it works with existing ccollect configuration files. The only +requirement is that interval names be chosen to sort nicely (under +ls). For example, I currently use: + +$ ls -1 intervals +a_daily +b_weekly +c_monthly +d_quarterly +e_yearly +$ cat intervals/* +6 +3 +2 +3 +30 + +A simpler example would be: + +$ ls -1 intervals +int1 +int2 +int3 +$ cat intervals/* +2 +3 +4 + +The algorithm works as follows: + + If no backup exists for the least frequent interval (int3 in the + simpler example), then use that interval. Otherwise, use the + most frequent interval (int1) unless there are "$(cat + intervals/int1)" int1 backups more recent than any int2 or int3 + backup, in which case select int2 unless there are "$(cat + intervals/int2)" int2 backups more recent than any int3 backups + in which case choose int3. + +This algorithm works well cycling through all the backups for my +always connected machines as well as for my usually connected +machines, and rarely connected machines. (For a rarely connected +machine, interval names like "b_weekly" lose their English meaning +but it still does a reasonable job of rotating through the +intervals.) + + In addition to being more robust, the automatic interval +selection means that crontab is greatly simplified: only one line +is needed. I use: + +30 3 * * * ccollect.sh AUTO host1 host2 host3 | tee -a /var/log/ccollect-full.log | ccollect_analyse_logs.sh iwe + + Some users might prefer a calendar-driven algorithm such as: do +a yearly backup the first time a machine is connected during a new +year; do a monthly backup the first that a machine is connected +during a month; etc. This, however, would require a change to the +ccollect configuration files. So, I didn't pursue the idea any +further. + + The code checks to see if the user specified the interval as +AUTO. If so, the auto_interval function is called to select the +interval: + +347a417,420 +> if [ ${INTERVAL} = "AUTO" ] ; then +> auto_interval +> _techo "Selected interval: '$INTERVAL'" +> fi + +The code for auto_interval is as follows (note that it allows 'more +recent' to be defined by either ctime or mtime as per the TSORT +variable): + +125a129,182 +> # Select interval if AUTO +> # +> # For this to work nicely, you have to choose interval names that sort nicely +> # such as int1, int2, int3 or a_daily, b_weekly, c_monthly, etc. +> # +> auto_interval() +> { +> if [ -d "${backup}/intervals" -a -n "$(ls "${backup}/intervals" 2>/dev/null)" ] ; then +> intervals_dir="${backup}/intervals" +> elif [ -d "${CDEFAULTS}/intervals" -a -n "$(ls "${CDEFAULTS}/intervals" 2>/dev/null)" ] ; then +> intervals_dir="${CDEFAULTS}/intervals" +> else +> _exit_err "No intervals are defined. Skipping." +> fi +> echo intervals_dir=${intervals_dir} +> +> trial_interval="$(ls -1r "${intervals_dir}/" | head -n 1)" || \ +> _exit_err "Failed to list contents of ${intervals_dir}/." +> _techo "Considering interval ${trial_interval}" +> most_recent="$(pcmd ls -${TSORT}p1 "${ddir}" | grep "^${trial_interval}.*/$" | head -n 1)" || \ +> _exit_err "Failed to list contents of ${ddir}/." +> _techo " Most recent ${trial_interval}: '${most_recent}'" +> if [ -n "${most_recent}" ]; then +> no_intervals="$(ls -1 "${intervals_dir}/" | wc -l)" +> n=1 +> while [ "${n}" -le "${no_intervals}" ]; do +> trial_interval="$(ls -p1 "${intervals_dir}/" | tail -n+${n} | head -n 1)" +> _techo "Considering interval '${trial_interval}'" +> c_interval="$(cat "${intervals_dir}/${trial_interval}" 2>/dev/null)" +> m=$((${n}+1)) +> set -- "${ddir}" -maxdepth 1 +> while [ "${m}" -le "${no_intervals}" ]; do +> interval_m="$(ls -1 "${intervals_dir}/" | tail -n+${m} | head -n 1)" +> most_recent="$(pcmd ls -${TSORT}p1 "${ddir}" | grep "^${interval_m}\..*/$" | head -n 1)" +> _techo " Most recent ${interval_m}: '${most_recent}'" +> if [ -n "${most_recent}" ] ; then +> set -- "$@" -$NEWER "${ddir}/${most_recent}" +> fi +> m=$((${m}+1)) +> done +> count=$(pcmd find "$@" -iname "${trial_interval}*" | wc -l) +> _techo " Found $count more recent backups of ${trial_interval} (limit: ${c_interval})" +> if [ "$count" -lt "${c_interval}" ] ; then +> break +> fi +> n=$((${n}+1)) +> done +> fi +> export INTERVAL="${trial_interval}" +> D_FILE_INTERVAL="${intervals_dir}/${INTERVAL}" +> D_INTERVAL=$(cat "${D_FILE_INTERVAL}" 2>/dev/null) +> } +> +> # + +While I consider the auto_interval code to be developmental, I have +been using it for my nightly backups and it works for me. + + One last change: For auto_interval to work, it needs "ddir" to +be defined first. Consequently, I had to move the following code +so it gets run before auto_interval is called: + +369,380c442,443 +< +< # +< # Destination is a path +< # +< if [ ! -f "${c_dest}" ]; then +< _exit_err "Destination ${c_dest} is not a file. Skipping." +< else +< ddir=$(cat "${c_dest}"); ret="$?" +< if [ "${ret}" -ne 0 ]; then +< _exit_err "Destination ${c_dest} is not readable. Skipping." +< fi +< fi +345a403,414 +> # Destination is a path +> # +> if [ ! -f "${c_dest}" ]; then +> _exit_err "Destination ${c_dest} is not a file. Skipping." +> else +> ddir=$(cat "${c_dest}"); ret="$?" +> if [ "${ret}" -ne 0 ]; then +> _exit_err "Destination ${c_dest} is not readable. Skipping." +> fi +> fi +> +> # + + I have some other ideas but this is all I have implemented at +the moment. Files are attached. + + Thanks again for developing ccollect and let me know what you +think. + +Regards, + +John + +-- + John L. Lawless, Ph.D. + Redwood Scientific, Inc. + 1005 Terra Nova Blvd + Pacifica, CA 94044-4300 + 1-650-738-8083 + diff --git a/contrib/jlawless-2009-06-03/old/a.patch b/contrib/jlawless-2009-06-03/old/a.patch new file mode 100644 index 0000000..bf4b662 --- /dev/null +++ b/contrib/jlawless-2009-06-03/old/a.patch @@ -0,0 +1,15 @@ +--- ccollect-0.7.1.sh 2009-02-02 03:39:42.000000000 -0800 ++++ ccollect-0.7.1-a.sh 2009-05-24 21:30:38.000000000 -0700 +@@ -364,10 +364,12 @@ + source=$(cat "${c_source}"); ret="$?" + if [ "${ret}" -ne 0 ]; then + _exit_err "Source ${c_source} is not readable. Skipping." + fi + fi ++ # Verify source is up and accepting connections before deleting any old backups ++ rsync "$source" >/dev/null || _exit_err "Source ${source} is not readable. Skipping." + + # + # Destination is a path + # + if [ ! -f "${c_dest}" ]; then diff --git a/contrib/jlawless-2009-06-03/old/b.patch b/contrib/jlawless-2009-06-03/old/b.patch new file mode 100644 index 0000000..c0266d2 --- /dev/null +++ b/contrib/jlawless-2009-06-03/old/b.patch @@ -0,0 +1,15 @@ +--- ccollect-0.7.1-a.sh 2009-05-24 21:30:38.000000000 -0700 ++++ ccollect-0.7.1-b.sh 2009-05-24 21:32:00.000000000 -0700 +@@ -551,10 +551,12 @@ + # the rsync part + # + + _techo "Transferring files..." + rsync "$@" "${source}" "${destination_full}"; ret=$? ++ # Correct the modification time: ++ pcmd touch "${destination_dir}" + + # + # remove marking here + # + pcmd rm "${destination_dir}.${c_marker}" || \ diff --git a/contrib/jlawless-2009-06-03/old/c.patch b/contrib/jlawless-2009-06-03/old/c.patch new file mode 100644 index 0000000..7b5f9a8 --- /dev/null +++ b/contrib/jlawless-2009-06-03/old/c.patch @@ -0,0 +1,35 @@ +--- ccollect-0.7.1-b.sh 2009-05-24 21:32:00.000000000 -0700 ++++ ccollect-0.7.1-c.sh 2009-05-24 21:39:43.000000000 -0700 +@@ -40,10 +40,13 @@ + VERSION=0.7.1 + RELEASE="2009-02-02" + HALF_VERSION="ccollect ${VERSION}" + FULL_VERSION="ccollect ${VERSION} (${RELEASE})" + ++#TSORT="tc" ; NEWER="cnewer" ++TSORT="t" ; NEWER="newer" ++ + # + # CDATE: how we use it for naming of the archives + # DDATE: how the user should see it in our output (DISPLAY) + # + CDATE="date +%Y%m%d-%H%M" +@@ -513,14 +516,14 @@ + + + # + # Check for backup directory to clone from: Always clone from the latest one! + # +- # Use ls -1c instead of -1t, because last modification maybe the same on all +- # and metadate update (-c) is updated by rsync locally. +- # +- last_dir="$(pcmd ls -tcp1 "${ddir}" | grep '/$' | head -n 1)" || \ ++ # Depending on your file system, you may want to sort on: ++ # 1. mtime (modification time) with TSORT=t, or ++ # 2. ctime (last change time, usually) with TSORT=tc ++ last_dir="$(pcmd ls -${TSORT}p1 "${ddir}" | grep '/$' | head -n 1)" || \ + _exit_err "Failed to list contents of ${ddir}." + + # + # clone from old backup, if existing + # diff --git a/contrib/jlawless-2009-06-03/old/ccollect-0.7.1.sh b/contrib/jlawless-2009-06-03/old/ccollect-0.7.1.sh new file mode 100755 index 0000000..e14dcfc --- /dev/null +++ b/contrib/jlawless-2009-06-03/old/ccollect-0.7.1.sh @@ -0,0 +1,615 @@ +#!/bin/sh +# +# 2005-2009 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# Initially written for SyGroup (www.sygroup.ch) +# Date: Mon Nov 14 11:45:11 CET 2005 + +# +# Standard variables (stolen from cconf) +# +__pwd="$(pwd -P)" +__mydir="${0%/*}"; __abs_mydir="$(cd "$__mydir" && pwd -P)" +__myname=${0##*/}; __abs_myname="$__abs_mydir/$__myname" + +# +# where to find our configuration and temporary file +# +CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} +CSOURCES=${CCOLLECT_CONF}/sources +CDEFAULTS=${CCOLLECT_CONF}/defaults +CPREEXEC="${CDEFAULTS}/pre_exec" +CPOSTEXEC="${CDEFAULTS}/post_exec" + +TMP=$(mktemp "/tmp/${__myname}.XXXXXX") +VERSION=0.7.1 +RELEASE="2009-02-02" +HALF_VERSION="ccollect ${VERSION}" +FULL_VERSION="ccollect ${VERSION} (${RELEASE})" + +# +# CDATE: how we use it for naming of the archives +# DDATE: how the user should see it in our output (DISPLAY) +# +CDATE="date +%Y%m%d-%H%M" +DDATE="date +%Y-%m-%d-%H:%M:%S" + +# +# unset parallel execution +# +PARALLEL="" + +# +# catch signals +# +trap "rm -f \"${TMP}\"" 1 2 15 + +# +# Functions +# + +# time displaying echo +_techo() +{ + echo "$(${DDATE}): $@" +} + +# exit on error +_exit_err() +{ + _techo "$@" + rm -f "${TMP}" + exit 1 +} + +add_name() +{ + awk "{ print \"[${name}] \" \$0 }" +} + +pcmd() +{ + if [ "$remote_host" ]; then + ssh "$remote_host" "$@" + else + "$@" + fi +} + +# +# Version +# +display_version() +{ + echo "${FULL_VERSION}" + exit 0 +} + +# +# Tell how to use us +# +usage() +{ + echo "${__myname}: [args] " + echo "" + echo " ccollect creates (pseudo) incremental backups" + echo "" + echo " -h, --help: Show this help screen" + echo " -p, --parallel: Parallelise backup processes" + echo " -a, --all: Backup all sources specified in ${CSOURCES}" + echo " -v, --verbose: Be very verbose (uses set -x)" + echo " -V, --version: Print version information" + echo "" + echo " This is version ${VERSION}, released on ${RELEASE}" + echo " (the first version was written on 2005-12-05 by Nico Schottelius)." + echo "" + echo " Retrieve latest ccollect at http://unix.schottelius.org/ccollect/" + exit 0 +} + +# +# need at least interval and one source or --all +# +if [ $# -lt 2 ]; then + if [ "$1" = "-V" -o "$1" = "--version" ]; then + display_version + else + usage + fi +fi + +# +# check for configuraton directory +# +[ -d "${CCOLLECT_CONF}" ] || _exit_err "No configuration found in " \ + "\"${CCOLLECT_CONF}\" (is \$CCOLLECT_CONF properly set?)" + +# +# Filter arguments +# +export INTERVAL="$1"; shift +i=1 +no_sources=0 + +# +# Create source "array" +# +while [ "$#" -ge 1 ]; do + eval arg=\"\$1\"; shift + + if [ "${NO_MORE_ARGS}" = 1 ]; then + eval source_${no_sources}=\"${arg}\" + no_sources=$((${no_sources}+1)) + + # make variable available for subscripts + eval export source_${no_sources} + else + case "${arg}" in + -a|--all) + ALL=1 + ;; + -v|--verbose) + VERBOSE=1 + ;; + -p|--parallel) + PARALLEL=1 + ;; + -h|--help) + usage + ;; + --) + NO_MORE_ARGS=1 + ;; + *) + eval source_${no_sources}=\"$arg\" + no_sources=$(($no_sources+1)) + ;; + esac + fi + + i=$(($i+1)) +done + +# also export number of sources +export no_sources + +# +# be really, really, really verbose +# +if [ "${VERBOSE}" = 1 ]; then + set -x +fi + +# +# Look, if we should take ALL sources +# +if [ "${ALL}" = 1 ]; then + # reset everything specified before + no_sources=0 + + # + # get entries from sources + # + cwd=$(pwd -P) + ( cd "${CSOURCES}" && ls > "${TMP}" ); ret=$? + + [ "${ret}" -eq 0 ] || _exit_err "Listing of sources failed. Aborting." + + while read tmp; do + eval source_${no_sources}=\"${tmp}\" + no_sources=$((${no_sources}+1)) + done < "${TMP}" +fi + +# +# Need at least ONE source to backup +# +if [ "${no_sources}" -lt 1 ]; then + usage +else + _techo "${HALF_VERSION}: Beginning backup using interval ${INTERVAL}" +fi + +# +# Look for pre-exec command (general) +# +if [ -x "${CPREEXEC}" ]; then + _techo "Executing ${CPREEXEC} ..." + "${CPREEXEC}"; ret=$? + _techo "Finished ${CPREEXEC} (return code: ${ret})." + + [ "${ret}" -eq 0 ] || _exit_err "${CPREEXEC} failed. Aborting" +fi + +# +# check default configuration +# + +D_FILE_INTERVAL="${CDEFAULTS}/intervals/${INTERVAL}" +D_INTERVAL=$(cat "${D_FILE_INTERVAL}" 2>/dev/null) + + +# +# Let's do the backup +# +i=0 +while [ "${i}" -lt "${no_sources}" ]; do + + # + # Get current source + # + eval name=\"\$source_${i}\" + i=$((${i}+1)) + + export name + + # + # start ourself, if we want parallel execution + # + if [ "${PARALLEL}" ]; then + "$0" "${INTERVAL}" "${name}" & + continue + fi + +# +# Start subshell for easy log editing +# +( + # + # Stderr to stdout, so we can produce nice logs + # + exec 2>&1 + + # + # Configuration + # + backup="${CSOURCES}/${name}" + c_source="${backup}/source" + c_dest="${backup}/destination" + c_exclude="${backup}/exclude" + c_verbose="${backup}/verbose" + c_vverbose="${backup}/very_verbose" + c_rsync_extra="${backup}/rsync_options" + c_summary="${backup}/summary" + c_pre_exec="${backup}/pre_exec" + c_post_exec="${backup}/post_exec" + f_incomplete="delete_incomplete" + c_incomplete="${backup}/${f_incomplete}" + c_remote_host="${backup}/remote_host" + + # + # Marking backups: If we abort it's not removed => Backup is broken + # + c_marker=".ccollect-marker" + + # + # Times + # + begin_s=$(date +%s) + + # + # unset possible options + # + EXCLUDE="" + RSYNC_EXTRA="" + SUMMARY="" + VERBOSE="" + VVERBOSE="" + DELETE_INCOMPLETE="" + + _techo "Beginning to backup" + + # + # Standard configuration checks + # + if [ ! -e "${backup}" ]; then + _exit_err "Source does not exist." + fi + + # + # configuration _must_ be a directory + # + if [ ! -d "${backup}" ]; then + _exit_err "\"${name}\" is not a cconfig-directory. Skipping." + fi + + # + # first execute pre_exec, which may generate destination or other + # parameters + # + if [ -x "${c_pre_exec}" ]; then + _techo "Executing ${c_pre_exec} ..." + "${c_pre_exec}"; ret="$?" + _techo "Finished ${c_pre_exec} (return code ${ret})." + + if [ "${ret}" -ne 0 ]; then + _exit_err "${c_pre_exec} failed. Skipping." + fi + fi + + # + # interval definition: First try source specific, fallback to default + # + c_interval="$(cat "${backup}/intervals/${INTERVAL}" 2>/dev/null)" + + if [ -z "${c_interval}" ]; then + c_interval="${D_INTERVAL}" + + if [ -z "${c_interval}" ]; then + _exit_err "No definition for interval \"${INTERVAL}\" found. Skipping." + fi + fi + + # + # Source checks + # + if [ ! -f "${c_source}" ]; then + _exit_err "Source description \"${c_source}\" is not a file. Skipping." + else + source=$(cat "${c_source}"); ret="$?" + if [ "${ret}" -ne 0 ]; then + _exit_err "Source ${c_source} is not readable. Skipping." + fi + fi + + # + # Destination is a path + # + if [ ! -f "${c_dest}" ]; then + _exit_err "Destination ${c_dest} is not a file. Skipping." + else + ddir=$(cat "${c_dest}"); ret="$?" + if [ "${ret}" -ne 0 ]; then + _exit_err "Destination ${c_dest} is not readable. Skipping." + fi + fi + + # + # do we backup to a remote host? then set pre-cmd + # + if [ -f "${c_remote_host}" ]; then + # adjust ls and co + remote_host=$(cat "${c_remote_host}"); ret="$?" + if [ "${ret}" -ne 0 ]; then + _exit_err "Remote host file ${c_remote_host} exists, but is not readable. Skipping." + fi + destination="${remote_host}:${ddir}" + else + remote_host="" + destination="${ddir}" + fi + export remote_host + + # + # check for existence / use real name + # + ( pcmd cd "$ddir" ) || _exit_err "Cannot change to ${ddir}. Skipping." + + + # + # Check whether to delete incomplete backups + # + if [ -f "${c_incomplete}" -o -f "${CDEFAULTS}/${f_incomplete}" ]; then + DELETE_INCOMPLETE="yes" + fi + + # NEW method as of 0.6: + # - insert ccollect default parameters + # - insert options + # - insert user options + + # + # rsync standard options + # + + set -- "$@" "--archive" "--delete" "--numeric-ids" "--relative" \ + "--delete-excluded" "--sparse" + + # + # exclude list + # + if [ -f "${c_exclude}" ]; then + set -- "$@" "--exclude-from=${c_exclude}" + fi + + # + # Output a summary + # + if [ -f "${c_summary}" ]; then + set -- "$@" "--stats" + fi + + # + # Verbosity for rsync + # + if [ -f "${c_vverbose}" ]; then + set -- "$@" "-vv" + elif [ -f "${c_verbose}" ]; then + set -- "$@" "-v" + fi + + # + # extra options for rsync provided by the user + # + if [ -f "${c_rsync_extra}" ]; then + while read line; do + set -- "$@" "$line" + done < "${c_rsync_extra}" + fi + + # + # Check for incomplete backups + # + pcmd ls -1 "$ddir/${INTERVAL}"*".${c_marker}" > "${TMP}" 2>/dev/null + + i=0 + while read incomplete; do + eval incomplete_$i=\"$(echo ${incomplete} | sed "s/\\.${c_marker}\$//")\" + i=$(($i+1)) + done < "${TMP}" + + j=0 + while [ "$j" -lt "$i" ]; do + eval realincomplete=\"\$incomplete_$j\" + _techo "Incomplete backup: ${realincomplete}" + if [ "${DELETE_INCOMPLETE}" = "yes" ]; then + _techo "Deleting ${realincomplete} ..." + pcmd rm $VVERBOSE -rf "${ddir}/${realincomplete}" || \ + _exit_err "Removing ${realincomplete} failed." + fi + j=$(($j+1)) + done + + # + # check if maximum number of backups is reached, if so remove + # use grep and ls -p so we only look at directories + # + count="$(pcmd ls -p1 "${ddir}" | grep "^${INTERVAL}\..*/\$" | wc -l \ + | sed 's/^ *//g')" || _exit_err "Counting backups failed" + + _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" + + if [ "${count}" -ge "${c_interval}" ]; then + substract=$((${c_interval} - 1)) + remove=$((${count} - ${substract})) + _techo "Removing ${remove} backup(s)..." + + pcmd ls -p1 "$ddir" | grep "^${INTERVAL}\..*/\$" | \ + sort -n | head -n "${remove}" > "${TMP}" || \ + _exit_err "Listing old backups failed" + + i=0 + while read to_remove; do + eval remove_$i=\"${to_remove}\" + i=$(($i+1)) + done < "${TMP}" + + j=0 + while [ "$j" -lt "$i" ]; do + eval to_remove=\"\$remove_$j\" + _techo "Removing ${to_remove} ..." + pcmd rm ${VVERBOSE} -rf "${ddir}/${to_remove}" || \ + _exit_err "Removing ${to_remove} failed." + j=$(($j+1)) + done + fi + + + # + # Check for backup directory to clone from: Always clone from the latest one! + # + # Use ls -1c instead of -1t, because last modification maybe the same on all + # and metadate update (-c) is updated by rsync locally. + # + last_dir="$(pcmd ls -tcp1 "${ddir}" | grep '/$' | head -n 1)" || \ + _exit_err "Failed to list contents of ${ddir}." + + # + # clone from old backup, if existing + # + if [ "${last_dir}" ]; then + set -- "$@" "--link-dest=${ddir}/${last_dir}" + _techo "Hard linking from ${last_dir}" + fi + + + # set time when we really begin to backup, not when we began to remove above + destination_date=$(${CDATE}) + destination_dir="${ddir}/${INTERVAL}.${destination_date}.$$" + destination_full="${destination}/${INTERVAL}.${destination_date}.$$" + + # give some info + _techo "Beginning to backup, this may take some time..." + + _techo "Creating ${destination_dir} ..." + pcmd mkdir ${VVERBOSE} "${destination_dir}" || \ + _exit_err "Creating ${destination_dir} failed. Skipping." + + # + # added marking in 0.6 (and remove it, if successful later) + # + pcmd touch "${destination_dir}.${c_marker}" + + # + # the rsync part + # + + _techo "Transferring files..." + rsync "$@" "${source}" "${destination_full}"; ret=$? + + # + # remove marking here + # + pcmd rm "${destination_dir}.${c_marker}" || \ + _exit_err "Removing ${destination_dir}/${c_marker} failed." + + _techo "Finished backup (rsync return code: $ret)." + if [ "${ret}" -ne 0 ]; then + _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." + fi + + # + # post_exec + # + if [ -x "${c_post_exec}" ]; then + _techo "Executing ${c_post_exec} ..." + "${c_post_exec}"; ret=$? + _techo "Finished ${c_post_exec}." + + if [ ${ret} -ne 0 ]; then + _exit_err "${c_post_exec} failed." + fi + fi + + # Calculation + end_s=$(date +%s) + + full_seconds=$((${end_s} - ${begin_s})) + hours=$((${full_seconds} / 3600)) + seconds=$((${full_seconds} - (${hours} * 3600))) + minutes=$((${seconds} / 60)) + seconds=$((${seconds} - (${minutes} * 60))) + + _techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" + +) | add_name +done + +# +# Be a good parent and wait for our children, if they are running wild parallel +# +if [ "${PARALLEL}" ]; then + _techo "Waiting for children to complete..." + wait +fi + +# +# Look for post-exec command (general) +# +if [ -x "${CPOSTEXEC}" ]; then + _techo "Executing ${CPOSTEXEC} ..." + "${CPOSTEXEC}"; ret=$? + _techo "Finished ${CPOSTEXEC} (return code: ${ret})." + + if [ ${ret} -ne 0 ]; then + _techo "${CPOSTEXEC} failed." + fi +fi + +rm -f "${TMP}" +_techo "Finished ${WE}" diff --git a/contrib/jlawless-2009-06-03/old/ccollect-f.sh b/contrib/jlawless-2009-06-03/old/ccollect-f.sh new file mode 100755 index 0000000..5c8952e --- /dev/null +++ b/contrib/jlawless-2009-06-03/old/ccollect-f.sh @@ -0,0 +1,683 @@ +#!/bin/sh +# +# 2005-2009 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# Initially written for SyGroup (www.sygroup.ch) +# Date: Mon Nov 14 11:45:11 CET 2005 + +# +# Standard variables (stolen from cconf) +# +__pwd="$(pwd -P)" +__mydir="${0%/*}"; __abs_mydir="$(cd "$__mydir" && pwd -P)" +__myname=${0##*/}; __abs_myname="$__abs_mydir/$__myname" + +# +# where to find our configuration and temporary file +# +CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} +CSOURCES=${CCOLLECT_CONF}/sources +CDEFAULTS=${CCOLLECT_CONF}/defaults +CPREEXEC="${CDEFAULTS}/pre_exec" +CPOSTEXEC="${CDEFAULTS}/post_exec" + +TMP=$(mktemp "/tmp/${__myname}.XXXXXX") +VERSION=0.7.1 +RELEASE="2009-02-02" +HALF_VERSION="ccollect ${VERSION}" +FULL_VERSION="ccollect ${VERSION} (${RELEASE})" + +#TSORT="tc" ; NEWER="cnewer" +TSORT="t" ; NEWER="newer" + +# +# CDATE: how we use it for naming of the archives +# DDATE: how the user should see it in our output (DISPLAY) +# +CDATE="date +%Y%m%d-%H%M" +DDATE="date +%Y-%m-%d-%H:%M:%S" + +# +# unset parallel execution +# +PARALLEL="" + +# +# catch signals +# +trap "rm -f \"${TMP}\"" 1 2 15 + +# +# Functions +# + +# time displaying echo +_techo() +{ + echo "$(${DDATE}): $@" +} + +# exit on error +_exit_err() +{ + _techo "$@" + rm -f "${TMP}" + exit 1 +} + +add_name() +{ + awk "{ print \"[${name}] \" \$0 }" +} + +pcmd() +{ + if [ "$remote_host" ]; then + ssh "$remote_host" "$@" + else + "$@" + fi +} + +# +# Version +# +display_version() +{ + echo "${FULL_VERSION}" + exit 0 +} + +# +# Tell how to use us +# +usage() +{ + echo "${__myname}: [args] " + echo "" + echo " ccollect creates (pseudo) incremental backups" + echo "" + echo " -h, --help: Show this help screen" + echo " -p, --parallel: Parallelise backup processes" + echo " -a, --all: Backup all sources specified in ${CSOURCES}" + echo " -v, --verbose: Be very verbose (uses set -x)" + echo " -V, --version: Print version information" + echo "" + echo " This is version ${VERSION}, released on ${RELEASE}" + echo " (the first version was written on 2005-12-05 by Nico Schottelius)." + echo "" + echo " Retrieve latest ccollect at http://unix.schottelius.org/ccollect/" + exit 0 +} + +# +# Select interval if AUTO +# +# For this to work nicely, you have to choose interval names that sort nicely +# such as int1, int2, int3 or a_daily, b_weekly, c_monthly, etc. +# +auto_interval() +{ + if [ -d "${backup}/intervals" -a -n "$(ls "${backup}/intervals" 2>/dev/null)" ] ; then + intervals_dir="${backup}/intervals" + elif [ -d "${CDEFAULTS}/intervals" -a -n "$(ls "${CDEFAULTS}/intervals" 2>/dev/null)" ] ; then + intervals_dir="${CDEFAULTS}/intervals" + else + _exit_err "No intervals are defined. Skipping." + fi + echo intervals_dir=${intervals_dir} + + trial_interval="$(ls -1r "${intervals_dir}/" | head -n 1)" || \ + _exit_err "Failed to list contents of ${intervals_dir}/." + _techo "Considering interval ${trial_interval}" + most_recent="$(pcmd ls -${TSORT}p1 "${ddir}" | grep "^${trial_interval}.*/$" | head -n 1)" || \ + _exit_err "Failed to list contents of ${ddir}/." + _techo " Most recent ${trial_interval}: '${most_recent}'" + if [ -n "${most_recent}" ]; then + no_intervals="$(ls -1 "${intervals_dir}/" | wc -l)" + n=1 + while [ "${n}" -le "${no_intervals}" ]; do + trial_interval="$(ls -p1 "${intervals_dir}/" | tail -n+${n} | head -n 1)" + _techo "Considering interval '${trial_interval}'" + c_interval="$(cat "${intervals_dir}/${trial_interval}" 2>/dev/null)" + m=$((${n}+1)) + set -- "${ddir}" -maxdepth 1 + while [ "${m}" -le "${no_intervals}" ]; do + interval_m="$(ls -1 "${intervals_dir}/" | tail -n+${m} | head -n 1)" + most_recent="$(pcmd ls -${TSORT}p1 "${ddir}" | grep "^${interval_m}\..*/$" | head -n 1)" + _techo " Most recent ${interval_m}: '${most_recent}'" + if [ -n "${most_recent}" ] ; then + set -- "$@" -$NEWER "${ddir}/${most_recent}" + fi + m=$((${m}+1)) + done + count=$(pcmd find "$@" -iname "${trial_interval}*" | wc -l) + _techo " Found $count more recent backups of ${trial_interval} (limit: ${c_interval})" + if [ "$count" -lt "${c_interval}" ] ; then + break + fi + n=$((${n}+1)) + done + fi + export INTERVAL="${trial_interval}" + D_FILE_INTERVAL="${intervals_dir}/${INTERVAL}" + D_INTERVAL=$(cat "${D_FILE_INTERVAL}" 2>/dev/null) +} + +# +# need at least interval and one source or --all +# +if [ $# -lt 2 ]; then + if [ "$1" = "-V" -o "$1" = "--version" ]; then + display_version + else + usage + fi +fi + +# +# check for configuraton directory +# +[ -d "${CCOLLECT_CONF}" ] || _exit_err "No configuration found in " \ + "\"${CCOLLECT_CONF}\" (is \$CCOLLECT_CONF properly set?)" + +# +# Filter arguments +# +export INTERVAL="$1"; shift +i=1 +no_sources=0 + +# +# Create source "array" +# +while [ "$#" -ge 1 ]; do + eval arg=\"\$1\"; shift + + if [ "${NO_MORE_ARGS}" = 1 ]; then + eval source_${no_sources}=\"${arg}\" + no_sources=$((${no_sources}+1)) + + # make variable available for subscripts + eval export source_${no_sources} + else + case "${arg}" in + -a|--all) + ALL=1 + ;; + -v|--verbose) + VERBOSE=1 + ;; + -p|--parallel) + PARALLEL=1 + ;; + -h|--help) + usage + ;; + --) + NO_MORE_ARGS=1 + ;; + *) + eval source_${no_sources}=\"$arg\" + no_sources=$(($no_sources+1)) + ;; + esac + fi + + i=$(($i+1)) +done + +# also export number of sources +export no_sources + +# +# be really, really, really verbose +# +if [ "${VERBOSE}" = 1 ]; then + set -x +fi + +# +# Look, if we should take ALL sources +# +if [ "${ALL}" = 1 ]; then + # reset everything specified before + no_sources=0 + + # + # get entries from sources + # + cwd=$(pwd -P) + ( cd "${CSOURCES}" && ls > "${TMP}" ); ret=$? + + [ "${ret}" -eq 0 ] || _exit_err "Listing of sources failed. Aborting." + + while read tmp; do + eval source_${no_sources}=\"${tmp}\" + no_sources=$((${no_sources}+1)) + done < "${TMP}" +fi + +# +# Need at least ONE source to backup +# +if [ "${no_sources}" -lt 1 ]; then + usage +else + _techo "${HALF_VERSION}: Beginning backup using interval ${INTERVAL}" +fi + +# +# Look for pre-exec command (general) +# +if [ -x "${CPREEXEC}" ]; then + _techo "Executing ${CPREEXEC} ..." + "${CPREEXEC}"; ret=$? + _techo "Finished ${CPREEXEC} (return code: ${ret})." + + [ "${ret}" -eq 0 ] || _exit_err "${CPREEXEC} failed. Aborting" +fi + +# +# check default configuration +# + +D_FILE_INTERVAL="${CDEFAULTS}/intervals/${INTERVAL}" +D_INTERVAL=$(cat "${D_FILE_INTERVAL}" 2>/dev/null) + + +# +# Let's do the backup +# +i=0 +while [ "${i}" -lt "${no_sources}" ]; do + + # + # Get current source + # + eval name=\"\$source_${i}\" + i=$((${i}+1)) + + export name + + # + # start ourself, if we want parallel execution + # + if [ "${PARALLEL}" ]; then + "$0" "${INTERVAL}" "${name}" & + continue + fi + +# +# Start subshell for easy log editing +# +( + # + # Stderr to stdout, so we can produce nice logs + # + exec 2>&1 + + # + # Configuration + # + backup="${CSOURCES}/${name}" + c_source="${backup}/source" + c_dest="${backup}/destination" + c_exclude="${backup}/exclude" + c_verbose="${backup}/verbose" + c_vverbose="${backup}/very_verbose" + c_rsync_extra="${backup}/rsync_options" + c_summary="${backup}/summary" + c_pre_exec="${backup}/pre_exec" + c_post_exec="${backup}/post_exec" + f_incomplete="delete_incomplete" + c_incomplete="${backup}/${f_incomplete}" + c_remote_host="${backup}/remote_host" + + # + # Marking backups: If we abort it's not removed => Backup is broken + # + c_marker=".ccollect-marker" + + # + # Times + # + begin_s=$(date +%s) + + # + # unset possible options + # + EXCLUDE="" + RSYNC_EXTRA="" + SUMMARY="" + VERBOSE="" + VVERBOSE="" + DELETE_INCOMPLETE="" + + _techo "Beginning to backup" + + # + # Standard configuration checks + # + if [ ! -e "${backup}" ]; then + _exit_err "Source does not exist." + fi + + # + # configuration _must_ be a directory + # + if [ ! -d "${backup}" ]; then + _exit_err "\"${name}\" is not a cconfig-directory. Skipping." + fi + + # + # first execute pre_exec, which may generate destination or other + # parameters + # + if [ -x "${c_pre_exec}" ]; then + _techo "Executing ${c_pre_exec} ..." + "${c_pre_exec}"; ret="$?" + _techo "Finished ${c_pre_exec} (return code ${ret})." + + if [ "${ret}" -ne 0 ]; then + _exit_err "${c_pre_exec} failed. Skipping." + fi + fi + + # + # Destination is a path + # + if [ ! -f "${c_dest}" ]; then + _exit_err "Destination ${c_dest} is not a file. Skipping." + else + ddir=$(cat "${c_dest}"); ret="$?" + if [ "${ret}" -ne 0 ]; then + _exit_err "Destination ${c_dest} is not readable. Skipping." + fi + fi + + # + # interval definition: First try source specific, fallback to default + # + if [ ${INTERVAL} = "AUTO" ] ; then + auto_interval + _techo "Selected interval: '$INTERVAL'" + fi + c_interval="$(cat "${backup}/intervals/${INTERVAL}" 2>/dev/null)" + + if [ -z "${c_interval}" ]; then + c_interval="${D_INTERVAL}" + + if [ -z "${c_interval}" ]; then + _exit_err "No definition for interval \"${INTERVAL}\" found. Skipping." + fi + fi + + # + # Source checks + # + if [ ! -f "${c_source}" ]; then + _exit_err "Source description \"${c_source}\" is not a file. Skipping." + else + source=$(cat "${c_source}"); ret="$?" + if [ "${ret}" -ne 0 ]; then + _exit_err "Source ${c_source} is not readable. Skipping." + fi + fi + # Verify source is up and accepting connections before deleting any old backups + rsync "$source" >/dev/null || _exit_err "Source ${source} is not readable. Skipping." + + # + # do we backup to a remote host? then set pre-cmd + # + if [ -f "${c_remote_host}" ]; then + # adjust ls and co + remote_host=$(cat "${c_remote_host}"); ret="$?" + if [ "${ret}" -ne 0 ]; then + _exit_err "Remote host file ${c_remote_host} exists, but is not readable. Skipping." + fi + destination="${remote_host}:${ddir}" + else + remote_host="" + destination="${ddir}" + fi + export remote_host + + # + # check for existence / use real name + # + ( pcmd cd "$ddir" ) || _exit_err "Cannot change to ${ddir}. Skipping." + + + # + # Check whether to delete incomplete backups + # + if [ -f "${c_incomplete}" -o -f "${CDEFAULTS}/${f_incomplete}" ]; then + DELETE_INCOMPLETE="yes" + fi + + # NEW method as of 0.6: + # - insert ccollect default parameters + # - insert options + # - insert user options + + # + # rsync standard options + # + + set -- "$@" "--archive" "--delete" "--numeric-ids" "--relative" \ + "--delete-excluded" "--sparse" + + # + # exclude list + # + if [ -f "${c_exclude}" ]; then + set -- "$@" "--exclude-from=${c_exclude}" + fi + + # + # Output a summary + # + if [ -f "${c_summary}" ]; then + set -- "$@" "--stats" + fi + + # + # Verbosity for rsync + # + if [ -f "${c_vverbose}" ]; then + set -- "$@" "-vv" + elif [ -f "${c_verbose}" ]; then + set -- "$@" "-v" + fi + + # + # extra options for rsync provided by the user + # + if [ -f "${c_rsync_extra}" ]; then + while read line; do + set -- "$@" "$line" + done < "${c_rsync_extra}" + fi + + # + # Check for incomplete backups + # + pcmd ls -1 "$ddir/${INTERVAL}"*".${c_marker}" > "${TMP}" 2>/dev/null + + i=0 + while read incomplete; do + eval incomplete_$i=\"$(echo ${incomplete} | sed "s/\\.${c_marker}\$//")\" + i=$(($i+1)) + done < "${TMP}" + + j=0 + while [ "$j" -lt "$i" ]; do + eval realincomplete=\"\$incomplete_$j\" + _techo "Incomplete backup: ${realincomplete}" + if [ "${DELETE_INCOMPLETE}" = "yes" ]; then + _techo "Deleting ${realincomplete} ..." + pcmd rm $VVERBOSE -rf "${ddir}/${realincomplete}" || \ + _exit_err "Removing ${realincomplete} failed." + fi + j=$(($j+1)) + done + + # + # check if maximum number of backups is reached, if so remove + # use grep and ls -p so we only look at directories + # + count="$(pcmd ls -p1 "${ddir}" | grep "^${INTERVAL}\..*/\$" | wc -l \ + | sed 's/^ *//g')" || _exit_err "Counting backups failed" + + _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" + + if [ "${count}" -ge "${c_interval}" ]; then + substract=$((${c_interval} - 1)) + remove=$((${count} - ${substract})) + _techo "Removing ${remove} backup(s)..." + + pcmd ls -${TSORT}p1r "$ddir" | grep "^${INTERVAL}\..*/\$" | \ + head -n "${remove}" > "${TMP}" || \ + _exit_err "Listing old backups failed" + + i=0 + while read to_remove; do + eval remove_$i=\"${to_remove}\" + i=$(($i+1)) + done < "${TMP}" + + j=0 + while [ "$j" -lt "$i" ]; do + eval to_remove=\"\$remove_$j\" + _techo "Removing ${to_remove} ..." + pcmd rm ${VVERBOSE} -rf "${ddir}/${to_remove}" || \ + _exit_err "Removing ${to_remove} failed." + j=$(($j+1)) + done + fi + + + # + # Check for backup directory to clone from: Always clone from the latest one! + # + # Depending on your file system, you may want to sort on: + # 1. mtime (modification time) with TSORT=t, or + # 2. ctime (last change time, usually) with TSORT=tc + last_dir="$(pcmd ls -${TSORT}p1 "${ddir}" | grep '/$' | head -n 1)" || \ + _exit_err "Failed to list contents of ${ddir}." + + # + # clone from old backup, if existing + # + if [ "${last_dir}" ]; then + set -- "$@" "--link-dest=${ddir}/${last_dir}" + _techo "Hard linking from ${last_dir}" + fi + + + # set time when we really begin to backup, not when we began to remove above + destination_date=$(${CDATE}) + destination_dir="${ddir}/${INTERVAL}.${destination_date}.$$" + destination_full="${destination}/${INTERVAL}.${destination_date}.$$" + + # give some info + _techo "Beginning to backup, this may take some time..." + + _techo "Creating ${destination_dir} ..." + pcmd mkdir ${VVERBOSE} "${destination_dir}" || \ + _exit_err "Creating ${destination_dir} failed. Skipping." + + # + # added marking in 0.6 (and remove it, if successful later) + # + pcmd touch "${destination_dir}.${c_marker}" + + # + # the rsync part + # + _techo "Transferring files..." + rsync "$@" "${source}" "${destination_full}"; ret=$? + # Correct the modification time: + pcmd touch "${destination_dir}" + + # + # remove marking here + # + if [ "$ret" -ne 12 ] ; then + pcmd rm "${destination_dir}.${c_marker}" || \ + _exit_err "Removing ${destination_dir}/${c_marker} failed." + fi + + _techo "Finished backup (rsync return code: $ret)." + if [ "${ret}" -ne 0 ]; then + _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." + fi + + # + # post_exec + # + if [ -x "${c_post_exec}" ]; then + _techo "Executing ${c_post_exec} ..." + "${c_post_exec}"; ret=$? + _techo "Finished ${c_post_exec}." + + if [ ${ret} -ne 0 ]; then + _exit_err "${c_post_exec} failed." + fi + fi + + # Calculation + end_s=$(date +%s) + + full_seconds=$((${end_s} - ${begin_s})) + hours=$((${full_seconds} / 3600)) + seconds=$((${full_seconds} - (${hours} * 3600))) + minutes=$((${seconds} / 60)) + seconds=$((${seconds} - (${minutes} * 60))) + + _techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" + +) | add_name +done + +# +# Be a good parent and wait for our children, if they are running wild parallel +# +if [ "${PARALLEL}" ]; then + _techo "Waiting for children to complete..." + wait +fi + +# +# Look for post-exec command (general) +# +if [ -x "${CPOSTEXEC}" ]; then + _techo "Executing ${CPOSTEXEC} ..." + "${CPOSTEXEC}"; ret=$? + _techo "Finished ${CPOSTEXEC} (return code: ${ret})." + + if [ ${ret} -ne 0 ]; then + _techo "${CPOSTEXEC} failed." + fi +fi + +rm -f "${TMP}" +_techo "Finished ${WE}" + +# vim: set shiftwidth=3 tabstop=3 expandtab : diff --git a/contrib/jlawless-2009-06-03/old/d.patch b/contrib/jlawless-2009-06-03/old/d.patch new file mode 100644 index 0000000..7fae410 --- /dev/null +++ b/contrib/jlawless-2009-06-03/old/d.patch @@ -0,0 +1,17 @@ +--- ccollect-0.7.1-c.sh 2009-05-24 21:39:43.000000000 -0700 ++++ ccollect-0.7.1-d.sh 2009-05-24 21:47:09.000000000 -0700 +@@ -492,12 +492,12 @@ + if [ "${count}" -ge "${c_interval}" ]; then + substract=$((${c_interval} - 1)) + remove=$((${count} - ${substract})) + _techo "Removing ${remove} backup(s)..." + +- pcmd ls -p1 "$ddir" | grep "^${INTERVAL}\..*/\$" | \ +- sort -n | head -n "${remove}" > "${TMP}" || \ ++ pcmd ls -${TSORT}p1r "$ddir" | grep "^${INTERVAL}\..*/\$" | \ ++ head -n "${remove}" > "${TMP}" || \ + _exit_err "Listing old backups failed" + + i=0 + while read to_remove; do + eval remove_$i=\"${to_remove}\" diff --git a/contrib/jlawless-2009-06-03/old/e.patch b/contrib/jlawless-2009-06-03/old/e.patch new file mode 100644 index 0000000..d277c06 --- /dev/null +++ b/contrib/jlawless-2009-06-03/old/e.patch @@ -0,0 +1,19 @@ +--- ccollect-0.7.1-d.sh 2009-05-24 21:47:09.000000000 -0700 ++++ ccollect-0.7.1-e.sh 2009-05-24 22:18:16.000000000 -0700 +@@ -560,12 +560,14 @@ + pcmd touch "${destination_dir}" + + # + # remove marking here + # +- pcmd rm "${destination_dir}.${c_marker}" || \ +- _exit_err "Removing ${destination_dir}/${c_marker} failed." ++ if [ "$ret" -ne 12 ] ; then ++ pcmd rm "${destination_dir}.${c_marker}" || \ ++ _exit_err "Removing ${destination_dir}/${c_marker} failed." ++ fi + + _techo "Finished backup (rsync return code: $ret)." + if [ "${ret}" -ne 0 ]; then + _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." + fi diff --git a/contrib/jlawless-2009-06-03/old/f.patch b/contrib/jlawless-2009-06-03/old/f.patch new file mode 100644 index 0000000..3bedf34 --- /dev/null +++ b/contrib/jlawless-2009-06-03/old/f.patch @@ -0,0 +1,119 @@ +--- ccollect-0.7.1-e.sh 2009-05-24 22:18:16.000000000 -0700 ++++ ccollect-0.7.1-f.sh 2009-05-24 22:19:50.000000000 -0700 +@@ -124,10 +124,64 @@ + echo " Retrieve latest ccollect at http://unix.schottelius.org/ccollect/" + exit 0 + } + + # ++# Select interval if AUTO ++# ++# For this to work nicely, you have to choose interval names that sort nicely ++# such as int1, int2, int3 or a_daily, b_weekly, c_monthly, etc. ++# ++auto_interval() ++{ ++ if [ -d "${backup}/intervals" -a -n "$(ls "${backup}/intervals" 2>/dev/null)" ] ; then ++ intervals_dir="${backup}/intervals" ++ elif [ -d "${CDEFAULTS}/intervals" -a -n "$(ls "${CDEFAULTS}/intervals" 2>/dev/null)" ] ; then ++ intervals_dir="${CDEFAULTS}/intervals" ++ else ++ _exit_err "No intervals are defined. Skipping." ++ fi ++ echo intervals_dir=${intervals_dir} ++ ++ trial_interval="$(ls -1r "${intervals_dir}/" | head -n 1)" || \ ++ _exit_err "Failed to list contents of ${intervals_dir}/." ++ _techo "Considering interval ${trial_interval}" ++ most_recent="$(pcmd ls -${TSORT}p1 "${ddir}" | grep "^${trial_interval}.*/$" | head -n 1)" || \ ++ _exit_err "Failed to list contents of ${ddir}/." ++ _techo " Most recent ${trial_interval}: '${most_recent}'" ++ if [ -n "${most_recent}" ]; then ++ no_intervals="$(ls -1 "${intervals_dir}/" | wc -l)" ++ n=1 ++ while [ "${n}" -le "${no_intervals}" ]; do ++ trial_interval="$(ls -p1 "${intervals_dir}/" | tail -n+${n} | head -n 1)" ++ _techo "Considering interval '${trial_interval}'" ++ c_interval="$(cat "${intervals_dir}/${trial_interval}" 2>/dev/null)" ++ m=$((${n}+1)) ++ set -- "${ddir}" -maxdepth 1 ++ while [ "${m}" -le "${no_intervals}" ]; do ++ interval_m="$(ls -1 "${intervals_dir}/" | tail -n+${m} | head -n 1)" ++ most_recent="$(pcmd ls -${TSORT}p1 "${ddir}" | grep "^${interval_m}\..*/$" | head -n 1)" ++ _techo " Most recent ${interval_m}: '${most_recent}'" ++ if [ -n "${most_recent}" ] ; then ++ set -- "$@" -$NEWER "${ddir}/${most_recent}" ++ fi ++ m=$((${m}+1)) ++ done ++ count=$(pcmd find "$@" -iname "${trial_interval}*" | wc -l) ++ _techo " Found $count more recent backups of ${trial_interval} (limit: ${c_interval})" ++ if [ "$count" -lt "${c_interval}" ] ; then ++ break ++ fi ++ n=$((${n}+1)) ++ done ++ fi ++ export INTERVAL="${trial_interval}" ++ D_FILE_INTERVAL="${intervals_dir}/${INTERVAL}" ++ D_INTERVAL=$(cat "${D_FILE_INTERVAL}" 2>/dev/null) ++} ++ ++# + # need at least interval and one source or --all + # + if [ $# -lt 2 ]; then + if [ "$1" = "-V" -o "$1" = "--version" ]; then + display_version +@@ -344,12 +398,28 @@ + _exit_err "${c_pre_exec} failed. Skipping." + fi + fi + + # ++ # Destination is a path ++ # ++ if [ ! -f "${c_dest}" ]; then ++ _exit_err "Destination ${c_dest} is not a file. Skipping." ++ else ++ ddir=$(cat "${c_dest}"); ret="$?" ++ if [ "${ret}" -ne 0 ]; then ++ _exit_err "Destination ${c_dest} is not readable. Skipping." ++ fi ++ fi ++ ++ # + # interval definition: First try source specific, fallback to default + # ++ if [ ${INTERVAL} = "AUTO" ] ; then ++ auto_interval ++ _techo "Selected interval: '$INTERVAL'" ++ fi + c_interval="$(cat "${backup}/intervals/${INTERVAL}" 2>/dev/null)" + + if [ -z "${c_interval}" ]; then + c_interval="${D_INTERVAL}" + +@@ -371,22 +441,10 @@ + fi + # Verify source is up and accepting connections before deleting any old backups + rsync "$source" >/dev/null || _exit_err "Source ${source} is not readable. Skipping." + + # +- # Destination is a path +- # +- if [ ! -f "${c_dest}" ]; then +- _exit_err "Destination ${c_dest} is not a file. Skipping." +- else +- ddir=$(cat "${c_dest}"); ret="$?" +- if [ "${ret}" -ne 0 ]; then +- _exit_err "Destination ${c_dest} is not readable. Skipping." +- fi +- fi +- +- # + # do we backup to a remote host? then set pre-cmd + # + if [ -f "${c_remote_host}" ]; then + # adjust ls and co + remote_host=$(cat "${c_remote_host}"); ret="$?" From f4f9564bde9324224c8db2e33af0790c35e25fb4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 16 Jun 2009 10:34:49 +0200 Subject: [PATCH 317/581] add backup manager from Jens-Christoph Brendel Signed-off-by: Nico Schottelius --- contrib/jbrendel-autobackup/backup.sh | 22 +++ contrib/jbrendel-autobackup/bm.pl | 242 +++++++++++++++++++++++ contrib/jbrendel-autobackup/correction_1 | 3 + 3 files changed, 267 insertions(+) create mode 100644 contrib/jbrendel-autobackup/backup.sh create mode 100644 contrib/jbrendel-autobackup/bm.pl create mode 100644 contrib/jbrendel-autobackup/correction_1 diff --git a/contrib/jbrendel-autobackup/backup.sh b/contrib/jbrendel-autobackup/backup.sh new file mode 100644 index 0000000..ea21635 --- /dev/null +++ b/contrib/jbrendel-autobackup/backup.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +function mkbackup { + find /etc/ccollect/logwrapper/destination -type f -atime +2 -exec sudo rm {} \; + /home/jcb/bm.pl & +} + +mkdir -p /media/backupdisk +grep backupdisk /etc/mtab &> /dev/null + +if [ $? == 0 ] +then + mkbackup +else + mount /media/backupdisk + if [ $? == 0 ] + then + mkbackup + else + echo "Error mounting backup disk" + fi +fi diff --git a/contrib/jbrendel-autobackup/bm.pl b/contrib/jbrendel-autobackup/bm.pl new file mode 100644 index 0000000..3a3da84 --- /dev/null +++ b/contrib/jbrendel-autobackup/bm.pl @@ -0,0 +1,242 @@ +#!/usr/bin/perl + +############################### +# +# Jens-Christoph Brendel, 2009 +# licensed under GPL3 NO WARRANTY +# +############################### + +use Date::Calc qw(:all); +use strict; +use warnings; + +# +#!!!!!!!!!!!!!!!!! you need to customize these settings !!!!!!!!!!!!!!!!!!!! +# +my $backupdir = "/media/backupdisk"; +my $logwrapper = "/home/jcb/ccollect/tools/ccollect_logwrapper.sh"; + +#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +# +------------------------------------------------------------------------+ +# | | +# | V A R I A B L E S | +# | | +# +------------------------------------------------------------------------+ +# + +# get the current date +# +my ($sek, $min, $hour, $day, $month, $year) = localtime(); + +my $curr_year = $year + 1900; +my $curr_month = $month +1; +my ($curr_week,$cur_year) = Week_of_Year($curr_year,$curr_month,$day); + +# initialize some variables +# +my %most_recent_daily = ( + 'age' => 9999, + 'file' => '' +); + +my %most_recent_weekly = ( + 'age' => 9999, + 'file' => '' +); + +my %most_recent_monthly = ( + 'age' => 9999, + 'file' => '' +); + +# prepare the output formatting +# +#--------------------------------------------------------------------------- +my ($msg1, $msg2, $msg3, $msg4); + +format = + @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + $msg1 + @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<< + $msg2, $msg3 + + @|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| + $msg4 +. + +my @months = (' ','January', 'February', 'March', 'April', + 'May', 'June', 'July', 'August', + 'September', 'October', 'November', + 'December'); + +# +------------------------------------------------------------------------+ +# | | +# | P r o c e d u r e s | +# | | +# +------------------------------------------------------------------------+ +# + +# PURPOSE: extract the date from the file name +# PARAMETER VALUE: file name +# RETURN VALUE: pointer of a hash containing year, month, day +# +sub decodeDate { + my $file = shift; + $file =~ /^(daily|weekly|monthly)\.(\d+)-.*/; + my %date = ( + 'y' => substr($2,0,4), + 'm' => substr($2,4,2), + 'd' => substr($2,6,2) + ); + return \%date; +} + +# PURPOSE: calculate the file age in days +# PARAMETER VALUE: name of a ccollect backup file +# RETURN VALUE: age in days +# +sub AgeInDays { + my $file = shift; + my $date=decodeDate($file); + my $ageindays = Delta_Days($$date{'y'}, $$date{'m'}, $$date{'d'}, $curr_year, $curr_month, $day); + return $ageindays; +} + +# PURPOSE: calculate the file age in number of weeks +# PARAMETER VALUE: name of a ccollect backup file +# RETURN VALUE: age in weeks +# +sub AgeInWeeks { + my($y,$m,$d); + + my $file = shift; + my $date = decodeDate($file); + my ($weeknr,$yr) = Week_of_Year($$date{'y'}, $$date{'m'}, $$date{'d'}); + my $ageinweeks = $curr_week - $weeknr; + return $ageinweeks; +} + +# PURPOSE: calculate the file age in number of months +# PARAMETER VALUE: name of a ccollect backup file +# RETURN VALUE: age in months +# +sub AgeInMonths { + my $ageinmonths; + my $ageinmonths; + my $file = shift; + my $date = decodeDate($file); + if ($curr_year == $$date{'y'}) { + $ageinmonths = $curr_month - $$date{'m'}; + } else { + $ageinmonths = $curr_month + (12-$$date{'m'}) + ($curr_year-$$date{'y'}-1)*12; + } + return $ageinmonths; +} + +# +------------------------------------------------------------------------+ +# | | +# | M A I N | +# | | +# +------------------------------------------------------------------------+ +# + +# +# find the most recent daily, weekly and monthly backup file +# + +opendir(DIRH, $backupdir) or die "Can't open $backupdir \n"; + +my @files = readdir(DIRH); + +die "Zielverzeichnis leer \n" if ( $#files <= 1 ); + +foreach my $file (@files) { + + next if $file eq "." or $file eq ".."; + + SWITCH: { + if ($file =~ /^daily/) { + my $curr_age=AgeInDays($file); + if ($curr_age<$most_recent_daily{'age'}) { + $most_recent_daily{'age'} =$curr_age; + $most_recent_daily{'file'}= $file; + } + last SWITCH; + } + + if ($file =~ /^weekly/) { + my $curr_week_age = AgeInWeeks($file); + if ($curr_week_age<$most_recent_weekly{'age'}) { + $most_recent_weekly{'age'} =$curr_week_age; + $most_recent_weekly{'file'}=$file; + } + last SWITCH; + } + + if ($file =~ /^monthly/) { + my $curr_month_age=AgeInMonths($file); + if ($curr_month_age < $most_recent_monthly{'age'}) { + $most_recent_monthly{'age'} =$curr_month_age; + $most_recent_monthly{'file'}=$file; + } + last SWITCH; + } + print "\n\n unknown file $file \n\n"; + } +} + +printf("\nBackup Manager started: %02u.%02u. %u, week %02u\n\n", $day, $curr_month, $curr_year, $curr_week); + +# +# compare the most recent daily, weekly and monthly backup file +# and decide if it's necessary to start a new backup process in +# each category +# + +if ($most_recent_monthly{'age'} == 0) { + $msg1="The most recent monthly backup"; + $msg2="$most_recent_monthly{'file'} from $months[$curr_month - $most_recent_monthly{'age'}]"; + $msg3="is still valid."; + $msg4=""; + write; +} else { + $msg1="The most recent monthly backup"; + $msg2="$most_recent_monthly{'file'} from $months[$curr_month - $most_recent_monthly{'age'}]"; + $msg3="is out-dated."; + $msg4="Starting new monthly backup."; + write; + exec "sudo $logwrapper monthly FULL"; + exit; +} + +if ($most_recent_weekly{'age'} == 0) { + $msg1="The most recent weekly backup"; + $msg2="$most_recent_weekly{'file'} from week nr: $curr_week-$most_recent_weekly{'age'}"; + $msg3="is still valid."; + $msg4=""; + write; +} else { + $msg1="The most recent weekly backup"; + $msg2="$most_recent_weekly{'file'} from week nr: $curr_week-$most_recent_weekly{'age'}"; + $msg3="is out-dated."; + $msg4="Starting new weekly backup."; + write; + exec "sudo $logwrapper weekly FULL"; + exit; +} + +if ($most_recent_daily{'age'} == 0 ) { + $msg1=" The most recent daily backup"; + $msg2="$most_recent_daily{'file'}"; + $msg3="is still valid."; + $msg4=""; + write; +} else { + $msg1="The most recent daily backup"; + $msg2="$most_recent_daily{'file'}"; + $msg3="is out-dated."; + $msg4="Starting new daily backup."; + write; + exec "sudo $logwrapper daily FULL"; diff --git a/contrib/jbrendel-autobackup/correction_1 b/contrib/jbrendel-autobackup/correction_1 new file mode 100644 index 0000000..4fec440 --- /dev/null +++ b/contrib/jbrendel-autobackup/correction_1 @@ -0,0 +1,3 @@ +- Zeile 126/127 (my $ageinmonths;) ist doppelt, einmal streichen. +- in die allerletzte Zeile gehört eine schließende geschweifte Klammer +"}", die irgendwo verlorengegangen ist. From b121e545f7660eb5613fe2dbc08a2548492f49d8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 18 Jun 2009 10:02:39 +0200 Subject: [PATCH 318/581] WARNING: THIS TREE WAS REWRITTEN I added some patches from John with an E-Mail address he does not to be public on the internet. I did not ask him before whether this is fine, so I screwed up (similar to the description in git-tag(1)). Thus I replaced his e-mail and would like you to accept this forced push and remove old trees on the net. Thanks, Nico Signed-off-by: Nico Schottelius --- README | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/README b/README index cab53f1..e74464d 100644 --- a/README +++ b/README @@ -20,30 +20,30 @@ using ccollect. A small try to visualize the differences in a table: +---------------+-------------------------------------------------------------+ -| What? | rsnapshot | ccollect | +| What? | rsnapshot | ccollect | +---------------+-------------------------------------------------------------+ -| Configuration | tab separated, needs | plain cconfig-style | -| | parsing | | +| Configuration | tab separated, needs | plain cconfig-style | +| | parsing | | +---------------+-------------------------------------------------------------+ -| Per source | | | -| post-/pre- | no | yes | -| execution | | | +| Per source | | | +| post-/pre- | no | yes | +| execution | | | +---------------+-------------------------------------------------------------+ -| Per source | | | -| exclude lists | no | yes | +| Per source | | | +| exclude lists | no | yes | +---------------+-------------------------------------------------------------+ -| Parallel | | | -| execution | | | -| of multiple | no | yes | -| backups | | | +| Parallel | | | +| execution | | | +| of multiple | no | yes | +| backups | | | +---------------+-------------------------------------------------------------+ -| Programming | perl | sh | -| language | | (posix compatible) | +| Programming | perl | sh | +| language | | (posix compatible) | +---------------+-------------------------------------------------------------+ -| Lines of code | 6772 (5353 w/o comments, | 546 (375 w/o comments, | -| (2006-10-25) | 4794 w/o empty lines) | 288 w/o empty lines) | +| Lines of code | 6772 (5353 w/o comments, | 546 (375 w/o comments, | +| (2006-10-25) | 4794 w/o empty lines) | 288 w/o empty lines) | +---------------+-------------------------------------------------------------+ -| Age | Available since 2002/2003 | Written at 2005-11-14 | +| Age | Available since 2002/2003 | Written at 2005-11-14 | +---------------+-------------------------------------------------------------+ Included documentation: From 122982b0b98fe13a7f5d26fd9c18bed9e8e3d397 Mon Sep 17 00:00:00 2001 From: jll2 Date: Sun, 14 Jun 2009 17:54:48 -0700 Subject: [PATCH 319/581] Modifies ccollect.sh's interpretation of options: 1). If an option doesn't exist in a source directory, check the defaults directory. 2). For every option, create a corresponding "no_" option so that a source directory can override an option set in defaults. (i.patch) --- ccollect.sh | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index cd13ac8..f1bd00c 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -283,16 +283,15 @@ while [ "${i}" -lt "${no_sources}" ]; do backup="${CSOURCES}/${name}" c_source="${backup}/source" c_dest="${backup}/destination" - c_exclude="${backup}/exclude" - c_verbose="${backup}/verbose" - c_vverbose="${backup}/very_verbose" - c_rsync_extra="${backup}/rsync_options" - c_summary="${backup}/summary" c_pre_exec="${backup}/pre_exec" c_post_exec="${backup}/post_exec" - f_incomplete="delete_incomplete" - c_incomplete="${backup}/${f_incomplete}" - c_remote_host="${backup}/remote_host" + for opt in exclude verbose very_verbose rsync_options summary delete_incomplete remote_host ; do + if [ -f "${backup}/$opt" -o -f "${backup}/no_$opt" ]; then + eval c_$opt=\"${backup}/$opt\" + else + eval c_$opt=\"${CDEFAULTS}/$opt\" + fi + done # # Marking backups: If we abort it's not removed => Backup is broken @@ -307,12 +306,8 @@ while [ "${i}" -lt "${no_sources}" ]; do # # unset possible options # - EXCLUDE="" - RSYNC_EXTRA="" - SUMMARY="" VERBOSE="" VVERBOSE="" - DELETE_INCOMPLETE="" _techo "Beginning to backup" @@ -408,13 +403,6 @@ while [ "${i}" -lt "${no_sources}" ]; do ( pcmd cd "$ddir" ) || _exit_err "Cannot change to ${ddir}. Skipping." - # - # Check whether to delete incomplete backups - # - if [ -f "${c_incomplete}" -o -f "${CDEFAULTS}/${f_incomplete}" ]; then - DELETE_INCOMPLETE="yes" - fi - # NEW method as of 0.6: # - insert ccollect default parameters # - insert options @@ -444,7 +432,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Verbosity for rsync # - if [ -f "${c_vverbose}" ]; then + if [ -f "${c_very_verbose}" ]; then set -- "$@" "-vv" elif [ -f "${c_verbose}" ]; then set -- "$@" "-v" @@ -453,10 +441,10 @@ while [ "${i}" -lt "${no_sources}" ]; do # # extra options for rsync provided by the user # - if [ -f "${c_rsync_extra}" ]; then + if [ -f "${c_rsync_options}" ]; then while read line; do set -- "$@" "$line" - done < "${c_rsync_extra}" + done < "${c_rsync_options}" fi # @@ -474,7 +462,7 @@ while [ "${i}" -lt "${no_sources}" ]; do while [ "$j" -lt "$i" ]; do eval realincomplete=\"\$incomplete_$j\" _techo "Incomplete backup: ${realincomplete}" - if [ "${DELETE_INCOMPLETE}" = "yes" ]; then + if [ -f "${c_delete_incomplete}" ]; then _techo "Deleting ${realincomplete} ..." pcmd rm $VVERBOSE -rf "${ddir}/${realincomplete}" || \ _exit_err "Removing ${realincomplete} failed." From 192b55b98d0df8ec3b235b7d61bb919a2e19c190 Mon Sep 17 00:00:00 2001 From: jll2 Date: Sun, 14 Jun 2009 19:15:12 -0700 Subject: [PATCH 320/581] Initialize four variables to prevent unwanted interaction with user's environment. --- ccollect.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index f1bd00c..f158a19 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -149,8 +149,12 @@ i=1 no_sources=0 # -# Create source "array" +# Capture options and create source "array" # +WE="" +ALL="" +VERBOSE="" +NO_MORE_ARGS="" while [ "$#" -ge 1 ]; do eval arg=\"\$1\"; shift From a4c61e7b6870b0f50a03d8f95298434f1fe8dcc1 Mon Sep 17 00:00:00 2001 From: jll2 Date: Mon, 15 Jun 2009 17:54:03 -0700 Subject: [PATCH 321/581] Bug fix for very_verbose: According to the documentation, "if [the very_verbose] file exists in the source specification -v will be passed to rsync, rm and mkdir." Previously, the -v option was passed only to rsync. This patch passes it to rm and mkdir as well. Actually, as per the behavior of the previous version, it is verbose that sends the -v option to rsync while very_verbose sends it the -vv option. I left it this way because this behavior seems reasonable. Maybe the documentation should be corrected on this point. --- ccollect.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index f158a19..3f2eda2 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -311,7 +311,6 @@ while [ "${i}" -lt "${no_sources}" ]; do # unset possible options # VERBOSE="" - VVERBOSE="" _techo "Beginning to backup" @@ -434,10 +433,12 @@ while [ "${i}" -lt "${no_sources}" ]; do fi # - # Verbosity for rsync + # Verbosity for rsync, rm, and mkdir # + VVERBOSE="" if [ -f "${c_very_verbose}" ]; then set -- "$@" "-vv" + VVERBOSE="-v" elif [ -f "${c_verbose}" ]; then set -- "$@" "-v" fi From ea16af51b28d048c2daf2341ae9faacfbb06bba7 Mon Sep 17 00:00:00 2001 From: jll2 Date: Mon, 15 Jun 2009 18:08:26 -0700 Subject: [PATCH 322/581] Simplify handling of command-line verbose option: Previously, there was a $VERBOSE script variable that was set according to the "-v" command line option and then reset to null within each source sub-shell. With no loss of functionality, this patch removes all references to that variable. This makes the script 13 lines shorter. --- ccollect.sh | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 3f2eda2..e93956d 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -153,7 +153,6 @@ no_sources=0 # WE="" ALL="" -VERBOSE="" NO_MORE_ARGS="" while [ "$#" -ge 1 ]; do eval arg=\"\$1\"; shift @@ -170,7 +169,7 @@ while [ "$#" -ge 1 ]; do ALL=1 ;; -v|--verbose) - VERBOSE=1 + set -x ;; -p|--parallel) PARALLEL=1 @@ -194,13 +193,6 @@ done # also export number of sources export no_sources -# -# be really, really, really verbose -# -if [ "${VERBOSE}" = 1 ]; then - set -x -fi - # # Look, if we should take ALL sources # @@ -307,11 +299,6 @@ while [ "${i}" -lt "${no_sources}" ]; do # begin_s=$(date +%s) - # - # unset possible options - # - VERBOSE="" - _techo "Beginning to backup" # From 10d420614c473f0f728b340f9172aa89c5a8e065 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 20 Jun 2009 21:00:21 +0200 Subject: [PATCH 323/581] [DOC] give some hints on how to hack ccollect Signed-off-by: Nico Schottelius --- README | 2 ++ doc/HACKING | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 doc/HACKING diff --git a/README b/README index e74464d..401d778 100644 --- a/README +++ b/README @@ -17,6 +17,8 @@ ccollect was inspired by rsnapshot [1], which has some problems: Please use tools/report_success.sh to report success, if you are successfully using ccollect. +Have a look at doc/HACKING, if you plan to change ccollect. + A small try to visualize the differences in a table: +---------------+-------------------------------------------------------------+ diff --git a/doc/HACKING b/doc/HACKING new file mode 100644 index 0000000..00db4d1 --- /dev/null +++ b/doc/HACKING @@ -0,0 +1,37 @@ +Hello Hacker, + +I really appreciate your interest in hacking this software, but +I am kind of critical when seeing patches. Thus I created this +file to give you some hints of my thinking quirks. + + +Submitting patches +------------------ +Make my life easier, make your life easier, use a version control system (vcs). +For this software the preferred vcs is git. Clone the latest repo, create +a new local branch (git checkout -b ) write down your ideas. + +When you're done, push all your stuff out to some public repo and drop a +mail to the mailinglist, what you did and where to get it. + + +Introduce a feature or change behaviour +--------------------------------------- +Uhh, fancy! You have had a great idea, then it's time to change +the major version, so others know that something changed. + +If the configuration format is changed, add a script to tools/ +to allow users upgrade their configuration to this major version. + +And now comes the most difficult part: Add documentation. Nobody +benefits from your cool feature, if it is not known. I know, writing +documentation is not so much fun, but you also expect good documentation +for this software, don't you? + + +If you think my thinking quirks must be corrected +------------------------------------------------- +See above ("Submitting patches") and submit a patch to this file. + + +Thanks for reading. From 4db6b78a13bcb671bab61c3b0f88c2187927e35e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 20 Jun 2009 21:05:49 +0200 Subject: [PATCH 324/581] Correctly sort CREDITS by alphabet Signed-off-by: Nico Schottelius --- CREDITS | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CREDITS b/CREDITS index 72d59cc..5c73034 100644 --- a/CREDITS +++ b/CREDITS @@ -1,9 +1,9 @@ -Thanks go to the following people: +Thanks go to the following people (sorted by alphabet): -* the whole #cLinux channel - - for testing and debugging (those I mean should know ;-) * Alexey Maximov - for finding return-value and shell limitation bugs +* #cLinux IRC channel on irc.freenode.org + - for testing and debugging (those I mean should know ;-) * Daniel Aubry - for reporting many hints * Markus Meier From d6ea94c6dcc86e3ade57895a3c1a5c50cb05358b Mon Sep 17 00:00:00 2001 From: jll2 Date: Mon, 15 Jun 2009 20:16:25 -0700 Subject: [PATCH 325/581] Fix delete_incomplete bugs: 1). On systems I tried, delete_incomplete failed because the line: < pcmd rm $VVERBOSE -rf "${ddir}/${realincomplete}" || \ should read: > pcmd rm $VVERBOSE -rf "${realincomplete}" || \ (Is this true of all systems?) 2). The marker file was not deleted. Code was added to delete it. 3). The delete_incomplete code was simplified. --- ccollect.sh | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index e93956d..d6831bc 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -442,24 +442,16 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Check for incomplete backups # - pcmd ls -1 "$ddir/${INTERVAL}"*".${c_marker}" > "${TMP}" 2>/dev/null - - i=0 - while read incomplete; do - eval incomplete_$i=\"$(echo ${incomplete} | sed "s/\\.${c_marker}\$//")\" - i=$(($i+1)) - done < "${TMP}" - - j=0 - while [ "$j" -lt "$i" ]; do - eval realincomplete=\"\$incomplete_$j\" - _techo "Incomplete backup: ${realincomplete}" + pcmd ls -1 "$ddir/${INTERVAL}"*".${c_marker}" 2>/dev/null | while read marker; do + incomplete="$(echo ${marker} | sed "s/\\.${c_marker}\$//")" + _techo "Incomplete backup: ${incomplete}" if [ -f "${c_delete_incomplete}" ]; then - _techo "Deleting ${realincomplete} ..." - pcmd rm $VVERBOSE -rf "${ddir}/${realincomplete}" || \ - _exit_err "Removing ${realincomplete} failed." + _techo "Deleting ${incomplete} ..." + pcmd rm $VVERBOSE -rf "${incomplete}" || \ + _exit_err "Removing ${incomplete} failed." + pcmd rm $VVERBOSE -f "${marker}" || \ + _exit_err "Removing ${marker} failed." fi - j=$(($j+1)) done # From cbff479c65b7c0c5e9a325179b6f4d1dfba82697 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 21 Jun 2009 00:15:04 +0200 Subject: [PATCH 326/581] Add John to the CREDITS list Signed-off-by: Nico Schottelius --- CREDITS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CREDITS b/CREDITS index 5c73034..2b315a5 100644 --- a/CREDITS +++ b/CREDITS @@ -6,6 +6,8 @@ Thanks go to the following people (sorted by alphabet): - for testing and debugging (those I mean should know ;-) * Daniel Aubry - for reporting many hints +* John Lawless + - A lot of patches and some very interesting discussions. * Markus Meier - for finding a really simple solution for choosing the right backup to clone from: Make it independent of the interval, simply choose the last From 2b285675888bf1f986e642c40476be38c0efd428 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 21 Jun 2009 00:15:21 +0200 Subject: [PATCH 327/581] Add README for contrib Signed-off-by: Nico Schottelius --- contrib/README | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 contrib/README diff --git a/contrib/README b/contrib/README new file mode 100644 index 0000000..ab30b7a --- /dev/null +++ b/contrib/README @@ -0,0 +1,3 @@ +This directory contains patches or programs contributed by others +which are either not yet integrated into ccollect or may be kept +seperated generally. From c9439be432e791d7e0389ca3bdfdcf214bfdf958 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 21 Jun 2009 00:50:04 +0200 Subject: [PATCH 328/581] add automatic backup manager CREDITS Signed-off-by: Nico Schottelius --- CREDITS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CREDITS b/CREDITS index 2b315a5..aac73e2 100644 --- a/CREDITS +++ b/CREDITS @@ -6,6 +6,8 @@ Thanks go to the following people (sorted by alphabet): - for testing and debugging (those I mean should know ;-) * Daniel Aubry - for reporting many hints +* Jens-Christoph Brendel + - Added automatic backup manager (contrib/jbrendel-autobackup) * John Lawless - A lot of patches and some very interesting discussions. * Markus Meier From 142fd24fc8f5efdcd2afe644a898731e0da7e839 Mon Sep 17 00:00:00 2001 From: jll2 Date: Mon, 22 Jun 2009 12:54:06 -0700 Subject: [PATCH 329/581] Add ARM to GNU/Linux architecture list I run ccollect nightly on a Thecus N2100 running Debian-ARM. The Linksys NSLU2 also runs an ARM processor and I have lightly tested ccollect on that under SlugOS. --- doc/ccollect.text | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 124f060..f1451f8 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -21,7 +21,7 @@ Supported and tested operating systems and architectures ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `ccollect` was successfully tested on the following platforms: -- GNU/Linux on amd64/hppa/i386/ppc +- GNU/Linux on amd64/hppa/i386/ppc/ARM - FreeBSD on amd64/i386 - Mac OS X 10.5 - NetBSD on alpha/amd64/i386/sparc/sparc64 From 64b5ae8b038962b52626683022074bfe05017ca6 Mon Sep 17 00:00:00 2001 From: jll2 Date: Sun, 14 Jun 2009 19:19:30 -0700 Subject: [PATCH 330/581] Defensive programming patch: "set -u" was added to make sure that there will never be misspelled or uninitialized variables in ccollect.sh. --- ccollect.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ccollect.sh b/ccollect.sh index d6831bc..ae64b70 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -20,6 +20,9 @@ # Initially written for SyGroup (www.sygroup.ch) # Date: Mon Nov 14 11:45:11 CET 2005 +# Error upon expanding unset variables: +set -u + # # Standard variables (stolen from cconf) # From 544a7d269ec9d4546b03879b18bab7180636a3e8 Mon Sep 17 00:00:00 2001 From: jll2 Date: Wed, 24 Jun 2009 17:01:14 -0700 Subject: [PATCH 331/581] Create rsync_failure_codes option. User may optionally create a file rsync_failure_codes with a newline-separated list of rsync return codes that are to be regarded as complete failure. If rsync exits with such a code, then the backup will be marked for deletion during the next ccollect run (if delete_incomplete). I added documentation for this feature in doc/ccollect.text In my experience (yours may differ), two rsync exit codes that belong in this file are 12 and 255. I have seen 12 result from ssh errors and 255 result from a kernel module conflict. In both cases, the resulting backups were empty. Without the rsync_failure_codes option, such errors cause good backups to be deleted, as per c_interval, leaving behind the new empty backups. In the long run, we may want a different and more comprehensive method for analyzing rsync errors. In the short run, I find this option necessary. --- ccollect.sh | 36 ++++++++++++++++++++++++++---------- doc/ccollect.text | 10 ++++++++++ 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index d6831bc..2b67ba7 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -281,7 +281,8 @@ while [ "${i}" -lt "${no_sources}" ]; do c_dest="${backup}/destination" c_pre_exec="${backup}/pre_exec" c_post_exec="${backup}/post_exec" - for opt in exclude verbose very_verbose rsync_options summary delete_incomplete remote_host ; do + for opt in exclude verbose very_verbose rsync_options summary delete_incomplete \ + remote_host rsync_failure_codes ; do if [ -f "${backup}/$opt" -o -f "${backup}/no_$opt" ]; then eval c_$opt=\"${backup}/$opt\" else @@ -530,16 +531,31 @@ while [ "${i}" -lt "${no_sources}" ]; do _techo "Transferring files..." rsync "$@" "${source}" "${destination_full}"; ret=$? - - # - # remove marking here - # - pcmd rm "${destination_dir}.${c_marker}" || \ - _exit_err "Removing ${destination_dir}/${c_marker} failed." - _techo "Finished backup (rsync return code: $ret)." - if [ "${ret}" -ne 0 ]; then - _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." + + # + # Check if rsync exit code indicates failure. + # + fail="" + if [ -f "$c_rsync_failure_codes" ]; then + while read code ; do + if [ "$ret" = "$code" ]; then + fail=1 + fi + done <"$c_rsync_failure_codes" + fi + + # + # Remove marking here unless rsync failed. + # + if [ -z "$fail" ]; then + pcmd rm "${destination_dir}.${c_marker}" || \ + _exit_err "Removing ${destination_dir}/${c_marker} failed." + if [ "${ret}" -ne 0 ]; then + _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." + fi + else + _techo "Warning: rsync failed with return code $ret." fi # diff --git a/doc/ccollect.text b/doc/ccollect.text index f1451f8..3d9c480 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -359,6 +359,7 @@ Additionally a source may have the following files: - `delete_incomplete` delete incomplete backups - `remote_host` host to backup to + - `rsync_failure_codes` list of rsync exit codes that indicate complete failure Example: @@ -574,6 +575,15 @@ If you create the file `delete_incomplete` in a source specification directory, was interrupted) and remove them. Without this file `ccollect` will only warn the user. +Detailed description of "rsync_failure_codes" +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +If you have the file `rsync_failure_codes` in your source configuration +directory, it should contain a newline-separated list of numbers representing +rsync exit codes. If rsync exits with any code in this list, a marker will +be left in the destination directory indicating failure of this backup. If +you have enabled delete_incomplete, then this backup will be deleted during +the next ccollect run on the same interval. + Hints ----- From 97df2c14dec483d54e21cf77e8aadc9a7d9b6e87 Mon Sep 17 00:00:00 2001 From: jll2 Date: Thu, 25 Jun 2009 16:20:00 -0700 Subject: [PATCH 332/581] Update the destination directory's mtime with each backup. After rsync, the destination directory's mtime reflects the modification time of its immediate contents. This patch overrides that and sets the mtime to the time that the backup finished. With this patch, the age of a backup can be assessed by looking at its mtime. The advantages of this are (1) that mtime can be preserved, via cp -a or rsync -a, when copying a backup repository to a new hard disk or a new machine and (2) that incorrect mtimes, such as might happen after a user meddles with his backup repository, can be, via touch, corrected. The disadvantage is that mtime for the immediate contents of the destination directory is lost. --- ccollect.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ccollect.sh b/ccollect.sh index bb8549b..7f5ae67 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -536,6 +536,11 @@ while [ "${i}" -lt "${no_sources}" ]; do rsync "$@" "${source}" "${destination_full}"; ret=$? _techo "Finished backup (rsync return code: $ret)." + # + # Set modification time (mtime) to current time + # + pcmd touch "${destination_dir}" + # # Check if rsync exit code indicates failure. # From 010449bafad648f1df3d36481f891bc00c31640c Mon Sep 17 00:00:00 2001 From: jll2 Date: Thu, 25 Jun 2009 20:35:13 -0700 Subject: [PATCH 333/581] Add option to sort backup directories based on modification time. By default, ccollect.sh sorts backup directories based on last change time (ctime). This adds the option to sort based on modification time (mtime). I have updated doc/ccollect.text but it needs some work to simplify and explain the issue. --- ccollect.sh | 12 ++++++++---- doc/ccollect.text | 13 +++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 7f5ae67..7c41352 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -285,7 +285,7 @@ while [ "${i}" -lt "${no_sources}" ]; do c_pre_exec="${backup}/pre_exec" c_post_exec="${backup}/post_exec" for opt in exclude verbose very_verbose rsync_options summary delete_incomplete \ - remote_host rsync_failure_codes ; do + remote_host rsync_failure_codes mtime ; do if [ -f "${backup}/$opt" -o -f "${backup}/no_$opt" ]; then eval c_$opt=\"${backup}/$opt\" else @@ -293,6 +293,13 @@ while [ "${i}" -lt "${no_sources}" ]; do fi done + # + # With mtime option, sort backup directories with mtime (default is ctime) + # + if [ -f "$c_mtime" ] ; then + TSORT="t" + fi + # # Marking backups: If we abort it's not removed => Backup is broken # @@ -496,9 +503,6 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Check for backup directory to clone from: Always clone from the latest one! # - # Use ls -1c instead of -1t, because last modification maybe the same on all - # and metadate update (-c) is updated by rsync locally. - # last_dir="$(pcmd ls -${TSORT}p1 "${ddir}" | grep '/$' | head -n 1)" || \ _exit_err "Failed to list contents of ${ddir}." diff --git a/doc/ccollect.text b/doc/ccollect.text index 3d9c480..9781387 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -360,6 +360,7 @@ Additionally a source may have the following files: - `delete_incomplete` delete incomplete backups - `remote_host` host to backup to - `rsync_failure_codes` list of rsync exit codes that indicate complete failure + - `mtime` Sort backup directories based on their modification time Example: @@ -584,6 +585,18 @@ be left in the destination directory indicating failure of this backup. If you have enabled delete_incomplete, then this backup will be deleted during the next ccollect run on the same interval. +mtime +^^^^^ +By default, ccollect.sh chooses the most recent backup directory for cloning or +the oldest for deletion based on the directory's last change time (ctime). +With this option, the sorting is done based on modification time (mtime). With +this version of ccollect.sh, the ctime and mtime of your backups will normally +be the same and this option has no effect. However, if you, for example, move +your backups to another hard disk using cp -a or rsync -a, you should use this +option because the ctimes are not preserved during such operations. + +If you have any backups in your repository made with ccollect version 0.7.1 or +earlier, do not use this option and do not move your repository. Hints ----- From dd7a0474088402f92a9de89f375718d4886f6245 Mon Sep 17 00:00:00 2001 From: jll2 Date: Thu, 25 Jun 2009 21:34:42 -0700 Subject: [PATCH 334/581] Add option quiet_if_down. If a source is not connectable, ccollect.sh issues a series of error messages such as: $ ccollect.sh "int 1" dummy 2009-06-25-21:04:14: ccollect 0.7.1: Beginning backup using interval int 1 [dummy] 2009-06-25-21:04:14: Beginning to backup [dummy] ssh: connect to host Ha port 20: No route to host [dummy] rsync: connection unexpectedly closed (0 bytes received so far) [receiver] [dummy] rsync error: unexplained error (code 255) at io.c(600) [receiver=3.0.5] [dummy] 2009-06-25-21:04:17: Error: source Ha:/tmp is not readable. Skipping. 2009-06-25-21:04:17: Finished If you expect the source to be up, you want to see these messages. However, for a notebook computer or other portable machine, it may be normal for it to be disconnected. If quiet_if_down is specified for that source, then the ssh and rsync errors are suppressed and the "Error:" prefix is removed from the "skipping" message: $ ccollect.sh "int 1" dummy 2009-06-25-21:03:33: ccollect 0.7.1: Beginning backup using interval int 1 [dummy] 2009-06-25-21:03:34: Beginning to backup [dummy] 2009-06-25-21:03:37: Source Ha:/tmp is not readable. Skipping. 2009-06-25-21:03:37: Finished I considered the alternative implementation of adding the logic to ccollect_analyse_logs.sh to enable it to separate rsync messages generated the initial connection test from messages generated by rsync used for an actual backup data transfer. Adding this approach to ccollect.sh appeared much simpler. --- ccollect.sh | 11 +++++++++-- doc/ccollect.text | 15 ++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 7c41352..59a0b02 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -285,7 +285,7 @@ while [ "${i}" -lt "${no_sources}" ]; do c_pre_exec="${backup}/pre_exec" c_post_exec="${backup}/post_exec" for opt in exclude verbose very_verbose rsync_options summary delete_incomplete \ - remote_host rsync_failure_codes mtime ; do + remote_host rsync_failure_codes mtime quiet_if_down ; do if [ -f "${backup}/$opt" -o -f "${backup}/no_$opt" ]; then eval c_$opt=\"${backup}/$opt\" else @@ -368,7 +368,14 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Verify source is up and accepting connections before deleting any old backups # - rsync "${source}" >/dev/null || _exit_err "Source ${source} is not readable. Skipping." + if ! rsync "${source}" >/dev/null 2>"${TMP}" ; then + if [ -f "${c_quiet_if_down}" ]; then + _exit_err "Source ${source} is not readable. Skipping." + else + cat "${TMP}" + _exit_err "Error: source ${source} is not readable. Skipping." + fi + fi # # Destination is a path diff --git a/doc/ccollect.text b/doc/ccollect.text index 9781387..9a76837 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -361,6 +361,7 @@ Additionally a source may have the following files: - `remote_host` host to backup to - `rsync_failure_codes` list of rsync exit codes that indicate complete failure - `mtime` Sort backup directories based on their modification time + - `quiet_if_down` Suppress error messages if source is not connectable Example: @@ -585,8 +586,8 @@ be left in the destination directory indicating failure of this backup. If you have enabled delete_incomplete, then this backup will be deleted during the next ccollect run on the same interval. -mtime -^^^^^ +Detailed description of "mtime" +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ By default, ccollect.sh chooses the most recent backup directory for cloning or the oldest for deletion based on the directory's last change time (ctime). With this option, the sorting is done based on modification time (mtime). With @@ -596,7 +597,15 @@ your backups to another hard disk using cp -a or rsync -a, you should use this option because the ctimes are not preserved during such operations. If you have any backups in your repository made with ccollect version 0.7.1 or -earlier, do not use this option and do not move your repository. +earlier, do not use this option. + +Detailed description of "quiet_if_down" +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +By default, ccollect.sh emits a series of error messages if a source is not +connectable. With this option enabled, ccollect.sh still reports that the +source is not connectable but the associated error messages generated by +rsync or ssh are suppressed. You may want to use this option for sources, +like notebook PCs, that are often disconnected. Hints ----- From 0b064e0565191015249dbd5a5f3a2cd057ecdeae Mon Sep 17 00:00:00 2001 From: jll2 Date: Fri, 26 Jun 2009 14:09:21 -0700 Subject: [PATCH 335/581] Beautify: remove trailing white space. If your editor does not highlight trailing white space, you won't see a difference. --- ccollect.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 59a0b02..e842053 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -1,19 +1,19 @@ #!/bin/sh -# +# # 2005-2009 Nico Schottelius (nico-ccollect at schottelius.org) -# +# # This file is part of ccollect. # # ccollect is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. -# +# # ccollect is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with ccollect. If not, see . # @@ -163,7 +163,7 @@ while [ "$#" -ge 1 ]; do if [ "${NO_MORE_ARGS}" = 1 ]; then eval source_${no_sources}=\"${arg}\" no_sources=$((${no_sources}+1)) - + # make variable available for subscripts eval export source_${no_sources} else @@ -415,13 +415,13 @@ while [ "${i}" -lt "${no_sources}" ]; do # - insert ccollect default parameters # - insert options # - insert user options - + # # rsync standard options # set -- "$@" "--archive" "--delete" "--numeric-ids" "--relative" \ - "--delete-excluded" "--sparse" + "--delete-excluded" "--sparse" # # exclude list @@ -480,7 +480,7 @@ while [ "${i}" -lt "${no_sources}" ]; do | sed 's/^ *//g')" || _exit_err "Counting backups failed" _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" - + if [ "${count}" -ge "${c_interval}" ]; then substract=$((${c_interval} - 1)) remove=$((${count} - ${substract})) @@ -512,7 +512,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # last_dir="$(pcmd ls -${TSORT}p1 "${ddir}" | grep '/$' | head -n 1)" || \ _exit_err "Failed to list contents of ${ddir}." - + # # clone from old backup, if existing # @@ -520,7 +520,7 @@ while [ "${i}" -lt "${no_sources}" ]; do set -- "$@" "--link-dest=${ddir}/${last_dir}" _techo "Hard linking from ${last_dir}" fi - + # set time when we really begin to backup, not when we began to remove above destination_date=$(${CDATE}) From 76e6094247ee4ca08111f631c000a03cb2d993e5 Mon Sep 17 00:00:00 2001 From: jll2 Date: Fri, 26 Jun 2009 14:42:45 -0700 Subject: [PATCH 336/581] Simplify interval code. Eight lines and two variables are removed which makes the code, I think, easier to read. The main motivation for this change, however, is that it makes ccollect.sh more friendly to (future) auto interval selection. The removed lines and variables assumed that the interval was known prior to the start of the source loop. With auto interval selection, the selected interval can be different for each source. --- ccollect.sh | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index e842053..65e10d9 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -237,14 +237,6 @@ if [ -x "${CPREEXEC}" ]; then [ "${ret}" -eq 0 ] || _exit_err "${CPREEXEC} failed. Aborting" fi -# -# check default configuration -# - -D_FILE_INTERVAL="${CDEFAULTS}/intervals/${INTERVAL}" -D_INTERVAL=$(cat "${D_FILE_INTERVAL}" 2>/dev/null) - - # # Let's do the backup # @@ -346,7 +338,7 @@ while [ "${i}" -lt "${no_sources}" ]; do c_interval="$(cat "${backup}/intervals/${INTERVAL}" 2>/dev/null)" if [ -z "${c_interval}" ]; then - c_interval="${D_INTERVAL}" + c_interval="$(cat "${CDEFAULTS}/intervals/${INTERVAL}" 2>/dev/null)" if [ -z "${c_interval}" ]; then _exit_err "No definition for interval \"${INTERVAL}\" found. Skipping." From 72830a4647188d34da7656ea2d166347c57333e2 Mon Sep 17 00:00:00 2001 From: jll2 Date: Fri, 26 Jun 2009 14:54:28 -0700 Subject: [PATCH 337/581] If the user specifies "delete_incomplete", this patch makes it so all incomplete backups are deleted, not just the ones with the particular interval that the user specified. The advantage of this is that those to-be-deleted incomplete backups will not interfere with calculations required for automatic interval selection. --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index 65e10d9..71c032b 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -452,7 +452,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Check for incomplete backups # - pcmd ls -1 "$ddir/${INTERVAL}"*".${c_marker}" 2>/dev/null | while read marker; do + pcmd ls -1 "${ddir}/"*".${c_marker}" 2>/dev/null | while read marker; do incomplete="$(echo ${marker} | sed "s/\\.${c_marker}\$//")" _techo "Incomplete backup: ${incomplete}" if [ -f "${c_delete_incomplete}" ]; then From 6fd22b641697ecbbb0bbfc1eab1301836f44c191 Mon Sep 17 00:00:00 2001 From: jll2 Date: Fri, 26 Jun 2009 15:22:09 -0700 Subject: [PATCH 338/581] Move "interval definition section". The interval definition section was down to just before the maximum backup check. This makes the code more friendly to automatic interval selection. Auto interval selection needs to have ddir defined first and it is best if it is done after delete_incomplete. This change accomplishes that while still placing it before the maximum backup check which needs to know the interval. --- ccollect.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 71c032b..a61af21 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -332,19 +332,6 @@ while [ "${i}" -lt "${no_sources}" ]; do fi fi - # - # interval definition: First try source specific, fallback to default - # - c_interval="$(cat "${backup}/intervals/${INTERVAL}" 2>/dev/null)" - - if [ -z "${c_interval}" ]; then - c_interval="$(cat "${CDEFAULTS}/intervals/${INTERVAL}" 2>/dev/null)" - - if [ -z "${c_interval}" ]; then - _exit_err "No definition for interval \"${INTERVAL}\" found. Skipping." - fi - fi - # # Source checks # @@ -464,6 +451,19 @@ while [ "${i}" -lt "${no_sources}" ]; do fi done + # + # interval definition: First try source specific, fallback to default + # + c_interval="$(cat "${backup}/intervals/${INTERVAL}" 2>/dev/null)" + + if [ -z "${c_interval}" ]; then + c_interval="$(cat "${CDEFAULTS}/intervals/${INTERVAL}" 2>/dev/null)" + + if [ -z "${c_interval}" ]; then + _exit_err "No definition for interval \"${INTERVAL}\" found. Skipping." + fi + fi + # # check if maximum number of backups is reached, if so remove # use grep and ls -p so we only look at directories From 194148b5b3b2cb7fea39003c399abdfbe13733db Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 1 Jul 2009 10:00:18 +0200 Subject: [PATCH 339/581] update url of homepage Signed-off-by: Nico Schottelius --- Makefile | 4 ++-- README | 2 +- ccollect.sh | 3 ++- doc/ccollect.text | 6 +++--- doc/changes/next | 1 + doc/man/ccollect.text | 2 +- doc/man/ccollect_add_source.text | 2 +- doc/man/ccollect_analyse_logs.text | 2 +- doc/man/ccollect_delete_source.text | 2 +- doc/man/ccollect_list_intervals.text | 2 +- doc/man/ccollect_logwrapper.text | 2 +- release.sh | 6 ++++-- 12 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index cfafa7a..8f7f688 100644 --- a/Makefile +++ b/Makefile @@ -43,8 +43,8 @@ path_dir=/usr/local/bin path_destination=${path_dir}/${CCOLLECT_DEST} # where to publish -host=home.schottelius.org -dir=/home/server/www/nico/unix.schottelius.org/www/ccollect/ +host=localhost +dir=/home/users/nico/privat/computer/net/netzseiten/www.nico.schottelius.org/src/software/ccollect docdir=${dir}/doc # diff --git a/README b/README index 401d778..5b63396 100644 --- a/README +++ b/README @@ -60,6 +60,6 @@ doc/man/ccollect.text Manpage in text format doc/man/ccollect.man Manpage in manpage format (generated) -------------------------------------------------------------------------------- -[0]: ccollect: http://unix.schottelius.org/ccollect/ +[0]: ccollect: http://www.nico.schottelius.org/software/ccollect/ [1]: rsnapshot: http://www.rsnapshot.org/ [2]: cconfig: http://nico.schotteli.us/papers/linux/cconfig/ diff --git a/ccollect.sh b/ccollect.sh index ae64b70..0dc7e9d 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -123,13 +123,14 @@ usage() echo " This is version ${VERSION}, released on ${RELEASE}" echo " (the first version was written on 2005-12-05 by Nico Schottelius)." echo "" - echo " Retrieve latest ccollect at http://unix.schottelius.org/ccollect/" + echo " Retrieve latest ccollect at http://www.nico.schottelius.org/software/ccollect/" exit 0 } # # need at least interval and one source or --all # + if [ $# -lt 2 ]; then if [ "$1" = "-V" -o "$1" = "--version" ]; then display_version diff --git a/doc/ccollect.text b/doc/ccollect.text index 124f060..29d7784 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -139,7 +139,7 @@ Quick start For those who do not want to read the whole long document: -------------------------------------------------------------------------------- -# get latest ccollect tarball from http://unix.schottelius.org/ccollect/ +# get latest ccollect tarball from http://www.nico.schottelius.org/software/ccollect/ # replace value for CCV with the current version export CCV=0.7.1 @@ -147,7 +147,7 @@ export CCV=0.7.1 # replace 'wget' with 'fetch' on bsd # holen=wget -"$holen" http://unix.schottelius.org/ccollect/ccollect-${CCV}.tar.bz2 +"$holen" http://www.nico.schottelius.org/software/ccollect/ccollect-${CCV}.tar.bz2 # extract the tarball, change to the newly created directory tar -xvjf ccollect-${CCV}.tar.bz2 @@ -212,7 +212,7 @@ Installing ccollect ~~~~~~~~~~~~~~~~~~~ For the installation you need at least - - the latest ccollect package (http://unix.schottelius.org/ccollect/) + - the latest ccollect package (http://www.nico.schottelius.org/software/ccollect/) - either `cp` and `chmod` or `install` - for more comfort: `make` - for rebuilding the generated documentation: additionally `asciidoc` diff --git a/doc/changes/next b/doc/changes/next index 0d7bd1f..8ce7b86 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -1,2 +1,3 @@ * Introduce consistenst time sorting (John Lawless) * Check for source connectivity before trying backup (John Lawless) +* Defensive programming patch (John Lawless) diff --git a/doc/man/ccollect.text b/doc/man/ccollect.text index d824717..84e95bb 100644 --- a/doc/man/ccollect.text +++ b/doc/man/ccollect.text @@ -52,7 +52,7 @@ Nico Schottelius RESOURCES --------- -Main web site: http://unix.schottelius.org/ccollect/[] +Main web site: http://www.nico.schottelius.org/software/ccollect/[] COPYING diff --git a/doc/man/ccollect_add_source.text b/doc/man/ccollect_add_source.text index 25e58a3..e3b9f83 100644 --- a/doc/man/ccollect_add_source.text +++ b/doc/man/ccollect_add_source.text @@ -66,7 +66,7 @@ Nico Schottelius RESOURCES --------- -Main web site: http://unix.schottelius.org/ccollect/[] +Main web site: http://www.nico.schottelius.org/software/ccollect/[] COPYING diff --git a/doc/man/ccollect_analyse_logs.text b/doc/man/ccollect_analyse_logs.text index 2638014..659ddbf 100644 --- a/doc/man/ccollect_analyse_logs.text +++ b/doc/man/ccollect_analyse_logs.text @@ -47,7 +47,7 @@ Nico Schottelius RESOURCES --------- -Main web site: http://unix.schottelius.org/ccollect/[] +Main web site: http://www.nico.schottelius.org/software/ccollect/[] COPYING diff --git a/doc/man/ccollect_delete_source.text b/doc/man/ccollect_delete_source.text index 9656271..2b7f300 100644 --- a/doc/man/ccollect_delete_source.text +++ b/doc/man/ccollect_delete_source.text @@ -48,7 +48,7 @@ Nico Schottelius RESOURCES --------- -Main web site: http://unix.schottelius.org/ccollect/[] +Main web site: http://www.nico.schottelius.org/software/ccollect/[] COPYING diff --git a/doc/man/ccollect_list_intervals.text b/doc/man/ccollect_list_intervals.text index 051b087..9df4121 100644 --- a/doc/man/ccollect_list_intervals.text +++ b/doc/man/ccollect_list_intervals.text @@ -39,7 +39,7 @@ Nico Schottelius RESOURCES --------- -Main web site: http://unix.schottelius.org/ccollect/[] +Main web site: http://www.nico.schottelius.org/software/ccollect/[] COPYING diff --git a/doc/man/ccollect_logwrapper.text b/doc/man/ccollect_logwrapper.text index ce1c5f6..8084c10 100644 --- a/doc/man/ccollect_logwrapper.text +++ b/doc/man/ccollect_logwrapper.text @@ -47,7 +47,7 @@ Nico Schottelius RESOURCES --------- -Main web site: http://unix.schottelius.org/ccollect/[] +Main web site: http://www.nico.schottelius.org/software/ccollect/[] COPYING diff --git a/release.sh b/release.sh index 976a5c4..ae095ec 100755 --- a/release.sh +++ b/release.sh @@ -33,8 +33,10 @@ DESCRIPTION="$1"; shift NAME=ccollect-${VERSION} TARNAME=${NAME}.tar.bz2 TARLOCAL=../${TARNAME} -DHOST=nico@home.schottelius.org -DDIR=www/unix.schottelius.org/www/ccollect/ +#DHOST=nico@home.schottelius.org +DHOST=nico@localhost +#DDIR=www/unix.schottelius.org/www/ccollect/ +DDIR=/home/users/nico/privat/computer/net/netzseiten/www.nico.schottelius.org/src/software/ccollect DESTINATION="$DHOST:$DDIR" set -e From de6a7893fca68f870b5592450173994f4690c04e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 1 Jul 2009 10:03:00 +0200 Subject: [PATCH 340/581] [DOC] Move German documentation to old/ (unmaintained) Signed-off-by: Nico Schottelius --- Makefile | 2 +- doc/old/README | 1 + doc/{ => old}/ccollect-DE.text | 0 3 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 doc/old/README rename doc/{ => old}/ccollect-DE.text (100%) diff --git a/Makefile b/Makefile index 8f7f688..0f8a8d1 100644 --- a/Makefile +++ b/Makefile @@ -57,7 +57,7 @@ MANDOCS = doc/man/ccollect.text \ doc/man/ccollect_logwrapper.text \ doc/man/ccollect_list_intervals.text -DOCS = ${MANDOCS} doc/ccollect.text doc/ccollect-DE.text +DOCS = ${MANDOCS} doc/ccollect.text # # Doku diff --git a/doc/old/README b/doc/old/README new file mode 100644 index 0000000..56d0964 --- /dev/null +++ b/doc/old/README @@ -0,0 +1 @@ +ccollect-DE.text is not maintained anymore (no feedback from author). diff --git a/doc/ccollect-DE.text b/doc/old/ccollect-DE.text similarity index 100% rename from doc/ccollect-DE.text rename to doc/old/ccollect-DE.text From ca1231a576e91a9db3f7e7afc613531fc53b201e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 1 Jul 2009 12:03:40 +0200 Subject: [PATCH 341/581] begin to implement new style option parsing Signed-off-by: Nico Schottelius --- ccollect.sh | 115 +++++++++++++++++++++++----------------------------- 1 file changed, 51 insertions(+), 64 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 0dc7e9d..7c04f0b 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -40,8 +40,8 @@ CPREEXEC="${CDEFAULTS}/pre_exec" CPOSTEXEC="${CDEFAULTS}/post_exec" TMP=$(mktemp "/tmp/${__myname}.XXXXXX") -VERSION=0.7.1 -RELEASE="2009-02-02" +VERSION=0.8 +RELEASE="2009-XX-XX" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" @@ -55,9 +55,13 @@ DDATE="date +%Y-%m-%d-%H:%M:%S" TSORT="tc" # -# unset parallel execution +# unset values # PARALLEL="" +USE_ALL="" +export INTERVAL="" +export no_sources=0 + # # catch signals @@ -87,6 +91,9 @@ add_name() awk "{ print \"[${name}] \" \$0 }" } +# +# Execute on remote host, if backing up to a remote host +# pcmd() { if [ "$remote_host" ]; then @@ -96,21 +103,15 @@ pcmd() fi } -# -# Version -# display_version() { echo "${FULL_VERSION}" exit 0 } -# -# Tell how to use us -# usage() { - echo "${__myname}: [args] " + echo "${__myname}: [args] " echo "" echo " ccollect creates (pseudo) incremental backups" echo "" @@ -128,16 +129,38 @@ usage() } # -# need at least interval and one source or --all +# Parse options # +while [ "$#" -ge 1 ]; do + case "$1" in + -a|--all) + USE_ALL=1 + ;; + -v|--verbose) + set -x + ;; + -p|--parallel) + PARALLEL=1 + ;; + -h|--help) + usage + ;; + -V|--version) + display_version + ;; + -h|--help|-*) + usage + ;; + --) + break + ;; + *) + break + ;; + esac + shift +done -if [ $# -lt 2 ]; then - if [ "$1" = "-V" -o "$1" = "--version" ]; then - display_version - else - usage - fi -fi # # check for configuraton directory @@ -146,68 +169,32 @@ fi "\"${CCOLLECT_CONF}\" (is \$CCOLLECT_CONF properly set?)" # -# Filter arguments +# Capture sources in an "array" # -export INTERVAL="$1"; shift -i=1 -no_sources=0 - -# -# Capture options and create source "array" -# -WE="" -ALL="" -NO_MORE_ARGS="" while [ "$#" -ge 1 ]; do eval arg=\"\$1\"; shift - if [ "${NO_MORE_ARGS}" = 1 ]; then + if [ -z "$INTERVAL" ]; then + INTERVAL="$arg" + else eval source_${no_sources}=\"${arg}\" - no_sources=$((${no_sources}+1)) + no_sources="$((${no_sources}+1))" # make variable available for subscripts eval export source_${no_sources} - else - case "${arg}" in - -a|--all) - ALL=1 - ;; - -v|--verbose) - set -x - ;; - -p|--parallel) - PARALLEL=1 - ;; - -h|--help) - usage - ;; - --) - NO_MORE_ARGS=1 - ;; - *) - eval source_${no_sources}=\"$arg\" - no_sources=$(($no_sources+1)) - ;; - esac fi - - i=$(($i+1)) done -# also export number of sources -export no_sources - # # Look, if we should take ALL sources # -if [ "${ALL}" = 1 ]; then - # reset everything specified before - no_sources=0 +if [ "${USE_ALL}" = 1 ]; then + no_sources="0" # # get entries from sources # - cwd=$(pwd -P) + cwd="$(pwd -P)" ( cd "${CSOURCES}" && ls > "${TMP}" ); ret=$? [ "${ret}" -eq 0 ] || _exit_err "Listing of sources failed. Aborting." @@ -221,7 +208,7 @@ fi # # Need at least ONE source to backup # -if [ "${no_sources}" -lt 1 ]; then +if [ "${no_sources}" -lt 1 -o -z "${INTERVAL}" ]; then usage else _techo "${HALF_VERSION}: Beginning backup using interval ${INTERVAL}" @@ -595,4 +582,4 @@ if [ -x "${CPOSTEXEC}" ]; then fi rm -f "${TMP}" -_techo "Finished ${WE}" +_techo "Finished" From bd1e365ca08f79c33dda0aba3568082657fcee19 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 1 Jul 2009 12:42:32 +0200 Subject: [PATCH 342/581] replace multiple echos with one cat Signed-off-by: Nico Schottelius --- ccollect.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 7c04f0b..ddfd878 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -111,20 +111,22 @@ display_version() usage() { - echo "${__myname}: [args] " - echo "" - echo " ccollect creates (pseudo) incremental backups" - echo "" - echo " -h, --help: Show this help screen" - echo " -p, --parallel: Parallelise backup processes" - echo " -a, --all: Backup all sources specified in ${CSOURCES}" - echo " -v, --verbose: Be very verbose (uses set -x)" - echo " -V, --version: Print version information" - echo "" - echo " This is version ${VERSION}, released on ${RELEASE}" - echo " (the first version was written on 2005-12-05 by Nico Schottelius)." - echo "" - echo " Retrieve latest ccollect at http://www.nico.schottelius.org/software/ccollect/" + cat << eof +${__myname}: [args] + + ccollect creates (pseudo) incremental backups + + -h, --help: Show this help screen + -p, --parallel: Parallelise backup processes + -a, --all: Backup all sources specified in ${CSOURCES} + -v, --verbose: Be very verbose (uses set -x) + -V, --version: Print version information + + This is version ${VERSION}, released on ${RELEASE} + (the first version was written on 2005-12-05 by Nico Schottelius). + + Retrieve latest ccollect at http://www.nico.schottelius.org/software/ccollect/ +eof exit 0 } From 65a7badd4d9889964921382321e92a41830edb27 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 1 Jul 2009 12:43:22 +0200 Subject: [PATCH 343/581] changes for the next version Signed-off-by: Nico Schottelius --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changes/next b/doc/changes/next index 8ce7b86..1339a98 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -1,3 +1,4 @@ * Introduce consistenst time sorting (John Lawless) * Check for source connectivity before trying backup (John Lawless) * Defensive programming patch (John Lawless) +* Some code cleanups (argument parsing, usage) (Nico Schottelius) From a9aad1ed8f374d544d78dc411d4d837524b78bd1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 1 Jul 2009 17:08:59 +0200 Subject: [PATCH 344/581] correct indent Signed-off-by: Nico Schottelius --- ccollect.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index ddfd878..10c50f8 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -179,12 +179,12 @@ while [ "$#" -ge 1 ]; do if [ -z "$INTERVAL" ]; then INTERVAL="$arg" else - eval source_${no_sources}=\"${arg}\" - no_sources="$((${no_sources}+1))" - - # make variable available for subscripts - eval export source_${no_sources} - fi + eval source_${no_sources}=\"${arg}\" + no_sources="$((${no_sources}+1))" + + # make variable available for subscripts + eval export source_${no_sources} +fi done # From 09ed55a17e62ea6e3a6e277f172357e069f89a7c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 1 Jul 2009 17:09:30 +0200 Subject: [PATCH 345/581] only consider directories as sources Signed-off-by: Nico Schottelius --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index 10c50f8..8523d3a 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -197,7 +197,7 @@ if [ "${USE_ALL}" = 1 ]; then # get entries from sources # cwd="$(pwd -P)" - ( cd "${CSOURCES}" && ls > "${TMP}" ); ret=$? + ( cd "${CSOURCES}" && ls -p1 > "${TMP}" | grep '/$' ); ret=$? [ "${ret}" -eq 0 ] || _exit_err "Listing of sources failed. Aborting." From 31ef31801ee8462f22ac9800777e911ca48c1fbb Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 1 Jul 2009 18:03:51 +0200 Subject: [PATCH 346/581] only consider directories as sources Signed-off-by: Nico Schottelius --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changes/next b/doc/changes/next index 1339a98..2e073f7 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -2,3 +2,4 @@ * Check for source connectivity before trying backup (John Lawless) * Defensive programming patch (John Lawless) * Some code cleanups (argument parsing, usage) (Nico Schottelius) +* Only consider directories as sources when using -a (Nico Schottelius) From 5da5506c6509e4f65937a42f6ef0f8140804eba2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 1 Jul 2009 22:39:42 +0200 Subject: [PATCH 347/581] add quotes to every possible problematic variable, add braces Signed-off-by: Nico Schottelius --- ccollect.sh | 63 ++++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 8523d3a..ab77bbe 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -33,14 +33,14 @@ __myname=${0##*/}; __abs_myname="$__abs_mydir/$__myname" # # where to find our configuration and temporary file # -CCOLLECT_CONF=${CCOLLECT_CONF:-/etc/ccollect} -CSOURCES=${CCOLLECT_CONF}/sources -CDEFAULTS=${CCOLLECT_CONF}/defaults +CCOLLECT_CONF="${CCOLLECT_CONF:-/etc/ccollect}" +CSOURCES="${CCOLLECT_CONF}/sources" +CDEFAULTS="${CCOLLECT_CONF}/defaults" CPREEXEC="${CDEFAULTS}/pre_exec" CPOSTEXEC="${CDEFAULTS}/post_exec" TMP=$(mktemp "/tmp/${__myname}.XXXXXX") -VERSION=0.8 +VERSION="0.8" RELEASE="2009-XX-XX" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" @@ -96,8 +96,8 @@ add_name() # pcmd() { - if [ "$remote_host" ]; then - ssh "$remote_host" "$@" + if [ "${remote_host}" ]; then + ssh "${remote_host}" "$@" else "$@" fi @@ -232,7 +232,7 @@ fi # D_FILE_INTERVAL="${CDEFAULTS}/intervals/${INTERVAL}" -D_INTERVAL=$(cat "${D_FILE_INTERVAL}" 2>/dev/null) +D_INTERVAL="$(cat "${D_FILE_INTERVAL}" 2>/dev/null)" # @@ -275,7 +275,7 @@ while [ "${i}" -lt "${no_sources}" ]; do c_pre_exec="${backup}/pre_exec" c_post_exec="${backup}/post_exec" for opt in exclude verbose very_verbose rsync_options summary delete_incomplete remote_host ; do - if [ -f "${backup}/$opt" -o -f "${backup}/no_$opt" ]; then + if [ -f "${backup}/${opt}" -o -f "${backup}/no_${opt}" ]; then eval c_$opt=\"${backup}/$opt\" else eval c_$opt=\"${CDEFAULTS}/$opt\" @@ -290,7 +290,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Times # - begin_s=$(date +%s) + begin_s="$(date +%s)" _techo "Beginning to backup" @@ -309,8 +309,7 @@ while [ "${i}" -lt "${no_sources}" ]; do fi # - # first execute pre_exec, which may generate destination or other - # parameters + # first execute pre_exec, which may generate destination or other parameters # if [ -x "${c_pre_exec}" ]; then _techo "Executing ${c_pre_exec} ..." @@ -358,18 +357,17 @@ while [ "${i}" -lt "${no_sources}" ]; do if [ ! -f "${c_dest}" ]; then _exit_err "Destination ${c_dest} is not a file. Skipping." else - ddir=$(cat "${c_dest}"); ret="$?" + ddir="$(cat "${c_dest}")"; ret="$?" if [ "${ret}" -ne 0 ]; then _exit_err "Destination ${c_dest} is not readable. Skipping." fi fi # - # do we backup to a remote host? then set pre-cmd + # Set pre-cmd, if we backup to a remote host. # if [ -f "${c_remote_host}" ]; then - # adjust ls and co - remote_host=$(cat "${c_remote_host}"); ret="$?" + remote_host="$(cat "${c_remote_host}")"; ret="$?" if [ "${ret}" -ne 0 ]; then _exit_err "Remote host file ${c_remote_host} exists, but is not readable. Skipping." fi @@ -385,7 +383,6 @@ while [ "${i}" -lt "${no_sources}" ]; do # ( pcmd cd "$ddir" ) || _exit_err "Cannot change to ${ddir}. Skipping." - # NEW method as of 0.6: # - insert ccollect default parameters # - insert options @@ -394,7 +391,6 @@ while [ "${i}" -lt "${no_sources}" ]; do # # rsync standard options # - set -- "$@" "--archive" "--delete" "--numeric-ids" "--relative" \ "--delete-excluded" "--sparse" @@ -435,7 +431,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Check for incomplete backups # - pcmd ls -1 "$ddir/${INTERVAL}"*".${c_marker}" 2>/dev/null | while read marker; do + pcmd ls -1 "${ddir}/${INTERVAL}"*".${c_marker}" 2>/dev/null | while read marker; do incomplete="$(echo ${marker} | sed "s/\\.${c_marker}\$//")" _techo "Incomplete backup: ${incomplete}" if [ -f "${c_delete_incomplete}" ]; then @@ -457,31 +453,30 @@ while [ "${i}" -lt "${no_sources}" ]; do _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" if [ "${count}" -ge "${c_interval}" ]; then - substract=$((${c_interval} - 1)) - remove=$((${count} - ${substract})) + substract="$((${c_interval} - 1))" + remove="$((${count} - ${substract}))" _techo "Removing ${remove} backup(s)..." - pcmd ls -${TSORT}p1r "$ddir" | grep "^${INTERVAL}\..*/\$" | \ + pcmd ls -${TSORT}p1r "${ddir}" | grep "^${INTERVAL}\..*/\$" | \ head -n "${remove}" > "${TMP}" || \ _exit_err "Listing old backups failed" i=0 while read to_remove; do eval remove_$i=\"${to_remove}\" - i=$(($i+1)) + i="$(($i+1))" done < "${TMP}" j=0 - while [ "$j" -lt "$i" ]; do + while [ "${j}" -lt "${i}" ]; do eval to_remove=\"\$remove_$j\" _techo "Removing ${to_remove} ..." pcmd rm ${VVERBOSE} -rf "${ddir}/${to_remove}" || \ _exit_err "Removing ${to_remove} failed." - j=$(($j+1)) + j="$(($j+1))" done fi - # # Check for backup directory to clone from: Always clone from the latest one! # @@ -501,7 +496,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # set time when we really begin to backup, not when we began to remove above - destination_date=$(${CDATE}) + destination_date="$(${CDATE})" destination_dir="${ddir}/${INTERVAL}.${destination_date}.$$" destination_full="${destination}/${INTERVAL}.${destination_date}.$$" @@ -543,19 +538,19 @@ while [ "${i}" -lt "${no_sources}" ]; do "${c_post_exec}"; ret=$? _techo "Finished ${c_post_exec}." - if [ ${ret} -ne 0 ]; then + if [ "${ret}" -ne 0 ]; then _exit_err "${c_post_exec} failed." fi fi # Calculation - end_s=$(date +%s) + end_s="$(date +%s)" - full_seconds=$((${end_s} - ${begin_s})) - hours=$((${full_seconds} / 3600)) - seconds=$((${full_seconds} - (${hours} * 3600))) - minutes=$((${seconds} / 60)) - seconds=$((${seconds} - (${minutes} * 60))) + full_seconds="$((${end_s} - ${begin_s}))" + hours="$((${full_seconds} / 3600))" + seconds="$((${full_seconds} - (${hours} * 3600)))" + minutes="$((${seconds} / 60))" + seconds="$((${seconds} - (${minutes} * 60)))" _techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" @@ -578,7 +573,7 @@ if [ -x "${CPOSTEXEC}" ]; then "${CPOSTEXEC}"; ret=$? _techo "Finished ${CPOSTEXEC} (return code: ${ret})." - if [ ${ret} -ne 0 ]; then + if [ "${ret}" -ne 0 ]; then _techo "${CPOSTEXEC} failed." fi fi From 8423fa136f6e32c885ecc3b5a9c72f286316fc0d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 1 Jul 2009 22:42:08 +0200 Subject: [PATCH 348/581] remove hint on German documentation in README Signed-off-by: Nico Schottelius --- README | 3 --- 1 file changed, 3 deletions(-) diff --git a/README b/README index 5b63396..b1e46fd 100644 --- a/README +++ b/README @@ -53,9 +53,6 @@ Included documentation: doc/ccollect.text Manual in text format doc/ccollect.html Manual in xhtml (generated) -doc/ccollect-DE.text German manual in text format (externally maintained) -doc/ccollect-DE.html German manual in xhtml (generated) - doc/man/ccollect.text Manpage in text format doc/man/ccollect.man Manpage in manpage format (generated) From 19bc94a756116dae149014d37f97b0818890005c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 8 Jul 2009 16:08:08 +0200 Subject: [PATCH 349/581] [DOC] correct destination examples Thanks, D-Tick. Signed-off-by: Nico Schottelius --- doc/ccollect.text | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 29d7784..984cdcf 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -365,7 +365,7 @@ Example: -------------------------------------------------------------------------------- [10:47] zaphodbeeblebrox:ccollect-0.2% ls -l conf/sources/testsource2 insgesamt 12 - lrwxrwxrwx 1 nico users 20 2005-11-17 16:44 destination -> /home/nico/backupdir + lrwxrwxrwx 1 nico users 20 2005-11-17 16:44 destination -rw-r--r-- 1 nico users 62 2005-12-07 17:43 exclude drwxr-xr-x 2 nico users 4096 2005-12-07 17:38 intervals -rw-r--r-- 1 nico users 15 2005-11-17 16:44 source @@ -905,12 +905,12 @@ srwali01:~# cd /etc/ccollect/sources srwali01:/etc/ccollect/sources# mkdir windos-wl6 srwali01:/etc/ccollect/sources# cd windos-wl6/ srwali01:/etc/ccollect/sources/windos-wl6# echo /mnt/win/SYS/WL6 > source -srwali01:/etc/ccollect/sources/windos-wl6# ln -s /mnt/hdbackup/wl6 destination +srwali01:/etc/ccollect/sources/windos-wl6# echo /mnt/hdbackup/wl6 > destination srwali01:/etc/ccollect/sources/windos-wl6# mkdir /mnt/hdbackup/wl6 srwali01:/etc/ccollect/sources/windos-wl6# cd .. srwali01:/etc/ccollect/sources# mkdir windos-daten srwali01:/etc/ccollect/sources/windos-daten# echo /mnt/win/Daten > source -srwali01:/etc/ccollect/sources/windos-daten# ln -s /mnt/hdbackup/windos-daten destination +srwali01:/etc/ccollect/sources/windos-daten# echo /mnt/hdbackup/windos-daten > destination srwali01:/etc/ccollect/sources/windos-daten# mkdir /mnt/hdbackup/windos-daten # Now add some remote source From 017b80f59b6a874c6659c12cea54db35eba90a2d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 19 Jul 2009 19:29:06 +0200 Subject: [PATCH 350/581] more todo (thanks goes to D-Tick) Signed-off-by: Nico Schottelius --- doc/todo/extern | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/todo/extern b/doc/todo/extern index 9be8f2b..cb42a07 100644 --- a/doc/todo/extern +++ b/doc/todo/extern @@ -21,3 +21,6 @@ to have. This means I won't code them, so somebody can code them. x intervalls x pre-/post exec o (X)dialog based + +- add option ("run_only_once") to prevent ccollect to run twice + (per source/general) From 3ea39547a70b76aae340e26113966bc0a2c9f96f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 23 Jul 2009 17:29:21 +0200 Subject: [PATCH 351/581] cleanup example conf/ directory Signed-off-by: Nico Schottelius --- conf/sources/bla blu/destination | 1 - conf/sources/bla blu/source | 1 - conf/sources/from-remote/README | 1 + .../sources/{local1&with-ampersand => from-remote}/destination | 0 conf/sources/{ikn => from-remote}/exclude | 0 conf/sources/from-remote/source | 1 + conf/sources/{ikn => from-remote}/summary | 0 conf/sources/{bla blu => from-remote}/verbose | 0 conf/sources/ikn/README | 1 - conf/sources/ikn/destination | 1 - conf/sources/ikn/source | 1 - conf/sources/{local1 => local-with&ersand}/destination | 0 .../{local1&with-ampersand => local-with&ersand}/exclude | 0 conf/sources/local-with&ersand/source | 1 + conf/sources/{remote1 => local}/destination | 0 conf/sources/{local1 => local}/exclude | 0 conf/sources/local/source | 1 + conf/sources/local1/source | 1 - conf/sources/remote1/source | 1 - .../delete_incomplete | 0 conf/sources/source with spaces and interval/destination | 1 + .../exclude | 0 .../intervals}/daily | 0 .../source | 0 conf/sources/{ikn => source with spaces and interval}/verbose | 0 conf/sources/source with spaces/destination | 1 - conf/sources/source with spaces/verbose | 0 conf/sources/testsource2/destination | 1 - conf/sources/testsource2/exclude | 3 --- conf/sources/testsource2/intervalls/daily | 1 - conf/sources/testsource2/intervalls/yearly | 1 - conf/sources/testsource2/source | 1 - conf/sources/{fehler => this_is_not_a_source} | 0 conf/sources/to-remote/destination | 1 + conf/sources/{remote1 => to-remote}/exclude | 0 conf/sources/{remote1 => to-remote}/remote_host | 0 conf/sources/{local1&with-ampersand => to-remote}/source | 0 conf/sources/vpn/destination | 1 - conf/sources/vpn/source | 1 - 39 files changed, 6 insertions(+), 17 deletions(-) delete mode 120000 conf/sources/bla blu/destination delete mode 100644 conf/sources/bla blu/source create mode 100644 conf/sources/from-remote/README rename conf/sources/{local1&with-ampersand => from-remote}/destination (100%) rename conf/sources/{ikn => from-remote}/exclude (100%) create mode 100644 conf/sources/from-remote/source rename conf/sources/{ikn => from-remote}/summary (100%) rename conf/sources/{bla blu => from-remote}/verbose (100%) delete mode 100644 conf/sources/ikn/README delete mode 100644 conf/sources/ikn/destination delete mode 100644 conf/sources/ikn/source rename conf/sources/{local1 => local-with&ersand}/destination (100%) rename conf/sources/{local1&with-ampersand => local-with&ersand}/exclude (100%) create mode 100644 conf/sources/local-with&ersand/source rename conf/sources/{remote1 => local}/destination (100%) rename conf/sources/{local1 => local}/exclude (100%) create mode 100644 conf/sources/local/source delete mode 100644 conf/sources/local1/source delete mode 100644 conf/sources/remote1/source rename conf/sources/{source with spaces => source with spaces and interval}/delete_incomplete (100%) create mode 100644 conf/sources/source with spaces and interval/destination rename conf/sources/{source with spaces => source with spaces and interval}/exclude (100%) rename conf/sources/{source with spaces/intervalls => source with spaces and interval/intervals}/daily (100%) rename conf/sources/{source with spaces => source with spaces and interval}/source (100%) rename conf/sources/{ikn => source with spaces and interval}/verbose (100%) delete mode 120000 conf/sources/source with spaces/destination delete mode 100644 conf/sources/source with spaces/verbose delete mode 120000 conf/sources/testsource2/destination delete mode 100644 conf/sources/testsource2/exclude delete mode 100644 conf/sources/testsource2/intervalls/daily delete mode 100644 conf/sources/testsource2/intervalls/yearly delete mode 100644 conf/sources/testsource2/source rename conf/sources/{fehler => this_is_not_a_source} (100%) mode change 100755 => 100644 create mode 100644 conf/sources/to-remote/destination rename conf/sources/{remote1 => to-remote}/exclude (100%) rename conf/sources/{remote1 => to-remote}/remote_host (100%) rename conf/sources/{local1&with-ampersand => to-remote}/source (100%) delete mode 120000 conf/sources/vpn/destination delete mode 100644 conf/sources/vpn/source diff --git a/conf/sources/bla blu/destination b/conf/sources/bla blu/destination deleted file mode 120000 index b12e153..0000000 --- a/conf/sources/bla blu/destination +++ /dev/null @@ -1 +0,0 @@ -/home/nico/backupdir \ No newline at end of file diff --git a/conf/sources/bla blu/source b/conf/sources/bla blu/source deleted file mode 100644 index 597ddca..0000000 --- a/conf/sources/bla blu/source +++ /dev/null @@ -1 +0,0 @@ -/home/nico/vpn diff --git a/conf/sources/from-remote/README b/conf/sources/from-remote/README new file mode 100644 index 0000000..c778cfe --- /dev/null +++ b/conf/sources/from-remote/README @@ -0,0 +1 @@ +This is based on a production example I use for my notebook. diff --git a/conf/sources/local1&with-ampersand/destination b/conf/sources/from-remote/destination similarity index 100% rename from conf/sources/local1&with-ampersand/destination rename to conf/sources/from-remote/destination diff --git a/conf/sources/ikn/exclude b/conf/sources/from-remote/exclude similarity index 100% rename from conf/sources/ikn/exclude rename to conf/sources/from-remote/exclude diff --git a/conf/sources/from-remote/source b/conf/sources/from-remote/source new file mode 100644 index 0000000..540dd91 --- /dev/null +++ b/conf/sources/from-remote/source @@ -0,0 +1 @@ +localhost:/home/users/nico/bin diff --git a/conf/sources/ikn/summary b/conf/sources/from-remote/summary similarity index 100% rename from conf/sources/ikn/summary rename to conf/sources/from-remote/summary diff --git a/conf/sources/bla blu/verbose b/conf/sources/from-remote/verbose similarity index 100% rename from conf/sources/bla blu/verbose rename to conf/sources/from-remote/verbose diff --git a/conf/sources/ikn/README b/conf/sources/ikn/README deleted file mode 100644 index 6b192a6..0000000 --- a/conf/sources/ikn/README +++ /dev/null @@ -1 +0,0 @@ -This is a production example I use for my notebook. diff --git a/conf/sources/ikn/destination b/conf/sources/ikn/destination deleted file mode 100644 index 8ac51bc..0000000 --- a/conf/sources/ikn/destination +++ /dev/null @@ -1 +0,0 @@ -/home/server/raid/backup/ikn diff --git a/conf/sources/ikn/source b/conf/sources/ikn/source deleted file mode 100644 index b498fd4..0000000 --- a/conf/sources/ikn/source +++ /dev/null @@ -1 +0,0 @@ -/ diff --git a/conf/sources/local1/destination b/conf/sources/local-with&ersand/destination similarity index 100% rename from conf/sources/local1/destination rename to conf/sources/local-with&ersand/destination diff --git a/conf/sources/local1&with-ampersand/exclude b/conf/sources/local-with&ersand/exclude similarity index 100% rename from conf/sources/local1&with-ampersand/exclude rename to conf/sources/local-with&ersand/exclude diff --git a/conf/sources/local-with&ersand/source b/conf/sources/local-with&ersand/source new file mode 100644 index 0000000..e64611b --- /dev/null +++ b/conf/sources/local-with&ersand/source @@ -0,0 +1 @@ +/home/users/nico/bin diff --git a/conf/sources/remote1/destination b/conf/sources/local/destination similarity index 100% rename from conf/sources/remote1/destination rename to conf/sources/local/destination diff --git a/conf/sources/local1/exclude b/conf/sources/local/exclude similarity index 100% rename from conf/sources/local1/exclude rename to conf/sources/local/exclude diff --git a/conf/sources/local/source b/conf/sources/local/source new file mode 100644 index 0000000..e64611b --- /dev/null +++ b/conf/sources/local/source @@ -0,0 +1 @@ +/home/users/nico/bin diff --git a/conf/sources/local1/source b/conf/sources/local1/source deleted file mode 100644 index 9686138..0000000 --- a/conf/sources/local1/source +++ /dev/null @@ -1 +0,0 @@ -/home/user/nico/bin diff --git a/conf/sources/remote1/source b/conf/sources/remote1/source deleted file mode 100644 index 9686138..0000000 --- a/conf/sources/remote1/source +++ /dev/null @@ -1 +0,0 @@ -/home/user/nico/bin diff --git a/conf/sources/source with spaces/delete_incomplete b/conf/sources/source with spaces and interval/delete_incomplete similarity index 100% rename from conf/sources/source with spaces/delete_incomplete rename to conf/sources/source with spaces and interval/delete_incomplete diff --git a/conf/sources/source with spaces and interval/destination b/conf/sources/source with spaces and interval/destination new file mode 100644 index 0000000..8cac69d --- /dev/null +++ b/conf/sources/source with spaces and interval/destination @@ -0,0 +1 @@ +/tmp/ccollect diff --git a/conf/sources/source with spaces/exclude b/conf/sources/source with spaces and interval/exclude similarity index 100% rename from conf/sources/source with spaces/exclude rename to conf/sources/source with spaces and interval/exclude diff --git a/conf/sources/source with spaces/intervalls/daily b/conf/sources/source with spaces and interval/intervals/daily similarity index 100% rename from conf/sources/source with spaces/intervalls/daily rename to conf/sources/source with spaces and interval/intervals/daily diff --git a/conf/sources/source with spaces/source b/conf/sources/source with spaces and interval/source similarity index 100% rename from conf/sources/source with spaces/source rename to conf/sources/source with spaces and interval/source diff --git a/conf/sources/ikn/verbose b/conf/sources/source with spaces and interval/verbose similarity index 100% rename from conf/sources/ikn/verbose rename to conf/sources/source with spaces and interval/verbose diff --git a/conf/sources/source with spaces/destination b/conf/sources/source with spaces/destination deleted file mode 120000 index 8de582a..0000000 --- a/conf/sources/source with spaces/destination +++ /dev/null @@ -1 +0,0 @@ -/home/user/nico/backupdir/testsource1 \ No newline at end of file diff --git a/conf/sources/source with spaces/verbose b/conf/sources/source with spaces/verbose deleted file mode 100644 index e69de29..0000000 diff --git a/conf/sources/testsource2/destination b/conf/sources/testsource2/destination deleted file mode 120000 index b12e153..0000000 --- a/conf/sources/testsource2/destination +++ /dev/null @@ -1 +0,0 @@ -/home/nico/backupdir \ No newline at end of file diff --git a/conf/sources/testsource2/exclude b/conf/sources/testsource2/exclude deleted file mode 100644 index bbdbdf1..0000000 --- a/conf/sources/testsource2/exclude +++ /dev/null @@ -1,3 +0,0 @@ -openvpn-2.0.1.tar.gz -nicht_reinnehmen -etwas mit leerzeichenli diff --git a/conf/sources/testsource2/intervalls/daily b/conf/sources/testsource2/intervalls/daily deleted file mode 100644 index 7ed6ff8..0000000 --- a/conf/sources/testsource2/intervalls/daily +++ /dev/null @@ -1 +0,0 @@ -5 diff --git a/conf/sources/testsource2/intervalls/yearly b/conf/sources/testsource2/intervalls/yearly deleted file mode 100644 index 209e3ef..0000000 --- a/conf/sources/testsource2/intervalls/yearly +++ /dev/null @@ -1 +0,0 @@ -20 diff --git a/conf/sources/testsource2/source b/conf/sources/testsource2/source deleted file mode 100644 index 597ddca..0000000 --- a/conf/sources/testsource2/source +++ /dev/null @@ -1 +0,0 @@ -/home/nico/vpn diff --git a/conf/sources/fehler b/conf/sources/this_is_not_a_source old mode 100755 new mode 100644 similarity index 100% rename from conf/sources/fehler rename to conf/sources/this_is_not_a_source diff --git a/conf/sources/to-remote/destination b/conf/sources/to-remote/destination new file mode 100644 index 0000000..8cac69d --- /dev/null +++ b/conf/sources/to-remote/destination @@ -0,0 +1 @@ +/tmp/ccollect diff --git a/conf/sources/remote1/exclude b/conf/sources/to-remote/exclude similarity index 100% rename from conf/sources/remote1/exclude rename to conf/sources/to-remote/exclude diff --git a/conf/sources/remote1/remote_host b/conf/sources/to-remote/remote_host similarity index 100% rename from conf/sources/remote1/remote_host rename to conf/sources/to-remote/remote_host diff --git a/conf/sources/local1&with-ampersand/source b/conf/sources/to-remote/source similarity index 100% rename from conf/sources/local1&with-ampersand/source rename to conf/sources/to-remote/source diff --git a/conf/sources/vpn/destination b/conf/sources/vpn/destination deleted file mode 120000 index fdfab7b..0000000 --- a/conf/sources/vpn/destination +++ /dev/null @@ -1 +0,0 @@ -/home/nico/backupdir/vpn \ No newline at end of file diff --git a/conf/sources/vpn/source b/conf/sources/vpn/source deleted file mode 100644 index 04b9f19..0000000 --- a/conf/sources/vpn/source +++ /dev/null @@ -1 +0,0 @@ -/home/nico/vpn/ From 37dcda8e3b191ceb7f8c8e36ba6468368adf757e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 23 Jul 2009 17:37:55 +0200 Subject: [PATCH 352/581] BUGFIX: ignore -- as parameter Signed-off-by: Nico Schottelius --- ccollect.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ccollect.sh b/ccollect.sh index ab77bbe..13a3451 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -154,6 +154,8 @@ while [ "$#" -ge 1 ]; do usage ;; --) + # ignore the -- itself + shift break ;; *) From debdd9d004333c58c6a0762805a876188cd0864f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 23 Jul 2009 17:39:42 +0200 Subject: [PATCH 353/581] BUGFIX: Fix --all handling Signed-off-by: Nico Schottelius --- ccollect.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 13a3451..9e100c4 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -198,8 +198,7 @@ if [ "${USE_ALL}" = 1 ]; then # # get entries from sources # - cwd="$(pwd -P)" - ( cd "${CSOURCES}" && ls -p1 > "${TMP}" | grep '/$' ); ret=$? + ( cd "${CSOURCES}" && ls -p1 | grep '/$' > "${TMP}" ); ret=$? [ "${ret}" -eq 0 ] || _exit_err "Listing of sources failed. Aborting." From 8491a54b0deef3fb6c0a078edb9d92a12af74036 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 23 Jul 2009 17:46:04 +0200 Subject: [PATCH 354/581] extract the interval handling from parsing Signed-off-by: Nico Schottelius --- ccollect.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ccollect.sh b/ccollect.sh index 9e100c4..a3a0973 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -165,6 +165,15 @@ while [ "$#" -ge 1 ]; do shift done +# +# Setup interval +# +if [ $# -ge 1 ]; then + export INTERVAL="$1" + shift +else + usage +fi # # check for configuraton directory From f5e1920a155eb260a7b2d25c2de5eab224385f64 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 23 Jul 2009 17:47:54 +0200 Subject: [PATCH 355/581] join source handling for --all and normal Signed-off-by: Nico Schottelius --- ccollect.sh | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index a3a0973..5914d95 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -181,22 +181,6 @@ fi [ -d "${CCOLLECT_CONF}" ] || _exit_err "No configuration found in " \ "\"${CCOLLECT_CONF}\" (is \$CCOLLECT_CONF properly set?)" -# -# Capture sources in an "array" -# -while [ "$#" -ge 1 ]; do - eval arg=\"\$1\"; shift - - if [ -z "$INTERVAL" ]; then - INTERVAL="$arg" - else - eval source_${no_sources}=\"${arg}\" - no_sources="$((${no_sources}+1))" - - # make variable available for subscripts - eval export source_${no_sources} -fi -done # # Look, if we should take ALL sources @@ -204,6 +188,7 @@ done if [ "${USE_ALL}" = 1 ]; then no_sources="0" +if [ "${USE_ALL}" = 1 ]; then # # get entries from sources # @@ -215,6 +200,19 @@ if [ "${USE_ALL}" = 1 ]; then eval source_${no_sources}=\"${tmp}\" no_sources=$((${no_sources}+1)) done < "${TMP}" +else + # + # Get sources from command line + # + while [ "$#" -ge 1 ]; do + eval arg=\"\$1\"; shift + + eval source_${no_sources}=\"${arg}\" + no_sources="$((${no_sources}+1))" + + # make variable available for subscripts + eval export source_${no_sources} + done fi # From 8a87e7effaa72db413f289a89d98507c7d2cffbf Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 23 Jul 2009 17:53:35 +0200 Subject: [PATCH 356/581] Move option check below the check for existence of source Signed-off-by: Nico Schottelius --- ccollect.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 5914d95..7c9c54a 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -282,13 +282,6 @@ while [ "${i}" -lt "${no_sources}" ]; do c_dest="${backup}/destination" c_pre_exec="${backup}/pre_exec" c_post_exec="${backup}/post_exec" - for opt in exclude verbose very_verbose rsync_options summary delete_incomplete remote_host ; do - if [ -f "${backup}/${opt}" -o -f "${backup}/no_${opt}" ]; then - eval c_$opt=\"${backup}/$opt\" - else - eval c_$opt=\"${CDEFAULTS}/$opt\" - fi - done # # Marking backups: If we abort it's not removed => Backup is broken @@ -316,6 +309,17 @@ while [ "${i}" -lt "${no_sources}" ]; do _exit_err "\"${name}\" is not a cconfig-directory. Skipping." fi + # + # Read possible options + # + for opt in exclude verbose very_verbose rsync_options summary delete_incomplete remote_host ; do + if [ -f "${backup}/${opt}" -o -f "${backup}/no_${opt}" ]; then + eval c_$opt=\"${backup}/$opt\" + else + eval c_$opt=\"${CDEFAULTS}/$opt\" + fi + done + # # first execute pre_exec, which may generate destination or other parameters # From ed30a4d25be935fe864794ca91cd137c6c137d62 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 23 Jul 2009 17:56:41 +0200 Subject: [PATCH 357/581] Remove check for directories with -a Type of source is checked later anyway and using ls -p1 results in "dir/", which we should cleanup with "sed 's;/$;;' again, which is ugly. Signed-off-by: Nico Schottelius --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index 7c9c54a..cfd9b61 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -192,7 +192,7 @@ if [ "${USE_ALL}" = 1 ]; then # # get entries from sources # - ( cd "${CSOURCES}" && ls -p1 | grep '/$' > "${TMP}" ); ret=$? + ( cd "${CSOURCES}" && ls -1 > "${TMP}" ); ret=$? [ "${ret}" -eq 0 ] || _exit_err "Listing of sources failed. Aborting." From c9472c5dff3ca184bdcbc73267e53940cc7e555f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 23 Jul 2009 18:55:25 +0200 Subject: [PATCH 358/581] add luckys patches idea looks good, patches need some claenups Signed-off-by: Nico Schottelius --- .../exclude | 0 .../source | 0 conf/sources/to-remote/remote_host | 2 +- .../ccollect_logwrapper_destination.patch | 14 ++++++++++ contrib/lucky-2009-07-22/ccollect_stats.sh | 26 +++++++++++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) rename conf/sources/{source-without-intervall => source-without-destination}/exclude (100%) rename conf/sources/{source-without-intervall => source-without-destination}/source (100%) create mode 100644 contrib/lucky-2009-07-22/ccollect_logwrapper_destination.patch create mode 100644 contrib/lucky-2009-07-22/ccollect_stats.sh diff --git a/conf/sources/source-without-intervall/exclude b/conf/sources/source-without-destination/exclude similarity index 100% rename from conf/sources/source-without-intervall/exclude rename to conf/sources/source-without-destination/exclude diff --git a/conf/sources/source-without-intervall/source b/conf/sources/source-without-destination/source similarity index 100% rename from conf/sources/source-without-intervall/source rename to conf/sources/source-without-destination/source diff --git a/conf/sources/to-remote/remote_host b/conf/sources/to-remote/remote_host index 3c2693c..2fbb50c 100644 --- a/conf/sources/to-remote/remote_host +++ b/conf/sources/to-remote/remote_host @@ -1 +1 @@ -home.schottelius.org +localhost diff --git a/contrib/lucky-2009-07-22/ccollect_logwrapper_destination.patch b/contrib/lucky-2009-07-22/ccollect_logwrapper_destination.patch new file mode 100644 index 0000000..5fb20b5 --- /dev/null +++ b/contrib/lucky-2009-07-22/ccollect_logwrapper_destination.patch @@ -0,0 +1,14 @@ +31c31,41 +< logdir="${LOGCONF}/destination" +--- +> c_dest="${LOGCONF}/destination" +> +> if [ ! -f ${c_dest} ]; then +> _exit_err "Destination ${c_dest} is not a file. Skipping." +> else +> logdir=$(cat "${c_dest}"); ret="$?" +> if [ "${ret}" -ne 0 ]; then +> _exit_err "Destination ${c_dest} is not readable. Skipping." +> fi +> fi +> diff --git a/contrib/lucky-2009-07-22/ccollect_stats.sh b/contrib/lucky-2009-07-22/ccollect_stats.sh new file mode 100644 index 0000000..886be09 --- /dev/null +++ b/contrib/lucky-2009-07-22/ccollect_stats.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# +# 2007 Daniel Aubry +# 2008 Nico Schottelius (added minimal header) +# +# Copying license: GPL2-only +# + +# TODO: +# add variables, add copying, add configuration + +if [ ! -e /tmp/ccollect-stats.lock ] +then + touch /tmp/ccollect-stats.lock + + # changes after license clearify + # for dest in /etc/ccollect/sources/ -type f -name destination | while read line + + find /etc/ccollect/sources/*/destination | while read line + do + d=$(basename $(cat $line)) + echo "====[Backup: $backupname]====" | tee -a /var/log/backup.log + du -sh $line/* | tee -a /var/log/backup.log + done + rm /tmp/ccollect-stats.lock +fi From ef641b5e31000b8cf2e82e90880bc6f6acf73bf9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 23 Jul 2009 19:42:56 +0200 Subject: [PATCH 359/581] update ccollect vs. rsnapshot LOC statistic Signed-off-by: Nico Schottelius --- README | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README b/README index b1e46fd..558594d 100644 --- a/README +++ b/README @@ -45,6 +45,9 @@ A small try to visualize the differences in a table: | Lines of code | 6772 (5353 w/o comments, | 546 (375 w/o comments, | | (2006-10-25) | 4794 w/o empty lines) | 288 w/o empty lines) | +---------------+-------------------------------------------------------------+ +| Lines of code | 7269 (6778 w/o comments, | 587 (397 w/o comments, | +| (2009-07-23) | 6139 w/o empty lines) | 315 w/o empty lines) | ++---------------+-------------------------------------------------------------+ | Age | Available since 2002/2003 | Written at 2005-11-14 | +---------------+-------------------------------------------------------------+ From e390c62072ea5784e47e89d4faac124e6234ab3e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 24 Jul 2009 08:57:53 +0200 Subject: [PATCH 360/581] run all sources as a test Signed-off-by: Nico Schottelius --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0f8a8d1..8c05714 100644 --- a/Makefile +++ b/Makefile @@ -191,5 +191,4 @@ dist: distclean documentation test: ccollect.sh documentation mkdir -p /tmp/ccollect - CCOLLECT_CONF=./conf ./ccollect.sh daily "source with spaces" - CCOLLECT_CONF=./conf ./ccollect.sh normal 'local1&with-ampersand' + CCOLLECT_CONF=./conf ./ccollect.sh -a daily From b44fdb6107a3258e9a11c4c2a0e888872466611f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 24 Jul 2009 08:58:48 +0200 Subject: [PATCH 361/581] some cleanups Signed-off-by: Nico Schottelius --- ccollect.sh | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index cfd9b61..8a2094a 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -41,7 +41,7 @@ CPOSTEXEC="${CDEFAULTS}/post_exec" TMP=$(mktemp "/tmp/${__myname}.XXXXXX") VERSION="0.8" -RELEASE="2009-XX-XX" +RELEASE="2009-08-XX" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" @@ -59,9 +59,6 @@ TSORT="tc" # PARALLEL="" USE_ALL="" -export INTERVAL="" -export no_sources=0 - # # catch signals @@ -176,28 +173,27 @@ else fi # -# check for configuraton directory +# Check for configuraton directory # [ -d "${CCOLLECT_CONF}" ] || _exit_err "No configuration found in " \ "\"${CCOLLECT_CONF}\" (is \$CCOLLECT_CONF properly set?)" # -# Look, if we should take ALL sources +# Create (portable!) source "array" # -if [ "${USE_ALL}" = 1 ]; then - no_sources="0" +export no_sources=0 if [ "${USE_ALL}" = 1 ]; then # - # get entries from sources + # Get sources from source configuration # ( cd "${CSOURCES}" && ls -1 > "${TMP}" ); ret=$? [ "${ret}" -eq 0 ] || _exit_err "Listing of sources failed. Aborting." while read tmp; do - eval source_${no_sources}=\"${tmp}\" + eval export source_${no_sources}=\"${tmp}\" no_sources=$((${no_sources}+1)) done < "${TMP}" else @@ -218,7 +214,7 @@ fi # # Need at least ONE source to backup # -if [ "${no_sources}" -lt 1 -o -z "${INTERVAL}" ]; then +if [ "${no_sources}" -lt 1 ]; then usage else _techo "${HALF_VERSION}: Beginning backup using interval ${INTERVAL}" @@ -248,7 +244,6 @@ D_INTERVAL="$(cat "${D_FILE_INTERVAL}" 2>/dev/null)" # i=0 while [ "${i}" -lt "${no_sources}" ]; do - # # Get current source # @@ -506,7 +501,6 @@ while [ "${i}" -lt "${no_sources}" ]; do _techo "Hard linking from ${last_dir}" fi - # set time when we really begin to backup, not when we began to remove above destination_date="$(${CDATE})" destination_dir="${ddir}/${INTERVAL}.${destination_date}.$$" @@ -527,7 +521,6 @@ while [ "${i}" -lt "${no_sources}" ]; do # # the rsync part # - _techo "Transferring files..." rsync "$@" "${source}" "${destination_full}"; ret=$? From e136b132e693b48eae8bb8b88aa8ed2037af50c4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 24 Jul 2009 08:59:13 +0200 Subject: [PATCH 362/581] update changes list Signed-off-by: Nico Schottelius --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changes/next b/doc/changes/next index 2e073f7..4ff4cba 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -3,3 +3,4 @@ * Defensive programming patch (John Lawless) * Some code cleanups (argument parsing, usage) (Nico Schottelius) * Only consider directories as sources when using -a (Nico Schottelius) +* Fix general parsing problem with -a (Nico Schottelius) From 1b1e0ebc8ba815053318c432e03642dc752291d2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 24 Jul 2009 09:00:48 +0200 Subject: [PATCH 363/581] update example sources Signed-off-by: Nico Schottelius --- conf/sources/source-without-destination/exclude | 2 +- conf/sources/source-without-destination/source | 2 +- conf/sources/to-remote/source | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/sources/source-without-destination/exclude b/conf/sources/source-without-destination/exclude index 5469661..6b8710a 100644 --- a/conf/sources/source-without-destination/exclude +++ b/conf/sources/source-without-destination/exclude @@ -1 +1 @@ -manage +.git diff --git a/conf/sources/source-without-destination/source b/conf/sources/source-without-destination/source index a1849b9..e64611b 100644 --- a/conf/sources/source-without-destination/source +++ b/conf/sources/source-without-destination/source @@ -1 +1 @@ -nico@creme.schottelius.org:bin +/home/users/nico/bin diff --git a/conf/sources/to-remote/source b/conf/sources/to-remote/source index 9686138..e64611b 100644 --- a/conf/sources/to-remote/source +++ b/conf/sources/to-remote/source @@ -1 +1 @@ -/home/user/nico/bin +/home/users/nico/bin From 65c34deb43a440e6879bfc0a7cc15f09bf699936 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Jul 2009 09:01:13 +0200 Subject: [PATCH 364/581] remove unecessary whitespace in line 204 :-) Signed-off-by: Nico Schottelius --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index a762132..b7eb8e0 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -204,7 +204,7 @@ else eval source_${no_sources}=\"${arg}\" no_sources="$((${no_sources}+1))" - + # make variable available for subscripts eval export source_${no_sources} done From d61c9625f4eb5738d25143799e671812ef89b4d1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Jul 2009 09:06:01 +0200 Subject: [PATCH 365/581] Only check configuration options, if the base is exitsing Signed-off-by: Nico Schottelius --- ccollect.sh | 50 +++++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index b7eb8e0..62bfb84 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -202,11 +202,8 @@ else while [ "$#" -ge 1 ]; do eval arg=\"\$1\"; shift - eval source_${no_sources}=\"${arg}\" + eval export source_${no_sources}=\"${arg}\" no_sources="$((${no_sources}+1))" - - # make variable available for subscripts - eval export source_${no_sources} done fi @@ -261,7 +258,27 @@ while [ "${i}" -lt "${no_sources}" ]; do exec 2>&1 # - # Configuration + # Record start of backup: internal and for the user + # + begin_s="$(date +%s)" + _techo "Beginning to backup" + + # + # Standard configuration checks + # + if [ ! -e "${backup}" ]; then + _exit_err "Source does not exist." + fi + + # + # Configuration _must_ be a directory (cconfig style) + # + if [ ! -d "${backup}" ]; then + _exit_err "\"${name}\" is not a cconfig-directory. Skipping." + fi + + # + # Read Configuration # backup="${CSOURCES}/${name}" c_source="${backup}/source" @@ -270,7 +287,7 @@ while [ "${i}" -lt "${no_sources}" ]; do c_post_exec="${backup}/post_exec" for opt in exclude verbose very_verbose rsync_options summary delete_incomplete \ remote_host rsync_failure_codes mtime quiet_if_down ; do - if [ -f "${backup}/$opt" -o -f "${backup}/no_$opt" ]; then + if [ -f "${backup}/${opt}" -o -f "${backup}/no_${opt}" ]; then eval c_$opt=\"${backup}/$opt\" else eval c_$opt=\"${CDEFAULTS}/$opt\" @@ -289,27 +306,6 @@ while [ "${i}" -lt "${no_sources}" ]; do # c_marker=".ccollect-marker" - # - # Times - # - begin_s="$(date +%s)" - - _techo "Beginning to backup" - - # - # Standard configuration checks - # - if [ ! -e "${backup}" ]; then - _exit_err "Source does not exist." - fi - - # - # configuration _must_ be a directory - # - if [ ! -d "${backup}" ]; then - _exit_err "\"${name}\" is not a cconfig-directory. Skipping." - fi - # # Read possible options # From b014c00d2467996713b094ec8a0cd01760266d86 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Jul 2009 09:16:35 +0200 Subject: [PATCH 366/581] Remove double code imported with merge Signed-off-by: Nico Schottelius --- ccollect.sh | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 62bfb84..e7ac7fb 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -287,7 +287,7 @@ while [ "${i}" -lt "${no_sources}" ]; do c_post_exec="${backup}/post_exec" for opt in exclude verbose very_verbose rsync_options summary delete_incomplete \ remote_host rsync_failure_codes mtime quiet_if_down ; do - if [ -f "${backup}/${opt}" -o -f "${backup}/no_${opt}" ]; then + if [ -f "${backup}/${opt}" -o -f "${backup}/no_${opt}" ]; then eval c_$opt=\"${backup}/$opt\" else eval c_$opt=\"${CDEFAULTS}/$opt\" @@ -307,18 +307,7 @@ while [ "${i}" -lt "${no_sources}" ]; do c_marker=".ccollect-marker" # - # Read possible options - # - for opt in exclude verbose very_verbose rsync_options summary delete_incomplete remote_host ; do - if [ -f "${backup}/${opt}" -o -f "${backup}/no_${opt}" ]; then - eval c_$opt=\"${backup}/$opt\" - else - eval c_$opt=\"${CDEFAULTS}/$opt\" - fi - done - - # - # first execute pre_exec, which may generate destination or other parameters + # First execute pre_exec, which may generate destination or other parameters # if [ -x "${c_pre_exec}" ]; then _techo "Executing ${c_pre_exec} ..." From cbf1b7cf0e30f1cab9b96e20a81791b75e31abf7 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Jul 2009 09:17:06 +0200 Subject: [PATCH 367/581] Simplify error printing, if quiet_if_down is set Signed-off-by: Nico Schottelius --- ccollect.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index e7ac7fb..c07852a 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -335,12 +335,10 @@ while [ "${i}" -lt "${no_sources}" ]; do # Verify source is up and accepting connections before deleting any old backups # if ! rsync "${source}" >/dev/null 2>"${TMP}" ; then - if [ -f "${c_quiet_if_down}" ]; then - _exit_err "Source ${source} is not readable. Skipping." - else + if [ ! -f "${c_quiet_if_down}" ]; then cat "${TMP}" - _exit_err "Error: source ${source} is not readable. Skipping." fi + _exit_err "Source ${source} is not readable. Skipping." fi # @@ -375,10 +373,9 @@ while [ "${i}" -lt "${no_sources}" ]; do # ( pcmd cd "$ddir" ) || _exit_err "Cannot change to ${ddir}. Skipping." - # NEW method as of 0.6: - # - insert ccollect default parameters - # - insert options - # - insert user options + # + # Parameters: ccollect defaults, configuration options, user options + # # # rsync standard options From 483cfee90cd9a13d096a039ee516d620b15f9980 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Jul 2009 09:37:50 +0200 Subject: [PATCH 368/581] Reorder: All checks being done in the same place All configurations are checked in the same place Signed-off-by: Nico Schottelius --- ccollect.sh | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index c07852a..90862b1 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -278,13 +278,14 @@ while [ "${i}" -lt "${no_sources}" ]; do fi # - # Read Configuration + # Read / create configuration # backup="${CSOURCES}/${name}" c_source="${backup}/source" c_dest="${backup}/destination" c_pre_exec="${backup}/pre_exec" c_post_exec="${backup}/post_exec" + c_marker=".ccollect-marker" for opt in exclude verbose very_verbose rsync_options summary delete_incomplete \ remote_host rsync_failure_codes mtime quiet_if_down ; do if [ -f "${backup}/${opt}" -o -f "${backup}/no_${opt}" ]; then @@ -301,11 +302,6 @@ while [ "${i}" -lt "${no_sources}" ]; do TSORT="t" fi - # - # Marking backups: If we abort it's not removed => Backup is broken - # - c_marker=".ccollect-marker" - # # First execute pre_exec, which may generate destination or other parameters # @@ -320,7 +316,7 @@ while [ "${i}" -lt "${no_sources}" ]; do fi # - # Source checks + # Source configuration checks # if [ ! -f "${c_source}" ]; then _exit_err "Source description \"${c_source}\" is not a file. Skipping." @@ -331,16 +327,6 @@ while [ "${i}" -lt "${no_sources}" ]; do fi fi - # - # Verify source is up and accepting connections before deleting any old backups - # - if ! rsync "${source}" >/dev/null 2>"${TMP}" ; then - if [ ! -f "${c_quiet_if_down}" ]; then - cat "${TMP}" - fi - _exit_err "Source ${source} is not readable. Skipping." - fi - # # Destination is a path # @@ -368,23 +354,18 @@ while [ "${i}" -lt "${no_sources}" ]; do fi export remote_host - # - # check for existence / use real name - # - ( pcmd cd "$ddir" ) || _exit_err "Cannot change to ${ddir}. Skipping." - # # Parameters: ccollect defaults, configuration options, user options # # - # rsync standard options + # Rsync standard options # set -- "$@" "--archive" "--delete" "--numeric-ids" "--relative" \ "--delete-excluded" "--sparse" # - # exclude list + # Exclude list # if [ -f "${c_exclude}" ]; then set -- "$@" "--exclude-from=${c_exclude}" @@ -409,7 +390,7 @@ while [ "${i}" -lt "${no_sources}" ]; do fi # - # extra options for rsync provided by the user + # Extra options for rsync provided by the user # if [ -f "${c_rsync_options}" ]; then while read line; do @@ -418,7 +399,22 @@ while [ "${i}" -lt "${no_sources}" ]; do fi # - # Check for incomplete backups + # Check: source is up and accepting connections (before deleting old backups!) + # + if ! rsync "${source}" >/dev/null 2>"${TMP}" ; then + if [ ! -f "${c_quiet_if_down}" ]; then + cat "${TMP}" + fi + _exit_err "Source ${source} is not readable. Skipping." + fi + + # + # Check: destination exists? + # + ( pcmd cd "${ddir}" ) || _exit_err "Cannot change to ${ddir}. Skipping." + + # + # Check: incomplete backups? # pcmd ls -1 "${ddir}/"*".${c_marker}" 2>/dev/null | while read marker; do incomplete="$(echo ${marker} | sed "s/\\.${c_marker}\$//")" From c2bc225dc08b2625d42c26387720f7e89403868b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Jul 2009 09:39:33 +0200 Subject: [PATCH 369/581] SORT: make it more explicit, which sorting options are used Signed-off-by: Nico Schottelius --- ccollect.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 90862b1..a6aa098 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -48,11 +48,9 @@ FULL_VERSION="ccollect ${VERSION} (${RELEASE})" # # CDATE: how we use it for naming of the archives # DDATE: how the user should see it in our output (DISPLAY) -# TSORT: how to sort: tc = ctime, t = mtime # CDATE="date +%Y%m%d-%H%M" DDATE="date +%Y-%m-%d-%H:%M:%S" -TSORT="tc" # # unset values @@ -296,10 +294,12 @@ while [ "${i}" -lt "${no_sources}" ]; do done # - # With mtime option, sort backup directories with mtime (default is ctime) + # Sort by ctime (default) or mtime (configuration option) # if [ -f "$c_mtime" ] ; then TSORT="t" + else + TSORT="tc" fi # From 428670b4e7e221dc32c3a4b3abcd523731c6d038 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Jul 2009 09:52:18 +0200 Subject: [PATCH 370/581] comment cleanups Signed-off-by: Nico Schottelius --- ccollect.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index a6aa098..80e893f 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -429,7 +429,7 @@ while [ "${i}" -lt "${no_sources}" ]; do done # - # interval definition: First try source specific, fallback to default + # Interval definition: First try source specific, fallback to default # c_interval="$(cat "${backup}/intervals/${INTERVAL}" 2>/dev/null)" @@ -442,8 +442,8 @@ while [ "${i}" -lt "${no_sources}" ]; do fi # - # check if maximum number of backups is reached, if so remove - # use grep and ls -p so we only look at directories + # Check: maximum number of backups is reached? + # If so remove. Use grep and ls -p so we only look at directories # count="$(pcmd ls -p1 "${ddir}" | grep "^${INTERVAL}\..*/\$" | wc -l \ | sed 's/^ *//g')" || _exit_err "Counting backups failed" From 4e3c5922eef6f9d7aa8dd30ccbf00a6eec26b8ea Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Jul 2009 20:38:55 +0200 Subject: [PATCH 371/581] add smaller tests - easier to detect the problem Signed-off-by: Nico Schottelius --- Makefile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8c05714..db18f19 100644 --- a/Makefile +++ b/Makefile @@ -189,6 +189,16 @@ distclean: clean # dist: distclean documentation -test: ccollect.sh documentation +#test: ccollect.sh documentation +test: ccollect.sh mkdir -p /tmp/ccollect - CCOLLECT_CONF=./conf ./ccollect.sh -a daily + CCOLLECT_CONF=./conf ./ccollect.sh daily from-remote + CCOLLECT_CONF=./conf ./ccollect.sh daily local + CCOLLECT_CONF=./conf ./ccollect.sh daily "local-with&ersand" + CCOLLECT_CONF=./conf ./ccollect.sh daily source-without-destination + CCOLLECT_CONF=./conf ./ccollect.sh daily "source with spaces and interval" + CCOLLECT_CONF=./conf ./ccollect.sh daily to-remote + CCOLLECT_CONF=./conf ./ccollect.sh daily with_exec + CCOLLECT_CONF=./conf ./ccollect.sh daily no-source-must-fail +# for s in $$(ls ./conf/sources); do CCOLLECT_CONF=./conf echo ./ccollect.sh daily $$s; done +# CCOLLECT_CONF=./conf ./ccollect.sh -a daily From 77ea2b513f639a1e8837529fd8a39b5ddd795667 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 27 Jul 2009 20:39:09 +0200 Subject: [PATCH 372/581] update example sources Signed-off-by: Nico Schottelius --- conf/sources/source with spaces and interval/intervals/daily | 2 +- conf/sources/source with spaces and interval/source | 2 +- conf/sources/with_exec/source | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/sources/source with spaces and interval/intervals/daily b/conf/sources/source with spaces and interval/intervals/daily index 0cfbf08..64bb6b7 100644 --- a/conf/sources/source with spaces and interval/intervals/daily +++ b/conf/sources/source with spaces and interval/intervals/daily @@ -1 +1 @@ -2 +30 diff --git a/conf/sources/source with spaces and interval/source b/conf/sources/source with spaces and interval/source index 2206a2c..e64611b 100644 --- a/conf/sources/source with spaces and interval/source +++ b/conf/sources/source with spaces and interval/source @@ -1 +1 @@ -/home/user/nico/oeffentlich/computer/projekte/ccollect +/home/users/nico/bin diff --git a/conf/sources/with_exec/source b/conf/sources/with_exec/source index 5e56e04..e64611b 100644 --- a/conf/sources/with_exec/source +++ b/conf/sources/with_exec/source @@ -1 +1 @@ -/bin +/home/users/nico/bin From 87e15be5612ee7208f6a85a65907bc777aff257e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 28 Jul 2009 07:45:13 +0200 Subject: [PATCH 373/581] update example sources Signed-off-by: Nico Schottelius --- conf/sources/very-verbose/README | 1 + conf/sources/very-verbose/destination | 1 + conf/sources/very-verbose/exclude | 1 + conf/sources/very-verbose/source | 1 + conf/sources/very-verbose/summary | 0 conf/sources/very-verbose/verbose | 0 conf/sources/very-verbose/very_verbose | 0 conf/sources/with_exec/destination | 2 +- 8 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 conf/sources/very-verbose/README create mode 100644 conf/sources/very-verbose/destination create mode 100644 conf/sources/very-verbose/exclude create mode 100644 conf/sources/very-verbose/source create mode 100644 conf/sources/very-verbose/summary create mode 100644 conf/sources/very-verbose/verbose create mode 100644 conf/sources/very-verbose/very_verbose mode change 120000 => 100644 conf/sources/with_exec/destination diff --git a/conf/sources/very-verbose/README b/conf/sources/very-verbose/README new file mode 100644 index 0000000..c778cfe --- /dev/null +++ b/conf/sources/very-verbose/README @@ -0,0 +1 @@ +This is based on a production example I use for my notebook. diff --git a/conf/sources/very-verbose/destination b/conf/sources/very-verbose/destination new file mode 100644 index 0000000..8cac69d --- /dev/null +++ b/conf/sources/very-verbose/destination @@ -0,0 +1 @@ +/tmp/ccollect diff --git a/conf/sources/very-verbose/exclude b/conf/sources/very-verbose/exclude new file mode 100644 index 0000000..f5b5b7c --- /dev/null +++ b/conf/sources/very-verbose/exclude @@ -0,0 +1 @@ +/home/server/raid diff --git a/conf/sources/very-verbose/source b/conf/sources/very-verbose/source new file mode 100644 index 0000000..e64611b --- /dev/null +++ b/conf/sources/very-verbose/source @@ -0,0 +1 @@ +/home/users/nico/bin diff --git a/conf/sources/very-verbose/summary b/conf/sources/very-verbose/summary new file mode 100644 index 0000000..e69de29 diff --git a/conf/sources/very-verbose/verbose b/conf/sources/very-verbose/verbose new file mode 100644 index 0000000..e69de29 diff --git a/conf/sources/very-verbose/very_verbose b/conf/sources/very-verbose/very_verbose new file mode 100644 index 0000000..e69de29 diff --git a/conf/sources/with_exec/destination b/conf/sources/with_exec/destination deleted file mode 120000 index cad2309..0000000 --- a/conf/sources/with_exec/destination +++ /dev/null @@ -1 +0,0 @@ -/tmp \ No newline at end of file diff --git a/conf/sources/with_exec/destination b/conf/sources/with_exec/destination new file mode 100644 index 0000000..8cac69d --- /dev/null +++ b/conf/sources/with_exec/destination @@ -0,0 +1 @@ +/tmp/ccollect From 8a56d41ebc1852027d34314526317b741a441c54 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 28 Jul 2009 07:46:05 +0200 Subject: [PATCH 374/581] very-verbose -> very_verbose Signed-off-by: Nico Schottelius --- Makefile | 1 + conf/sources/{very-verbose => very_verbose}/README | 0 conf/sources/{very-verbose => very_verbose}/destination | 0 conf/sources/{very-verbose => very_verbose}/exclude | 0 conf/sources/{very-verbose => very_verbose}/source | 0 conf/sources/{very-verbose => very_verbose}/summary | 0 conf/sources/{very-verbose => very_verbose}/verbose | 0 conf/sources/{very-verbose => very_verbose}/very_verbose | 0 8 files changed, 1 insertion(+) rename conf/sources/{very-verbose => very_verbose}/README (100%) rename conf/sources/{very-verbose => very_verbose}/destination (100%) rename conf/sources/{very-verbose => very_verbose}/exclude (100%) rename conf/sources/{very-verbose => very_verbose}/source (100%) rename conf/sources/{very-verbose => very_verbose}/summary (100%) rename conf/sources/{very-verbose => very_verbose}/verbose (100%) rename conf/sources/{very-verbose => very_verbose}/very_verbose (100%) diff --git a/Makefile b/Makefile index db18f19..89003bb 100644 --- a/Makefile +++ b/Makefile @@ -199,6 +199,7 @@ test: ccollect.sh CCOLLECT_CONF=./conf ./ccollect.sh daily "source with spaces and interval" CCOLLECT_CONF=./conf ./ccollect.sh daily to-remote CCOLLECT_CONF=./conf ./ccollect.sh daily with_exec + CCOLLECT_CONF=./conf ./ccollect.sh daily very_verbose CCOLLECT_CONF=./conf ./ccollect.sh daily no-source-must-fail # for s in $$(ls ./conf/sources); do CCOLLECT_CONF=./conf echo ./ccollect.sh daily $$s; done # CCOLLECT_CONF=./conf ./ccollect.sh -a daily diff --git a/conf/sources/very-verbose/README b/conf/sources/very_verbose/README similarity index 100% rename from conf/sources/very-verbose/README rename to conf/sources/very_verbose/README diff --git a/conf/sources/very-verbose/destination b/conf/sources/very_verbose/destination similarity index 100% rename from conf/sources/very-verbose/destination rename to conf/sources/very_verbose/destination diff --git a/conf/sources/very-verbose/exclude b/conf/sources/very_verbose/exclude similarity index 100% rename from conf/sources/very-verbose/exclude rename to conf/sources/very_verbose/exclude diff --git a/conf/sources/very-verbose/source b/conf/sources/very_verbose/source similarity index 100% rename from conf/sources/very-verbose/source rename to conf/sources/very_verbose/source diff --git a/conf/sources/very-verbose/summary b/conf/sources/very_verbose/summary similarity index 100% rename from conf/sources/very-verbose/summary rename to conf/sources/very_verbose/summary diff --git a/conf/sources/very-verbose/verbose b/conf/sources/very_verbose/verbose similarity index 100% rename from conf/sources/very-verbose/verbose rename to conf/sources/very_verbose/verbose diff --git a/conf/sources/very-verbose/very_verbose b/conf/sources/very_verbose/very_verbose similarity index 100% rename from conf/sources/very-verbose/very_verbose rename to conf/sources/very_verbose/very_verbose From 9aa111d21b4a69f2f630d63376c6e38c4176507e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 28 Jul 2009 07:46:43 +0200 Subject: [PATCH 375/581] export TMP to subscripts Signed-off-by: Nico Schottelius --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index 80e893f..1613b59 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -39,7 +39,7 @@ CDEFAULTS="${CCOLLECT_CONF}/defaults" CPREEXEC="${CDEFAULTS}/pre_exec" CPOSTEXEC="${CDEFAULTS}/post_exec" -TMP=$(mktemp "/tmp/${__myname}.XXXXXX") +export TMP=$(mktemp "/tmp/${__myname}.XXXXXX") VERSION="0.8" RELEASE="2009-08-XX" HALF_VERSION="ccollect ${VERSION}" From e6a0300b9b2ef4e556cf3374bf901aef10f5491f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 28 Jul 2009 07:47:48 +0200 Subject: [PATCH 376/581] Simplify removal code Signed-off-by: Nico Schottelius --- ccollect.sh | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 1613b59..a6d4871 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -250,6 +250,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # Start subshell for easy log editing # ( + backup="${CSOURCES}/${name}" # # Stderr to stdout, so we can produce nice logs # @@ -278,7 +279,6 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Read / create configuration # - backup="${CSOURCES}/${name}" c_source="${backup}/source" c_dest="${backup}/destination" c_pre_exec="${backup}/pre_exec" @@ -459,20 +459,16 @@ while [ "${i}" -lt "${no_sources}" ]; do head -n "${remove}" > "${TMP}" || \ _exit_err "Listing old backups failed" - i=0 - while read to_remove; do - eval remove_$i=\"${to_remove}\" - i="$(($i+1))" - done < "${TMP}" - - j=0 - while [ "${j}" -lt "${i}" ]; do - eval to_remove=\"\$remove_$j\" - _techo "Removing ${to_remove} ..." - pcmd rm ${VVERBOSE} -rf "${ddir}/${to_remove}" || \ - _exit_err "Removing ${to_remove} failed." - j="$(($j+1))" - done + # + # ssh-"feature": we cannot do '... read ...; ssh ...; < file', + # because ssh reads stdin! -n does not work -> does not ask for password + # + ( + set -- "" + while read to_remove; do set -- "$@" "${ddir}/${to_remove}"; done < "${TMP}" + _techo "Removing $@ ..." + pcmd rm ${VVERBOSE} -rf "$@" + ) || _exit_err "Removing $@ failed." fi # From 4ba0dab26013ad6be299307435dcc07cc4ea0a91 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 28 Jul 2009 12:43:23 +0200 Subject: [PATCH 377/581] Create function 'delete_from_file()' Signed-off-by: Nico Schottelius --- ccollect.sh | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index a6d4871..54ac550 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -98,6 +98,18 @@ pcmd() fi } +delete_from_file() +{ + # + # ssh-"feature": we cannot do '... read ...; ssh ...; < file', + # because ssh reads stdin! -n does not work -> does not ask for password + # + file="$1"; shift + while read to_remove; do set -- "$@" "${ddir}/${to_remove}"; done < "${file}" + _techo "Removing $@ ..." + pcmd rm ${VVERBOSE} -rf "$@" || _exit_err "Removing $@ failed." +} + display_version() { echo "${FULL_VERSION}" @@ -283,7 +295,7 @@ while [ "${i}" -lt "${no_sources}" ]; do c_dest="${backup}/destination" c_pre_exec="${backup}/pre_exec" c_post_exec="${backup}/post_exec" - c_marker=".ccollect-marker" + c_marker="ccollect-marker" for opt in exclude verbose very_verbose rsync_options summary delete_incomplete \ remote_host rsync_failure_codes mtime quiet_if_down ; do if [ -f "${backup}/${opt}" -o -f "${backup}/no_${opt}" ]; then @@ -414,19 +426,19 @@ while [ "${i}" -lt "${no_sources}" ]; do ( pcmd cd "${ddir}" ) || _exit_err "Cannot change to ${ddir}. Skipping." # - # Check: incomplete backups? + # Check: incomplete backups? (needs echo to remove newlines) # - pcmd ls -1 "${ddir}/"*".${c_marker}" 2>/dev/null | while read marker; do - incomplete="$(echo ${marker} | sed "s/\\.${c_marker}\$//")" - _techo "Incomplete backup: ${incomplete}" + incomplete="$(echo \ + $(pcmd ls -1 "${ddir}/" | \ + awk "/\.${c_marker}\$/ { print \$0; gsub(\"\.${c_marker}\$\",\"\",\$0); print \$0 }" | \ + tee "${TMP}"))" + + if [ "${incomplete}" ]; then + _techo "Incomplete backups: ${incomplete}" if [ -f "${c_delete_incomplete}" ]; then - _techo "Deleting ${incomplete} ..." - pcmd rm $VVERBOSE -rf "${incomplete}" || \ - _exit_err "Removing ${incomplete} failed." - pcmd rm $VVERBOSE -f "${marker}" || \ - _exit_err "Removing ${marker} failed." + delete_from_file "${TMP}" fi - done + fi # # Interval definition: First try source specific, fallback to default @@ -459,16 +471,7 @@ while [ "${i}" -lt "${no_sources}" ]; do head -n "${remove}" > "${TMP}" || \ _exit_err "Listing old backups failed" - # - # ssh-"feature": we cannot do '... read ...; ssh ...; < file', - # because ssh reads stdin! -n does not work -> does not ask for password - # - ( - set -- "" - while read to_remove; do set -- "$@" "${ddir}/${to_remove}"; done < "${TMP}" - _techo "Removing $@ ..." - pcmd rm ${VVERBOSE} -rf "$@" - ) || _exit_err "Removing $@ failed." + delete_from_file "${TMP}" fi # @@ -531,7 +534,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # if [ -z "$fail" ]; then pcmd rm "${destination_dir}.${c_marker}" || \ - _exit_err "Removing ${destination_dir}/${c_marker} failed." + _exit_err "Removing ${destination_dir}.${c_marker} failed." if [ "${ret}" -ne 0 ]; then _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." fi From 50dcd80b858e28376758661e25151ac13fc7b997 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 28 Jul 2009 17:05:04 +0200 Subject: [PATCH 378/581] add source, which deletes incomplete backups Signed-off-by: Nico Schottelius --- conf/sources/delete_incomplete/delete_incomplete | 0 conf/sources/delete_incomplete/destination | 1 + conf/sources/delete_incomplete/exclude | 1 + conf/sources/delete_incomplete/source | 1 + 4 files changed, 3 insertions(+) create mode 100644 conf/sources/delete_incomplete/delete_incomplete create mode 100644 conf/sources/delete_incomplete/destination create mode 100644 conf/sources/delete_incomplete/exclude create mode 100644 conf/sources/delete_incomplete/source diff --git a/conf/sources/delete_incomplete/delete_incomplete b/conf/sources/delete_incomplete/delete_incomplete new file mode 100644 index 0000000..e69de29 diff --git a/conf/sources/delete_incomplete/destination b/conf/sources/delete_incomplete/destination new file mode 100644 index 0000000..8cac69d --- /dev/null +++ b/conf/sources/delete_incomplete/destination @@ -0,0 +1 @@ +/tmp/ccollect diff --git a/conf/sources/delete_incomplete/exclude b/conf/sources/delete_incomplete/exclude new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/conf/sources/delete_incomplete/exclude @@ -0,0 +1 @@ +.git diff --git a/conf/sources/delete_incomplete/source b/conf/sources/delete_incomplete/source new file mode 100644 index 0000000..e64611b --- /dev/null +++ b/conf/sources/delete_incomplete/source @@ -0,0 +1 @@ +/home/users/nico/bin From 4b560f64f4f08f3d1bdc45c7ff8557d5eb8f0964 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 28 Jul 2009 17:09:34 +0200 Subject: [PATCH 379/581] Test: include removal of incomplete backups Signed-off-by: Nico Schottelius --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 89003bb..82bab0e 100644 --- a/Makefile +++ b/Makefile @@ -200,6 +200,8 @@ test: ccollect.sh CCOLLECT_CONF=./conf ./ccollect.sh daily to-remote CCOLLECT_CONF=./conf ./ccollect.sh daily with_exec CCOLLECT_CONF=./conf ./ccollect.sh daily very_verbose + touch /tmp/ccollect/$$(ls /tmp/ccollect | head -n1).ccollect-marker + CCOLLECT_CONF=./conf ./ccollect.sh daily delete_incomplete CCOLLECT_CONF=./conf ./ccollect.sh daily no-source-must-fail # for s in $$(ls ./conf/sources); do CCOLLECT_CONF=./conf echo ./ccollect.sh daily $$s; done # CCOLLECT_CONF=./conf ./ccollect.sh -a daily From ba11374c6f87018ed2350160adc3ec1d25a8624b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 28 Jul 2009 17:09:56 +0200 Subject: [PATCH 380/581] DOC: cosmetic changes Signed-off-by: Nico Schottelius --- doc/ccollect.text | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 1a9db04..73f35ca 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -591,7 +591,7 @@ Detailed description of "mtime" By default, ccollect.sh chooses the most recent backup directory for cloning or the oldest for deletion based on the directory's last change time (ctime). With this option, the sorting is done based on modification time (mtime). With -this version of ccollect.sh, the ctime and mtime of your backups will normally +this version of ccollect, the ctime and mtime of your backups will normally be the same and this option has no effect. However, if you, for example, move your backups to another hard disk using cp -a or rsync -a, you should use this option because the ctimes are not preserved during such operations. @@ -602,11 +602,12 @@ earlier, do not use this option. Detailed description of "quiet_if_down" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ By default, ccollect.sh emits a series of error messages if a source is not -connectable. With this option enabled, ccollect.sh still reports that the +connectable. With this option enabled, ccollect still reports that the source is not connectable but the associated error messages generated by rsync or ssh are suppressed. You may want to use this option for sources, like notebook PCs, that are often disconnected. + Hints ----- From 4696590a73fb3a07bedcdfec1b655bd32f1df815 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 28 Jul 2009 17:16:13 +0200 Subject: [PATCH 381/581] Create SDATE, similar to DDATE and CDATE Signed-off-by: Nico Schottelius --- ccollect.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 54ac550..d3f1737 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -51,6 +51,7 @@ FULL_VERSION="ccollect ${VERSION} (${RELEASE})" # CDATE="date +%Y%m%d-%H%M" DDATE="date +%Y-%m-%d-%H:%M:%S" +SDATE="date +%s" # # unset values @@ -271,7 +272,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Record start of backup: internal and for the user # - begin_s="$(date +%s)" + begin_s="$(${SDATE})" _techo "Beginning to backup" # @@ -556,7 +557,7 @@ while [ "${i}" -lt "${no_sources}" ]; do fi # Calculation - end_s="$(date +%s)" + end_s="$(${SDATE})" full_seconds="$((${end_s} - ${begin_s}))" hours="$((${full_seconds} / 3600))" From 852155a4dbab012719edb92b8a6ae6035959d289 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 29 Jul 2009 08:33:59 +0200 Subject: [PATCH 382/581] Update changes list: +6 changes Signed-off-by: Nico Schottelius --- doc/changes/next | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/changes/next b/doc/changes/next index 4ff4cba..6024003 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -4,3 +4,9 @@ * Some code cleanups (argument parsing, usage) (Nico Schottelius) * Only consider directories as sources when using -a (Nico Schottelius) * Fix general parsing problem with -a (Nico Schottelius) +* Fix potential bug when using remote_host, delete_incomplete and ssh (Nico Schottelius) +* Improve removal performance: minimised number of 'rm' calls (Nico Schottelius) +* Support sorting by mtime (John Lawless) +* Improve option handling (John Lawless) +* Add support for quiet operation for dead devices (quiet_if_down) (John Lawless) +* Add smart option parsing (John Lawless) From aeb3ff6d895726e6a71b22840eec0c48552b7e42 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 29 Jul 2009 08:42:25 +0200 Subject: [PATCH 383/581] john also introduced default option support Signed-off-by: Nico Schottelius --- doc/changes/next | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changes/next b/doc/changes/next index 6024003..b30c916 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -9,4 +9,4 @@ * Support sorting by mtime (John Lawless) * Improve option handling (John Lawless) * Add support for quiet operation for dead devices (quiet_if_down) (John Lawless) -* Add smart option parsing (John Lawless) +* Add smart option parsing, including support for default values (John Lawless) From ab74059c779194b09c4ac5ecbd6ab19f4b26fec8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 29 Jul 2009 08:46:22 +0200 Subject: [PATCH 384/581] Documentate changes from 0.7 to 0.8 Signed-off-by: Nico Schottelius --- doc/ccollect.text | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 73f35ca..285cc45 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -36,7 +36,7 @@ Why you COULD only backup from remote hosts, not to them ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ While considering the design of ccollect, I thought about enabling backup to *remote* hosts. Though this sounds like a nice feature -('Backup my notebook to the server now.'), in my opinion it is a +('"Backup my notebook to the server now."'), in my opinion it is a bad idea to backup to a remote host. But as more and more people requested this feature, it was implemented, @@ -68,10 +68,28 @@ machine, she will not be able to log in on the backup machine. All other backups are still secure. -Incompatibilities -~~~~~~~~~~~~~~~~~ +Incompatibilities and changes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Versions 0.7 and 0.8 +^^^^^^^^^^^^^^^^^^^^^ + +.The argument order changed: +- Old: " [args] " +- New: "[args] " + +If you did not use arguments (most people do not), nothing will +change for you. + +.Deletion of incomplete backups using the 'delete_incomplete' option +- Old: Only incomplete backups from the current interval have been removed +- New: All incomplete backups are deleted + +.Support for standard values +- Old: no support +- New: Options in $CCOLLECT_CONF/defaults are used as defaults (see below) + Versions 0.6 and 0.7 ^^^^^^^^^^^^^^^^^^^^^ .The format of `destination` changed: From 3431646fbacdaa55781895548d39fcc715c551a0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 29 Jul 2009 08:49:05 +0200 Subject: [PATCH 385/581] update document version to 0.8 Signed-off-by: Nico Schottelius --- doc/ccollect.text | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 285cc45..1c0fc88 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -0.7.1, for ccollect 0.7.1, Initial Version from 2006-01-13 +0.8, for ccollect 0.8, Initial Version from 2006-01-13 :Author Initials: NS @@ -159,7 +159,7 @@ For those who do not want to read the whole long document: -------------------------------------------------------------------------------- # get latest ccollect tarball from http://www.nico.schottelius.org/software/ccollect/ # replace value for CCV with the current version -export CCV=0.7.1 +export CCV=0.8 # # replace 'wget' with 'fetch' on bsd From 3231acf525836670843c493f31d39aea1bcb44d2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 29 Jul 2009 09:08:38 +0200 Subject: [PATCH 386/581] config: add default option and disable it for one source Signed-off-by: Nico Schottelius --- conf/defaults/verbose | 0 conf/sources/local/no_verbose | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 conf/defaults/verbose create mode 100644 conf/sources/local/no_verbose diff --git a/conf/defaults/verbose b/conf/defaults/verbose new file mode 100644 index 0000000..e69de29 diff --git a/conf/sources/local/no_verbose b/conf/sources/local/no_verbose new file mode 100644 index 0000000..e69de29 From 02670a813ce40655cc0f7f17cfdc54f9838aef27 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 29 Jul 2009 09:10:30 +0200 Subject: [PATCH 387/581] synchronise order of options in ccollect with documentation Signed-off-by: Nico Schottelius --- ccollect.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index d3f1737..278e12a 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -297,9 +297,10 @@ while [ "${i}" -lt "${no_sources}" ]; do c_pre_exec="${backup}/pre_exec" c_post_exec="${backup}/post_exec" c_marker="ccollect-marker" - for opt in exclude verbose very_verbose rsync_options summary delete_incomplete \ - remote_host rsync_failure_codes mtime quiet_if_down ; do - if [ -f "${backup}/${opt}" -o -f "${backup}/no_${opt}" ]; then + for opt in verbose very_verbose summary exclude rsync_options \ + delete_incomplete remote_host rsync_failure_codes \ + mtime quiet_if_down ; do + if [ -f "${backup}/${opt}" -o -f "${backup}/no_${opt}" ]; then eval c_$opt=\"${backup}/$opt\" else eval c_$opt=\"${CDEFAULTS}/$opt\" From 48e181674a9ac4ccddd14c63e94a4bcbb8bf81a9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 29 Jul 2009 09:16:51 +0200 Subject: [PATCH 388/581] Documentation updates and introduce new section 'Default options' Signed-off-by: Nico Schottelius --- doc/ccollect.text | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 1c0fc88..4787053 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -247,9 +247,9 @@ Using ccollect Installing ---------- Either type 'make install' or simply copy it to a directory in your -$PATH and execute 'chmod *0755* /path/to/ccollect.sh'. If you would -like to use the new management scripts (available since 0.6), copy -the following scripts to a directory in $PATH: +$PATH and execute 'chmod *0755* /path/to/ccollect.sh'. If you like +to use the new management scripts (available since 0.6), copy the +following scripts to a directory in $PATH: - `tools/ccollect_add_source.sh` - `tools/ccollect_analyse_logs.sh.sh` @@ -297,7 +297,8 @@ The general configuration can be found in $CCOLLECT_CONF/defaults or all source definitions, although the values can be overwritten in the source configuration. -All configuration entries are plain-text files (use UTF-8 for non-ascii characters). +All configuration entries are plain-text files +(use UTF-8 for non-ascii characters). Interval definition @@ -344,13 +345,6 @@ human readable format before and after the whole backup process: ------------------------------------------------------------------------- -General delete_incomplete -^^^^^^^^^^^^^^^^^^^^^^^^^ -If you add '$CCOLLECT_CONF/defaults/`delete_incomplete`', this -option applies for all sources. See below for a longer -explanation. - - Source configuration ~~~~~~~~~~~~~~~~~~~~ Each source configuration exists in '$CCOLLECT_CONF/sources/$name' or @@ -365,6 +359,9 @@ Each source contains at least the following files: Additionally a source may have the following files: + - `pre_exec` program to execute before backing up *this* source + - `post_exec` program to execute after backing up *this* source + - `verbose` whether to be verbose (passes -v to `rsync`) - `very_verbose` be very verbose (`mkdir -v`, `rm -v` and `rsync -vv`) - `summary` create a transfer summary when `rsync` finished @@ -372,9 +369,6 @@ Additionally a source may have the following files: - `exclude` exclude list for `rsync`. newline seperated list. - `rsync_options` extra options for `rsync`. newline seperated list. - - `pre_exec` program to execute before backing up *this* source - - `post_exec` program to execute after backing up *this* source - - `delete_incomplete` delete incomplete backups - `remote_host` host to backup to - `rsync_failure_codes` list of rsync exit codes that indicate complete failure @@ -403,6 +397,31 @@ Example: /home/nico/vpn -------------------------------------------------------------------------------- +Default options +^^^^^^^^^^^^^^^ +If you add '$CCOLLECT_CONF/defaults/`option_name`', the value will +be used in abscence of the option in a source. If you want to prevent +the default value to be used in a source, you can create the file +'$CCOLLECT_CONF/sources/$name/`no_option_name`' (i.e. prefix it with +'no_'. + +Example: +-------------------------------------------------------------------------------- + [9:04] ikn2:ccollect% touch conf/defaults/verbose + [9:04] ikn2:ccollect% touch conf/sources/local/no_verbose +-------------------------------------------------------------------------------- +This enables the verbose option for all sources, but disables it for the +source 'local'. + +If an option is specified in the defaults folder and in the source, +the source specific version overrides the default one: + +Example: +-------------------------------------------------------------------------------- + [9:05] ikn2:ccollect% echo "backup-host" > conf/defaults/remote_host + [9:05] ikn2:ccollect% echo "different-host" > conf/sources/local/remote_host +-------------------------------------------------------------------------------- + Detailed description of "source" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From cf1459251e77e067e067222212bfe116f7ffd2ff Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 29 Jul 2009 09:22:42 +0200 Subject: [PATCH 389/581] specifiy, which options can be used as defaults Signed-off-by: Nico Schottelius --- doc/ccollect.text | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 4787053..720bcc8 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -422,6 +422,12 @@ Example: [9:05] ikn2:ccollect% echo "different-host" > conf/sources/local/remote_host -------------------------------------------------------------------------------- +You can use all source options as defaults, with the exception of + +- `source` +- `destination` +- `pre_exec` +- `post_exec` Detailed description of "source" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -474,7 +480,7 @@ Detailed description of "verbose" If this file exists in the source specification *-v* will be passed to `rsync`. -` + Example: -------------------------------------------------------------------------------- [11:35] zaphodbeeblebrox:ccollect-0.2% touch conf/sources/testsource1/verbose From 56879ed9fbe1412a0a847ad5541e3fc0b86f3d67 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 29 Jul 2009 09:24:50 +0200 Subject: [PATCH 390/581] even more changes Signed-off-by: Nico Schottelius --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changes/next b/doc/changes/next index b30c916..816d77c 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -10,3 +10,4 @@ * Improve option handling (John Lawless) * Add support for quiet operation for dead devices (quiet_if_down) (John Lawless) * Add smart option parsing, including support for default values (John Lawless) +* Updated and cleaned up documentation (Nico Schottelius) From 3abea41ffa1b787f2b6f13d5017024822d2799fc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 3 Aug 2009 12:22:39 +0200 Subject: [PATCH 391/581] Copy the correct COPYING file (replaced wrong LGPL3 with GPL3) Signed-off-by: Nico Schottelius --- COPYING | 757 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 633 insertions(+), 124 deletions(-) diff --git a/COPYING b/COPYING index fc8a5de..94a9ed0 100644 --- a/COPYING +++ b/COPYING @@ -1,165 +1,674 @@ - GNU LESSER GENERAL PUBLIC LICENSE + GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + Preamble - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. + The GNU General Public License is a free, copyleft license for +software and other kinds of works. - 0. Additional Definitions. + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. - 1. Exception to Section 3 of the GNU GPL. + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. + The precise terms and conditions for copying, distribution and +modification follow. - 2. Conveying Modified Versions. + TERMS AND CONDITIONS - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: + 0. Definitions. - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or + "This License" refers to version 3 of the GNU General Public License. - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. - 3. Object Code Incorporating Material from Library Header Files. + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. + A "covered work" means either the unmodified Program or a work based +on the Program. - b) Accompany the object code with a copy of the GNU GPL and this license - document. + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. - 4. Combined Works. + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. + 1. Source Code. - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. - d) Do one of the following: + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) + The Corresponding Source for a work in source code form is that +same work. - 5. Combined Libraries. + 2. Basic Permissions. - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. - 6. Revised Versions of the GNU Lesser General Public License. + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. From a08580fe7e45315adfa6d3c73e4f9316bd9a672f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 16 Aug 2009 13:39:39 +0200 Subject: [PATCH 392/581] add tool to archive the configuration Signed-off-by: Nico Schottelius --- tools/ccollect_archive_config.sh | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 tools/ccollect_archive_config.sh diff --git a/tools/ccollect_archive_config.sh b/tools/ccollect_archive_config.sh new file mode 100755 index 0000000..f42c88a --- /dev/null +++ b/tools/ccollect_archive_config.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# +# 2009 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# Write a tar containing the configuration +# + +# standard values +CCOLLECT_CONF="${CCOLLECT_CONF:-/etc/ccollect}" + +self="$(basename $0)" + +# functions first +_echo() +{ + echo "${self}> $@" +} + +_exit_err() +{ + _echo "$@" + rm -f "$TMP" + exit 1 +} + +# argv +if [ $# -ne 1 ]; then + _echo "${self} " + _exit_err "Exiting." +fi + +file="$1" + +_echo "Creating $file ..." + +[ -d "${CCOLLECT_CONF}" ] || _exit_err "No configuration in $CCOLLECT_CONF" + +tar cf "$file" "${CCOLLECT_CONF}" From b749a05473e63778436188314fa0bd5f9f5ecc29 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 20 Aug 2009 09:46:38 +0200 Subject: [PATCH 393/581] a bugfix into the next release Signed-off-by: Nico Schottelius --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changes/next b/doc/changes/next index 816d77c..75f9a63 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -11,3 +11,4 @@ * Add support for quiet operation for dead devices (quiet_if_down) (John Lawless) * Add smart option parsing, including support for default values (John Lawless) * Updated and cleaned up documentation (Nico Schottelius) +* Fixed bug "removal of current directory" in ccollect_delete_source.sh (Found by Günter Stöhr, fixed by Nico Schottelius) From 0f7a6a88efd607a8d1f8dd57b06664cfc74aa387 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 20 Aug 2009 09:49:47 +0200 Subject: [PATCH 394/581] [BUGFIX (untested)] fix current directory removal Signed-off-by: Nico Schottelius --- tools/ccollect_delete_source.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/ccollect_delete_source.sh b/tools/ccollect_delete_source.sh index 636ce67..509e95f 100755 --- a/tools/ccollect_delete_source.sh +++ b/tools/ccollect_delete_source.sh @@ -71,7 +71,6 @@ while [ $# -gt 0 ]; do _exit_err "Unknown option: $1" ;; esac - fi # Reached here? So there are no more parameters. @@ -97,13 +96,13 @@ while [ $# -gt 0 ]; do if [ "$backups" ]; then ddir="$(cat "${fullname}/destination")" - addir="$(cd && pwd -P)" || _exit_err "Cannot change to ${ddir}" - _echo "Deleting ${addir} ..." - rm -r $force "${addir}" + absdir="$(cd "${ddir}" && pwd -P)" || _exit_err "Cannot change to ${ddir}" + _echo "Deleting ${absdir} ..." + echo rm -r $force "${absdir}" fi _echo "Deleting ${fullname} ..." - rm -r $force "${fullname}" + echo rm -r $force "${fullname}" done exit 0 From f17023255cb1e9ffd2b10513862b05f1494b8459 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 20 Aug 2009 10:09:07 +0200 Subject: [PATCH 395/581] begin to write a test for the whole ccollect tools Signed-off-by: Nico Schottelius --- test/test-ccollect-tools.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/test-ccollect-tools.sh diff --git a/test/test-ccollect-tools.sh b/test/test-ccollect-tools.sh new file mode 100644 index 0000000..5980d04 --- /dev/null +++ b/test/test-ccollect-tools.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# +# 2009 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# +# Test the ccollect tools suite +# + +set -x + +tmp="$(mktemp /tmp/ccollect-tools.XXXXXXXXXXX)" + + +rm -rf "${tmp}" From 8cc833a7b19381515faac2d49b10b01157221313 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 20 Aug 2009 16:25:25 +0200 Subject: [PATCH 396/581] only change mtime of main dir, if sorting by mtime is selected Signed-off-by: Nico Schottelius --- ccollect.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 278e12a..d2f7ec7 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -515,9 +515,9 @@ while [ "${i}" -lt "${no_sources}" ]; do _techo "Finished backup (rsync return code: $ret)." # - # Set modification time (mtime) to current time + # Set modification time (mtime) to current time, if sorting by mtime is enabled # - pcmd touch "${destination_dir}" + [ -f "$c_mtime" ] && pcmd touch "${destination_dir}" # # Check if rsync exit code indicates failure. From 26f4ae777b6fb6ee45501ba3359c51ffe99780fc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 20 Aug 2009 17:36:09 +0200 Subject: [PATCH 397/581] prepare release 0.8 Signed-off-by: Nico Schottelius --- ccollect.sh | 2 +- doc/changes/{next => 0.8} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename doc/changes/{next => 0.8} (100%) diff --git a/ccollect.sh b/ccollect.sh index d2f7ec7..13ceb33 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -41,7 +41,7 @@ CPOSTEXEC="${CDEFAULTS}/post_exec" export TMP=$(mktemp "/tmp/${__myname}.XXXXXX") VERSION="0.8" -RELEASE="2009-08-XX" +RELEASE="2009-08-20" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" diff --git a/doc/changes/next b/doc/changes/0.8 similarity index 100% rename from doc/changes/next rename to doc/changes/0.8 From f5493342260c6ead1e9b847317df917e0fe71967 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 21 Aug 2009 13:03:38 +0200 Subject: [PATCH 398/581] Add rsync arguments for source checking Fix proposed by Nikita Koshikov: -------------------------------------------------------------------------------- [...] [guard] + set -- --archive --delete --numeric-ids --relative --delete-excluded --sparse --stats -v [guard] + '[' -f /etc/ccollect/sources/guard/rsync_options ']' [guard] + read line [guard] + set -- --archive --delete --numeric-ids --relative --delete-excluded --sparse --stats -v --password-file=/etc/ccollect/passwd [guard] + read line [guard] + rsync backup@192.168.1.8::etc Password: In this place it's sit and waiting for password. If I comment out related ccollect code section everything start working as expected. I had to modify this part to be look like: if ! rsync "${source}" "$@" >/dev/null 2>"${TMP}" ; then if [ ! -f "${c_quiet_if_down}" ]; then cat "${TMP}" fi _exit_err "Source ${source} is not readable. Skipping." fi Then checking host activity is passed and backup process running successful. -------------------------------------------------------------------------------- Changed it to "$@" "$source" instead, to be consistent and use options before source. Signed-off-by: Nico Schottelius --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index 13ceb33..11998af 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -415,7 +415,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Check: source is up and accepting connections (before deleting old backups!) # - if ! rsync "${source}" >/dev/null 2>"${TMP}" ; then + if ! rsync "$@" "${source}" >/dev/null 2>"${TMP}" ; then if [ ! -f "${c_quiet_if_down}" ]; then cat "${TMP}" fi From 1f84f87888196b6b0aaf77d2aa298c9bb44ff7c4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 21 Aug 2009 13:05:49 +0200 Subject: [PATCH 399/581] changes for the next version Signed-off-by: Nico Schottelius --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changes/next diff --git a/doc/changes/next b/doc/changes/next new file mode 100644 index 0000000..b20d40c --- /dev/null +++ b/doc/changes/next @@ -0,0 +1 @@ +* Fix source-is-up check (Nikita Koshikov) From 59f880ea86530c3e506de5c293cd87531bfc62cd Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 21 Aug 2009 13:06:01 +0200 Subject: [PATCH 400/581] [DOC] fix typo Signed-off-by: Nico Schottelius --- doc/ccollect.text | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 720bcc8..100118b 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -620,6 +620,7 @@ If you create the file `delete_incomplete` in a source specification directory, was interrupted) and remove them. Without this file `ccollect` will only warn the user. + Detailed description of "rsync_failure_codes" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ If you have the file `rsync_failure_codes` in your source configuration @@ -629,6 +630,7 @@ be left in the destination directory indicating failure of this backup. If you have enabled delete_incomplete, then this backup will be deleted during the next ccollect run on the same interval. + Detailed description of "mtime" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ By default, ccollect.sh chooses the most recent backup directory for cloning or @@ -642,6 +644,7 @@ option because the ctimes are not preserved during such operations. If you have any backups in your repository made with ccollect version 0.7.1 or earlier, do not use this option. + Detailed description of "quiet_if_down" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ By default, ccollect.sh emits a series of error messages if a source is not @@ -825,7 +828,7 @@ If you want to see what changed between two backups, you can use [12:00] u0255:ddba034.netstream.ch# rsync -n -a --delete --stats --progress daily.20080324-0313.17841/ daily.20080325-0313.31148/ -------------------------------------------------------------------------------- This results in a listing of changes. Because we pass -n to rsync no transfer -is made (i.e. report only mode)" +is made (i.e. report only mode). This hint was reported by Daniel Aubry. From 93b56025fa560fb1c86bd48e884f2523603fafd6 Mon Sep 17 00:00:00 2001 From: Nikita Koshikov Date: Thu, 10 Sep 2009 12:48:28 +0200 Subject: [PATCH 401/581] Add ccollect rpm spec Thanks a lot, Nikita! --- contrib/ccollect.spec | 85 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 contrib/ccollect.spec diff --git a/contrib/ccollect.spec b/contrib/ccollect.spec new file mode 100644 index 0000000..477a878 --- /dev/null +++ b/contrib/ccollect.spec @@ -0,0 +1,85 @@ +Summary: (pseudo) incremental backup with different exclude lists using hardlinks and rsync +Name: ccollect +Version: 0.8 +Release: 0 +URL: http://www.nico.schottelius.org/software/ccollect +Source0: http://www.nico.schottelius.org/software/ccollect/%{name}-%{version}.tar.bz2 + +License: LGPL-3 +Group: Applications/System +Vendor: Nico Schottelius +BuildRoot: %{_tmppath}/%{name}-%(id -un) +BuildArch: noarch +Requires: rsync + +%description +Ccollect backups data from local and remote hosts to your local harddisk. +Although ccollect creates full backups, it requires very less space on the backup medium, because ccollect uses hardlinks to create an initial copy of the last backup. +Only the inodes used by the hardlinks and the changed files need additional space. + +%prep +%setup -q + +%install +rm -rf $RPM_BUILD_ROOT + +#Installing main ccollect.sh and /etc directory +%__install -d 755 %buildroot%_bindir +%__install -d 755 %buildroot%_sysconfdir/%name +%__install -m 755 ccollect.sh %buildroot%_bindir/ + +#bin files from tools directory +for t in $(ls tools/ccollect_*) ; do + %__install -m 755 ${t} %buildroot%_bindir/ +done + +#Configuration examples and docs +%__install -d 755 %buildroot%_datadir/doc/%name-%version/examples + +%__install -m 644 README %buildroot%_datadir/doc/%name-%version +%__install -m 644 COPYING %buildroot%_datadir/doc/%name-%version +%__install -m 644 CREDITS %buildroot%_datadir/doc/%name-%version +%__install -m 644 conf/README %buildroot%_datadir/doc/%name-%version/examples +%__cp -pr conf/defaults %buildroot%_datadir/doc/%name-%version/examples/ +%__cp -pr conf/sources %buildroot%_datadir/doc/%name-%version/examples/ + +#Addition documentation and some config tools +%__install -d 755 %buildroot%_datadir/%name/tools +%__cp -pr tools/config-pre-* %buildroot%_datadir/%name/tools +%__install -m 755 tools/gnu-du-backup-size-compare.sh %buildroot%_datadir/%name/tools +%__install -m 755 tools/report_success.sh %buildroot%_datadir/%name/tools + +%clean +rm -rf $RPM_BUILD_ROOT + +%post +%__ln_s %_bindir/ccollect.sh %_bindir/ccollect + +%preun +unlink %_bindir/ccollect + +%files +%defattr(-,root,root) +%_bindir/ccollect* +%_datadir/doc/%name-%version +%_datadir/%name/tools +%docdir %_datadir/doc/%name-%version +%dir %_sysconfdir/%name + +%changelog +* Thu Aug 20 2009 Nico Schottelius 0.8 +- Introduce consistenst time sorting (John Lawless) +- Check for source connectivity before trying backup (John Lawless) +- Defensive programming patch (John Lawless) +- Some code cleanups (argument parsing, usage) (Nico Schottelius) +- Only consider directories as sources when using -a (Nico Schottelius) +- Fix general parsing problem with -a (Nico Schottelius) +- Fix potential bug when using remote_host, delete_incomplete and ssh (Nico Schottelius) +- Improve removal performance: minimised number of 'rm' calls (Nico Schottelius) +- Support sorting by mtime (John Lawless) +- Improve option handling (John Lawless) +- Add support for quiet operation for dead devices (quiet_if_down) (John Lawless) +- Add smart option parsing, including support for default values (John Lawless) +- Updated and cleaned up documentation (Nico Schottelius) +- Fixed bug "removal of current directory" in ccollect_delete_source.sh (Found by G????nter St????hr, fixed by Nico Schottelius) + From 5d41dea79dad7e0a69fa78270f38d6aceed5d86e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 12 Oct 2009 08:04:22 +0200 Subject: [PATCH 402/581] update manpage of ccollect: update argument order Signed-off-by: Nico Schottelius --- doc/man/ccollect.text | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/man/ccollect.text b/doc/man/ccollect.text index 84e95bb..84c1e37 100644 --- a/doc/man/ccollect.text +++ b/doc/man/ccollect.text @@ -10,7 +10,7 @@ ccollect - (pseudo) incremental backup with different exclude lists using hardli SYNOPSIS -------- -'ccollect.sh' [args] +'ccollect.sh' [args] DESCRIPTION @@ -36,7 +36,10 @@ OPTIONS Backup all sources specified in /etc/ccollect/sources -v, --verbose:: - Be very verbose (uses set -x). + Be very verbose (uses set -x) + +-V, --version:: + Show version and exit SEE ALSO From 9eba4e8b8e28d4b43d305ee399bd88bb6bdc6308 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 25 Oct 2009 15:21:19 +0100 Subject: [PATCH 403/581] update destination directory Signed-off-by: Nico Schottelius --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 82bab0e..cfef1b4 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ path_destination=${path_dir}/${CCOLLECT_DEST} # where to publish host=localhost -dir=/home/users/nico/privat/computer/net/netzseiten/www.nico.schottelius.org/src/software/ccollect +dir=/home/users/nico/privat/rechner/netz/seiten/www.nico.schottelius.org/src/software/ccollect docdir=${dir}/doc # From 25d8a2e2fb8a193ecfcb7f60ee8fb702d5201c64 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 25 Oct 2009 15:24:18 +0100 Subject: [PATCH 404/581] remove double --help section Signed-off-by: Nico Schottelius --- ccollect.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 11998af..db350a6 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -152,9 +152,6 @@ while [ "$#" -ge 1 ]; do -p|--parallel) PARALLEL=1 ;; - -h|--help) - usage - ;; -V|--version) display_version ;; From 23b2fcee08745f7cac748d532cad51d1616a4ff9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 25 Oct 2009 15:26:17 +0100 Subject: [PATCH 405/581] move -* check at the right location Signed-off-by: Nico Schottelius --- ccollect.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index db350a6..ca4e890 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -155,14 +155,14 @@ while [ "$#" -ge 1 ]; do -V|--version) display_version ;; - -h|--help|-*) - usage - ;; --) # ignore the -- itself shift break ;; + -h|--help|-*) + usage + ;; *) break ;; From 9d94beec68886517a0104bdebbed248484ee7f3a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 25 Oct 2009 15:27:11 +0100 Subject: [PATCH 406/581] more changes for the next version Signed-off-by: Nico Schottelius --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changes/next b/doc/changes/next index b20d40c..7a344a1 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -1 +1,2 @@ * Fix source-is-up check (Nikita Koshikov) +* Fix some minor command line parsing issues (Nico Schottelius) From 36f413173aa3e1cc4453f4799c331258fd430bd3 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 25 Oct 2009 15:30:55 +0100 Subject: [PATCH 407/581] minor argument reordering - beautify Signed-off-by: Nico Schottelius --- ccollect.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index ca4e890..3d13bfc 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -125,8 +125,8 @@ ${__myname}: [args] ccollect creates (pseudo) incremental backups -h, --help: Show this help screen - -p, --parallel: Parallelise backup processes -a, --all: Backup all sources specified in ${CSOURCES} + -p, --parallel: Parallelise backup processes -v, --verbose: Be very verbose (uses set -x) -V, --version: Print version information @@ -146,12 +146,12 @@ while [ "$#" -ge 1 ]; do -a|--all) USE_ALL=1 ;; - -v|--verbose) - set -x - ;; -p|--parallel) PARALLEL=1 ;; + -v|--verbose) + set -x + ;; -V|--version) display_version ;; From 422b22049436ce322fbde6cef9f01fc1a3214717 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 25 Oct 2009 15:40:37 +0100 Subject: [PATCH 408/581] more smaller cleanups Signed-off-by: Nico Schottelius --- ccollect.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 3d13bfc..f4fc319 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -195,9 +195,8 @@ if [ "${USE_ALL}" = 1 ]; then # # Get sources from source configuration # - ( cd "${CSOURCES}" && ls -1 > "${TMP}" ); ret=$? - - [ "${ret}" -eq 0 ] || _exit_err "Listing of sources failed. Aborting." + ( cd "${CSOURCES}" && ls -1 > "${TMP}" ) || \ + _exit_err "Listing of sources failed. Aborting." while read tmp; do eval export source_${no_sources}=\"${tmp}\" @@ -235,8 +234,9 @@ if [ -x "${CPREEXEC}" ]; then [ "${ret}" -eq 0 ] || _exit_err "${CPREEXEC} failed. Aborting" fi +################################################################################ # -# Let's do the backup +# Let's do the backup - here begins the real stuff # i=0 while [ "${i}" -lt "${no_sources}" ]; do @@ -249,7 +249,7 @@ while [ "${i}" -lt "${no_sources}" ]; do export name # - # start ourself, if we want parallel execution + # Start ourself, if we want parallel execution # if [ "${PARALLEL}" ]; then "$0" "${INTERVAL}" "${name}" & From 229e25148218f4204f60475b84701df147d0f12e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 25 Oct 2009 15:40:57 +0100 Subject: [PATCH 409/581] report about whole path, not the backup name Signed-off-by: Nico Schottelius --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index f4fc319..25aba17 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -283,7 +283,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # Configuration _must_ be a directory (cconfig style) # if [ ! -d "${backup}" ]; then - _exit_err "\"${name}\" is not a cconfig-directory. Skipping." + _exit_err "\"${backup}\" is not a cconfig-directory. Skipping." fi # From e8a977720f8ca18f5cdec17a96e257af907522ae Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 25 Oct 2009 15:44:16 +0100 Subject: [PATCH 410/581] one more bugfix for the next release Signed-off-by: Nico Schottelius --- doc/changes/next | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/changes/next b/doc/changes/next index 7a344a1..5605242 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -1,2 +1,3 @@ -* Fix source-is-up check (Nikita Koshikov) -* Fix some minor command line parsing issues (Nico Schottelius) + * Fix source-is-up check (Nikita Koshikov) + * Fix some minor command line parsing issues (Nico Schottelius) + * Correct output, if configuration is not in cconfig format (Nico Schottelius) From d7c4834dce8ab37b46bf369149a1198335b9690a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 25 Oct 2009 19:34:13 +0100 Subject: [PATCH 411/581] move c_marker to the global section, it's not specfic to a source Signed-off-by: Nico Schottelius --- ccollect.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 25aba17..b1c85ee 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -38,6 +38,7 @@ CSOURCES="${CCOLLECT_CONF}/sources" CDEFAULTS="${CCOLLECT_CONF}/defaults" CPREEXEC="${CDEFAULTS}/pre_exec" CPOSTEXEC="${CDEFAULTS}/post_exec" +CMARKER="ccollect-marker" export TMP=$(mktemp "/tmp/${__myname}.XXXXXX") VERSION="0.8" @@ -293,7 +294,6 @@ while [ "${i}" -lt "${no_sources}" ]; do c_dest="${backup}/destination" c_pre_exec="${backup}/pre_exec" c_post_exec="${backup}/post_exec" - c_marker="ccollect-marker" for opt in verbose very_verbose summary exclude rsync_options \ delete_incomplete remote_host rsync_failure_codes \ mtime quiet_if_down ; do @@ -429,7 +429,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # incomplete="$(echo \ $(pcmd ls -1 "${ddir}/" | \ - awk "/\.${c_marker}\$/ { print \$0; gsub(\"\.${c_marker}\$\",\"\",\$0); print \$0 }" | \ + awk "/\.${CMARKER}\$/ { print \$0; gsub(\"\.${CMARKER}\$\",\"\",\$0); print \$0 }" | \ tee "${TMP}"))" if [ "${incomplete}" ]; then @@ -502,7 +502,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # # added marking in 0.6 (and remove it, if successful later) # - pcmd touch "${destination_dir}.${c_marker}" + pcmd touch "${destination_dir}.${CMARKER}" # # the rsync part @@ -532,8 +532,8 @@ while [ "${i}" -lt "${no_sources}" ]; do # Remove marking here unless rsync failed. # if [ -z "$fail" ]; then - pcmd rm "${destination_dir}.${c_marker}" || \ - _exit_err "Removing ${destination_dir}.${c_marker} failed." + pcmd rm "${destination_dir}.${CMARKER}" || \ + _exit_err "Removing ${destination_dir}.${CMARKER} failed." if [ "${ret}" -ne 0 ]; then _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." fi From 1c8a0808a6868629cfc9c7f4282153f2cd22488b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 25 Oct 2009 19:37:36 +0100 Subject: [PATCH 412/581] and more stuff for the next release Signed-off-by: Nico Schottelius --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changes/next b/doc/changes/next index 5605242..d321d1e 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -1,3 +1,4 @@ * Fix source-is-up check (Nikita Koshikov) * Fix some minor command line parsing issues (Nico Schottelius) * Correct output, if configuration is not in cconfig format (Nico Schottelius) + * Minor code cleanups and optimisations (Nico Schottelius) From 3d571e915a716ddc563b5f6c97a3335dc65e9394 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 25 Oct 2009 19:50:04 +0100 Subject: [PATCH 413/581] add braces Signed-off-by: Nico Schottelius --- ccollect.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index b1c85ee..0c478ab 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -307,7 +307,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Sort by ctime (default) or mtime (configuration option) # - if [ -f "$c_mtime" ] ; then + if [ -f "${c_mtime}" ] ; then TSORT="t" else TSORT="tc" @@ -525,7 +525,7 @@ while [ "${i}" -lt "${no_sources}" ]; do if [ "$ret" = "$code" ]; then fail=1 fi - done <"$c_rsync_failure_codes" + done <"${c_rsync_failure_codes}" fi # From 262ceabca380c7c48b65624da27233daf5d74f97 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 25 Oct 2009 19:53:26 +0100 Subject: [PATCH 414/581] shorten some lines Signed-off-by: Nico Schottelius --- ccollect.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 0c478ab..5ef06a3 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -321,9 +321,7 @@ while [ "${i}" -lt "${no_sources}" ]; do "${c_pre_exec}"; ret="$?" _techo "Finished ${c_pre_exec} (return code ${ret})." - if [ "${ret}" -ne 0 ]; then - _exit_err "${c_pre_exec} failed. Skipping." - fi + [ "${ret}" -eq 0 ] || _exit_err "${c_pre_exec} failed. Skipping." fi # @@ -356,7 +354,7 @@ while [ "${i}" -lt "${no_sources}" ]; do if [ -f "${c_remote_host}" ]; then remote_host="$(cat "${c_remote_host}")"; ret="$?" if [ "${ret}" -ne 0 ]; then - _exit_err "Remote host file ${c_remote_host} exists, but is not readable. Skipping." + _exit_err "Remote host file ${c_remote_host} is unreadable. Skipping." fi destination="${remote_host}:${ddir}" else From 08331387b7db9ace036bfa7c17645e8da358909a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 25 Oct 2009 20:05:50 +0100 Subject: [PATCH 415/581] +braces Signed-off-by: Nico Schottelius --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index 5ef06a3..f940fef 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -403,7 +403,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # if [ -f "${c_rsync_options}" ]; then while read line; do - set -- "$@" "$line" + set -- "$@" "${line}" done < "${c_rsync_options}" fi From ce6157efee8f3e69a9996f847a3aea4c0e5f6311 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 25 Oct 2009 20:13:50 +0100 Subject: [PATCH 416/581] begin to cleanup ugly awk line Using ENVIRON[] instead of ugly quoting Signed-off-by: Nico Schottelius --- ccollect.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index f940fef..7e16dd6 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -427,7 +427,11 @@ while [ "${i}" -lt "${no_sources}" ]; do # incomplete="$(echo \ $(pcmd ls -1 "${ddir}/" | \ - awk "/\.${CMARKER}\$/ { print \$0; gsub(\"\.${CMARKER}\$\",\"\",\$0); print \$0 }" | \ + awk '/\.ENVIRON["CMARKER"]$/ { + print $0; + gsub("\." ENVIRON["CMARKER"]$","",$0); + print $0 + }' | \ tee "${TMP}"))" if [ "${incomplete}" ]; then From 84c732bfc0db1372e249c70a9080afb652846c22 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 25 Oct 2009 20:15:14 +0100 Subject: [PATCH 417/581] now put the dot back into CMARKER Removed it some hundred commits before Signed-off-by: Nico Schottelius --- ccollect.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 7e16dd6..f2396dc 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -38,7 +38,7 @@ CSOURCES="${CCOLLECT_CONF}/sources" CDEFAULTS="${CCOLLECT_CONF}/defaults" CPREEXEC="${CDEFAULTS}/pre_exec" CPOSTEXEC="${CDEFAULTS}/post_exec" -CMARKER="ccollect-marker" +CMARKER=".ccollect-marker" export TMP=$(mktemp "/tmp/${__myname}.XXXXXX") VERSION="0.8" @@ -427,9 +427,9 @@ while [ "${i}" -lt "${no_sources}" ]; do # incomplete="$(echo \ $(pcmd ls -1 "${ddir}/" | \ - awk '/\.ENVIRON["CMARKER"]$/ { + awk '/ENVIRON["CMARKER"]$/ { print $0; - gsub("\." ENVIRON["CMARKER"]$","",$0); + gsub(ENVIRON["CMARKER"]$,"",$0); print $0 }' | \ tee "${TMP}"))" @@ -504,7 +504,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # # added marking in 0.6 (and remove it, if successful later) # - pcmd touch "${destination_dir}.${CMARKER}" + pcmd touch "${destination_dir}${CMARKER}" # # the rsync part @@ -534,8 +534,8 @@ while [ "${i}" -lt "${no_sources}" ]; do # Remove marking here unless rsync failed. # if [ -z "$fail" ]; then - pcmd rm "${destination_dir}.${CMARKER}" || \ - _exit_err "Removing ${destination_dir}.${CMARKER} failed." + pcmd rm "${destination_dir}${CMARKER}" || \ + _exit_err "Removing ${destination_dir}${CMARKER} failed." if [ "${ret}" -ne 0 ]; then _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." fi From 4af94d9e71f3e76b2190b8a9d6563d15e1c1d09d Mon Sep 17 00:00:00 2001 From: Patrick Drolet Date: Fri, 30 Oct 2009 10:18:58 +0100 Subject: [PATCH 418/581] traps more errors and warnings. Signed-off-by: Nico Schottelius --- tools/ccollect_analyse_logs.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) mode change 100755 => 100644 tools/ccollect_analyse_logs.sh diff --git a/tools/ccollect_analyse_logs.sh b/tools/ccollect_analyse_logs.sh old mode 100755 new mode 100644 index 7ff9916..7d48d54 --- a/tools/ccollect_analyse_logs.sh +++ b/tools/ccollect_analyse_logs.sh @@ -72,6 +72,11 @@ if [ "$search_err" ]; then set -- "$@" "-e" 'ssh: connect to host .*: Connection timed out' set -- "$@" "-e" 'rsync error: unexplained error (code 255)' set -- "$@" "-e" 'rsync: connection unexpectedly closed' + set -- "$@" "-e" 'rsync: send_files failed to open' + set -- "$@" "-e" 'rsync: readlink_stat .* failed: File name too long' + set -- "$@" "-e" 'IO error encountered .* skipping file deletion' + set -- "$@" "-e" 'rsync: read error: Connection reset by peer' + set -- "$@" "-e" 'rsync error: error in rsync protocol data stream' fi # known error strings: @@ -103,6 +108,7 @@ fi if [ "$search_warn" ]; then # warn on non-zero exit code set -- "$@" "-e" 'Finished backup (rsync return code: [^0]' + set -- "$@" "-e" 'rsync: file has vanished' set -- "$@" "-e" 'WARNING: .* failed verification -- update discarded (will try again).' fi # known warnings: @@ -113,9 +119,12 @@ fi # Interesting strings in the logs: informational # ---------------------------------------------- if [ "$search_info" ]; then + set -- "$@" "-e" 'Number of files: [[:digit:]]*' + set -- "$@" "-e" 'Number of files transferred: [[:digit:]]*' + set -- "$@" "-e" 'Total transferred file size: [[:digit:]]* bytes' set -- "$@" "-e" 'total size is [[:digit:]]* speedup is' set -- "$@" "-e" 'Backup lasted: [[:digit:]]*:[[:digit:]]\{1,2\}:[[:digit:]]* (h:m:s)$' - set -- "$@" "-e" 'send [[:digit:]]* bytes received [0-9]* bytes [0-9]* bytes/sec$' + set -- "$@" "-e" 'sent [[:digit:]]* bytes received [0-9]* bytes' fi # info includes: @@ -123,4 +132,6 @@ fi # [u0160.nshq.ch.netstream.com] 2007-08-20-18:26:06: Backup lasted: 0:43:34 (h:m:s) #[ddba012.netstream.ch] sent 3303866 bytes received 1624630525 bytes 122700.92 bytes/sec +#echo Parameters: "$@" + grep "$@" From 67aead1db2ab776427f9c6fd4eeebe8e99fc07c8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 30 Oct 2009 10:19:44 +0100 Subject: [PATCH 419/581] more changes for the next release Signed-off-by: Nico Schottelius --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changes/next b/doc/changes/next index d321d1e..34c9530 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -2,3 +2,4 @@ * Fix some minor command line parsing issues (Nico Schottelius) * Correct output, if configuration is not in cconfig format (Nico Schottelius) * Minor code cleanups and optimisations (Nico Schottelius) + * ccollect_analyse_logs.sh traps more errors and warnings (Patrick Drolet) From 3d92f30574429b9e24b6973d09e16d6b12cb200f Mon Sep 17 00:00:00 2001 From: Patrick Drolet Date: Fri, 30 Oct 2009 10:30:30 +0100 Subject: [PATCH 420/581] Add ccollect_mgr.sh, rdu and S60ccollect_example (initscript for ccollect) Signed-off-by: Nico Schottelius --- contrib/patrick/README | 47 +++ contrib/patrick/S60ccollect_example | 21 ++ contrib/patrick/ccollect_mgr.sh | 471 ++++++++++++++++++++++++++++ contrib/patrick/rdu | 65 ++++ 4 files changed, 604 insertions(+) create mode 100644 contrib/patrick/README create mode 100644 contrib/patrick/S60ccollect_example create mode 100644 contrib/patrick/ccollect_mgr.sh create mode 100644 contrib/patrick/rdu diff --git a/contrib/patrick/README b/contrib/patrick/README new file mode 100644 index 0000000..63bba1a --- /dev/null +++ b/contrib/patrick/README @@ -0,0 +1,47 @@ +[Almost complete Copy of an e-mail from Patrick Drolet] + +Hello again, + + + +I have created a script to better manage the backups since my +upload/download ratio and my bandwidth is limited by my ISP, and my hard +disk space is also somewhat limited. The script is called +"ccollect_mgr.sh". + + + +Provides the following features + +1) Determine the interval (daily/weekly/monthly) + +a. Define when you want weekly and monthly backups. It takes care of +the rest + +2) Perform the backups using ccollect + +3) Copy the ccollect log output to the first backup of the set + +a. Keeping the detailed log of each backup is always handy! + +4) Build a periodic report and include the real amount of disk used + +a. Computes the real amount of disk used (eg: no double counting of +hard links) + +b. Shows the actual amount of data transferred + +5) Send an email if there has been errors or warnings + +6) Send a periodic email to show transfer size, real backup size, etc + +a. Weekly reports are nice.! + +[...] + +- rdu (real du), which computes the real amount of disk used (no +double/triple counting hard links), same code as in ccollect_mgr.sh. + +- S60ccollect_example, an example script to put in etc/init.d to +add ccollect_mgr to the crontab + diff --git a/contrib/patrick/S60ccollect_example b/contrib/patrick/S60ccollect_example new file mode 100644 index 0000000..08e839e --- /dev/null +++ b/contrib/patrick/S60ccollect_example @@ -0,0 +1,21 @@ +#!/bin/sh + +# Standard Linux: put in /etc/init.d +# Busybox: put in /opt/etc/init.d + +# Add ccollect_mgr job to crontab +# Syntax reminder from crontab: +# minute 0-59 +# hour 0-23 +# day of month 1-31 +# month 1-12 (or names, see below) +# day of week 0-7 (0 or 7 is Sun, or use names) + +crontab -l | grep -v ccollect_mgr > /tmp/crontab.tmp + +# Backup every day at 1 am. +echo "00 01 * * * /usr/local/sbin/ccollect_mgr.sh -from nas@myemail.net -to me@myemail.net -server relay_or_smtp_server NAS > /usr/local/var/log/ccollect.cron &" >> /tmp/crontab.tmp + +crontab /tmp/crontab.tmp +rm /tmp/crontab.tmp + diff --git a/contrib/patrick/ccollect_mgr.sh b/contrib/patrick/ccollect_mgr.sh new file mode 100644 index 0000000..5678779 --- /dev/null +++ b/contrib/patrick/ccollect_mgr.sh @@ -0,0 +1,471 @@ +#!/bin/sh +# +# ---------------------------------------------------------------------------- +# Last update: 2009-10-29 +# By : pdrolet (ccollect_mgr@drolet.name) +# ---------------------------------------------------------------------------- +# Job manager to the ccollect utilities +# (ccollect written by Nico Schottelius) +# +# Provides the following features +# 1) Determine the interval (daily/weekly/monthly) +# 2) Perform the backups using ccollect +# 4) Copy the ccollect log to the first backup of the set +# 5) Build a periodic report and include the real amount of disk used +# 6) Send an email if there has been errors or warnings +# 7) Send a periodic email to show transfer size, real backup size, etc +# ---------------------------------------------------------------------------- +# +# This script was written primarily to gain better visibility of backups in +# an environment where data transfer is limited and so is bandwidth +# (eg: going through an ISP). The primary target of this script were a +# DNS323 and a QNAP T209 (eg: Busybox devices and not standard Linux devices) +# but it should run on any POSIX compliant device. +# +# Note: This is one of my first script in over a decade... don't use this as a +# reference (but take a look at ccollect.sh... very well written!) +# ---------------------------------------------------------------------------- +# +# ------------------------------------------- +# TO MAKE THIS SCRIPT RUN ON A BUSYBOX DEVICE +# ------------------------------------------- +# - You may need to install Optware and the following packages: +# - findutils (to get a find utility which supports printf) +# - procps (to get a ps utility that is standard) +# - mini-sendmail (this is what I used to send emails... you could easily +# modify this to use sendmail, mutt, putmail, etc...). +# - On DNS323 only: Your Busybox is very limited. For details, see +# http://wiki.dns323.info/howto:ffp#shells. You need to redirect /bin/sh +# to the Busybox provided with ffp (Fun Plug). To do this, type: +# ln -fs /ffp/bin/sh /bin/sh +# +# -------------------------------------------------- +# TO MAKE THIS SCRIPT RUN ON A STANDARD LINUX DEVICE +# -------------------------------------------------- +# - You will need install mini_sendmail or rewrite the send_email routine. +# +# ---------------------------------------------------------------------------- + +# Send warning if the worst case data transfer will be larger than (in MB)... +warning_transfer_size=1024 + +# Define paths and default file names +ADD_TO_PATH=/opt/bin:/opt/sbin:/usr/local/bin:/usr/local/sbin +CCOLLECT=ccollect.sh +CCOLLECT_CONF=/usr/local/etc/ccollect + +per_report=${CCOLLECT_CONF}/periodic_report.log +tmp_report=/tmp/ccollect.$$ +tmp_email=/tmp/email.$$ + +# Sub routines... + +find_interval() +{ + # ---------------------------------------------------- + # Find interval for ccollect backup. + # optional parameters: + # - Day of the week to do weekly backups + # - Do monthly instead of weekly on the Nth week + # ---------------------------------------------------- + + weekly_backup=$1 + monthly_backup=$2 + + weekday=`date "+%w"` + if [ ${weekday} -eq ${weekly_backup} ]; then + dom=`date "+%d"` + weeknum=$(( ( ${dom} / 7 ) + 1 )) + if [ ${weeknum} -eq ${monthly_backup} ]; then + interval=monthly + else + interval=weekly + fi + else + interval=daily + fi +} + +move_log() +{ + for backup in $@ ; do + ddir="$(cat "${CCOLLECT_CONF}"/sources/"${backup}"/destination)"; ret="$?" + if [ "${ret}" -ne 0 ]; then + echo "Destination ${CCOLLECT_CONF}/sources/${backup}/destination is not readable... Skipping." + backup_dir="" + else + backup_dir=`cat ${TEMP_LOG} | grep "\[${backup}\] .*: Creating ${ddir}" | awk '{ print $4 }'` + fi + if [ "${backup_dir}" != "" ]; then + new_log=${backup_dir}/ccollect.log + mv ${TEMP_LOG} ${new_log} + echo New Log Location: ${new_log} + return 0 + fi + done + echo "WARNING: none of the backup set have been created" + new_log=${TEMP_LOG} +} + +compute_rdu() +{ + # WARNING: Don't pass a directory with a space as parameter (I'm too new at scripting!) + + kdivider=1 + find_options="" + + while [ "$#" -ge 1 ]; do + case "$1" in + -m) + kdivider=1024 + ;; + -g) + kdivider=1048576 + ;; + *) + find_options="${find_options} $1" + ;; + esac + shift + done + + # ------------------------------------------------------------------------------------------------------ + # Compute the real disk usage (eg: hard links do files outside the backup set don't count) + # ------------------------------------------------------------------------------------------------------ + # 1) Find selected files and list link count, inodes, file type and size + # 2) Sort (sorts on inodes since link count is constant per inode) + # 3) Merge duplicates using uniq + # (result is occurence count, link count, inode, file type and size) + # 4) Use awk to sum up the file size of each inodes when the occurence count + # and link count are the same. Use %k for size since awk's printf is 32 bits + # 5) Present the result with additional dividers based on command line parameters + # + + rdu=$(( ( `/opt/bin/find ${find_options} -printf '%n %i %y %k \n' \ + | sort -n \ + | uniq -c \ + | awk '{ if (( $1 == $2 ) || ($4 == "d")) { sum += $5; } } END { printf "%u\n",(sum); }'` \ + + ${kdivider} - 1 ) / ${kdivider} )) + echo RDU for ${find_options} is ${rdu} +} + +compute_total_rdu() +{ + real_usage=0 + + # ------------------------------------------ + # Get the real disk usage for the backup set + # ------------------------------------------ + for backup in $@ ; do + ddir="$(cat "${CCOLLECT_CONF}"/sources/"${backup}"/destination)"; ret="$?" + echo ${backup} - Adding ${ddir} to backup list + backup_dir_list="${backup_dir_list} ${ddir}" + if [ "${ret}" -ne 0 ]; then + echo "Destination ${CCOLLECT_CONF}/sources/${backup}/destination is not readable... Skipping." + else + backup_dir=`find ${ddir}/${interval}.* -maxdepth 0 -type d -print | sort -r | head -n 1` + compute_rdu -m ${backup_dir} + real_usage=$(( ${real_usage} + ${rdu} )) + fi + done + echo Backup list - ${backup_dir_list} +} + +send_email() +{ + # Send a simple email using mini-sendmail. + + msg_body_file=$1 + shift + + # ------------------------------ + # Quit if we can't send an email + # ------------------------------ + if [ "${to}" == "" ] || [ "${mail_server}" == "" ]; then + echo "Missing mail server or destination email. No email sent with subject: $@" + exit 1 + fi + + echo from: ${from} > ${tmp_email} + echo subject: $@ >> ${tmp_email} + echo to: ${to} >> ${tmp_email} + echo cc: >> ${tmp_email} + echo bcc: >> ${tmp_email} + echo "" >> ${tmp_email} + echo "" >> ${tmp_email} + cat ${msg_body_file} >> ${tmp_email} + echo "" >> ${tmp_email} + + echo Sending email to ${to} to report the following error: + echo ----------------------------------------------------- + cat ${tmp_email} + cat ${tmp_email} | mini_sendmail -f${from} -s${mail_server} ${to} + rm ${tmp_email} +} + +check_running_backups() +{ + # Check if a backup is already ongoing. If so, skip and send email + # Don't use the ccollect marker as this is no indication if it is still running + + for backup in ${ccollect_backups} ; do + PID=$$ + /opt/bin/ps -e -o pid,ppid,args 2> /dev/null | grep -v -e grep -e "${PID}.*ccollect.*${backup}" | grep "ccollect.*${backup}" > /tmp/ccollect_mgr.$$ 2> /dev/null + running_proc=`cat /tmp/ccollect_mgr.$$ | wc -l` + if [ ${running_proc} -gt 0 ]; then + running_backups="${running_backups}${backup} " + echo "Process:" + cat /tmp/ccollect.$$ + else + backups_to_do="${backups_to_do}${backup} " + fi + rm /tmp/ccollect_mgr.$$ + done + ccollect_backups=${backups_to_do} + + if [ "${running_backups}" != "" ]; then + echo "skipping ccollect backups already running: ${running_backups}" | tee ${tmp_report} + send_email ${tmp_report} "WARNING - skipping ccollect backups already running: ${running_backups}" + rm ${tmp_report} + fi +} + +precheck_transfer_size() +{ + # Check the estimated (worst case) transfer size and send email if larger than certain size + # + # Be nice and add error checking one day... + + for backup in ${ccollect_backups} ; do + ddir="$(cat "${CCOLLECT_CONF}"/sources/"${backup}"/destination)"; ret="$?" + last_dir="$(ls -tcp1 "${ddir}" | grep '/$' | head -n 1)" + sdir="$(cat "${CCOLLECT_CONF}"/sources/"${backup}"/source)"; ret="$?" + if [ -f "${CCOLLECT_CONF}"/sources/"${backup}"/exclude ]; then + exclude="--exclude-from=${CCOLLECT_CONF}/sources/${backup}/exclude"; + else + exclude="" + fi + if [ -f "${CCOLLECT_CONF}"/sources/"${backup}"/rsync_options ]; then + while read line; do + rsync_options="${rsync_options} ${line}" + done < ${CCOLLECT_CONF}/sources/${backup}/rsync_options + fi + rsync -n -a --delete --stats ${rsync_options} ${exclude} ${sdir} ${ddir}/${last_dir} > ${tmp_report} + tx_rx=`cat ${tmp_report} | grep "Total transferred file size" | \ + awk '{ { tx += $5 } } END { printf "%u",(((tx)+1024*1024-1)/1024/1024); }'` + total_xfer=$(( ${total_xfer} + ${tx_rx} )) + done + echo Transfer estimation for ${ccollect_backups}: ${total_xfer} MB + + if [ ${total_xfer} -gt ${warning_transfer_size} ]; then + # -------------------------------------------------- + # Send a warning if transfer is expected to be large + # -------------------------------------------------- + # Useful to detect potential issues when there is transfer quota (ex: with ISP) + + echo Data transfer larger than ${warning_transfer_size} MB is expected for ${ccollect_backups} > ${tmp_report} + + send_email ${tmp_report} "WARNING ccollect for ${ccollect_backups} -- Estimated Tx+Rx: ${total_xfer} MB" + rm ${tmp_report} + fi +} + +send_report() +{ + log=$1 + + # Analyze log for periodic report and for error status report + cat ${log} | ccollect_analyse_logs.sh iwe > ${tmp_report} + + # ------------------------- + # Build the periodic report + # ------------------------- + + # Compute the total number of MB sent and received for all the backup sets + tx_rx=`cat ${tmp_report} | \ + grep 'sent [[:digit:]]* bytes received [0-9]* bytes' | \ + awk '{ { tx += $3 } { rx += $6} } END \ + { printf "%u",(((tx+rx)+1024*1024-1)/1024/1024); }'` + current_date=`date +'20%y/%m/%d %Hh%M -- '` + + # --------------------------------------------------------- + # Get the disk usage for all backups of each backup sets... + # ** be patient ** + # --------------------------------------------------------- + compute_rdu -g ${backup_dir_list} + + echo ${current_date} Tx+Rx: ${tx_rx} MB -- \ + Disk Usage: ${real_usage} MB -- \ + Backup set \(${interval}\): ${ccollect_backups} -- \ + Historical backups usage: ${rdu} GB >> ${per_report} + + # ---------------------------------------- + # Send a status email if there is an error + # ---------------------------------------- + ccollect_we=`cat ${log} | ccollect_analyse_logs.sh we | wc -l` + if [ ${ccollect_we} -ge 1 ]; then + send_email ${tmp_report} "ERROR ccollect for ${ccollect_backups} -- Tx+Rx: ${tx_rx} MB" + fi + + # -------------------- + # Send periodic report + # -------------------- + if [ ${report_interval} == ${interval} ] || [ ${interval} == "monthly" ]; then + + # Make reporting atomic to handle concurrent ccollect_mgr instances + mv ${per_report} ${per_report}.$$ + cat ${per_report}.$$ >> ${per_report}.history + + # Calculate total amount of bytes sent and received + tx_rx=`cat ${per_report}.$$ | \ + awk '{ { transfer += $5 } } END \ + { printf "%u",(transfer); }'` + + # Send email + send_email ${per_report}.$$ "${report_interval} ccollect status for ${ccollect_backups} -- Tx+Rx: ${tx_rx} MB" + rm ${per_report}.$$ + fi + + rm ${tmp_report} +} + +# ------------------------------------------------ +# Add to PATH in case we're launching from crontab +# ------------------------------------------------ + +PATH=${ADD_TO_PATH}:${PATH} + +# -------------- +# Default Values +# -------------- + +# Set on which interval status emails are sent (daily, weekly, monthly) +report_interval=weekly + +# Set day of the week for weekly backups. Default is Monday +# 0=Sun, 1=Mon, 2=Tue, 3=Wed, 4=Thu, 5=Fri, 6=Sat +weekly_backup=1 + +# Set the monthly backup interval. Default is 4th Monday of every month +monthly_backup=4 + +show_help=0 + +# --------------------------------- +# Parse command line +# --------------------------------- + +while [ "$#" -ge 1 ]; do + case "$1" in + -help) + show_help=1 + ;; + -from) + from=$2 + shift + ;; + -to) + to=$2 + shift + ;; + -server|mail_server) + mail_server=$2 + shift + ;; + -weekly) + weekly_backup=$2 + shift + ;; + -monthly) + monthly_backup=$2 + shift + ;; + -warning_size) + warning_transfer_size=$2 + shift + ;; + -report) + report_interval=$2 + shift + ;; + -*) + ccollect_options="${ccollect_options} $1" + ;; + daily|weekly|monthly) + ;; + *) + ccollect_backups="${ccollect_backups}$1 " + ;; + esac + shift +done + +if [ "${ccollect_backups}" == "" ] || [ ${show_help} -eq 1 ]; then + echo + echo "$0: Syntax" + echo " -help This help" + echo " -from From email address (ex.: -from nas@home.com)" + echo " -to Send email to this address (ex.: -to me@home.com)" + echo " -server SMTP server used for sending emails" + echo " -weekly Define wich day of the week is the weekly backup" + echo " Default is ${weekly_backup}. Sunday = 0, Saturday = 6" + echo " -monthly Define on which week # is the monthly backup" + echo " Default is ${monthly_backup}. Value = 1 to 5" + echo " -report Frequency of report email (daily, weekly or monthly)" + echo " Default is ${report_interval}" + echo " -warning_size Send a warning email if the transfer size exceed this" + echo " Default is ${warning_transfer_size}" + echo "" + echo " other parameters are transfered to ccollect" + echo + exit 0 +fi + +# ------------------------------------------------------------------ +# Check if ccollect_mgr is already running for the given backup sets +# ------------------------------------------------------------------ + +check_running_backups + +if [ "${ccollect_backups}" == "" ]; then + echo "No backup sets are reachable" + exit 1 +fi + +# ---------------------------------------------------------- +# Set the interval type +# +# Here, weeklys are Mondays, and Monthlys are the 4th Monday +# ---------------------------------------------------------- + +find_interval ${weekly_backup} ${monthly_backup} +echo Interval: ${interval} + +# -------------- +# Do the backups +# -------------- +TEMP_LOG=${CCOLLECT_CONF}/log.$$ +echo Backup sets: ${ccollect_backups} + +# Check the transfer size (to issue email warning) +precheck_transfer_size + +${CCOLLECT} ${ccollect_options} ${interval} ${ccollect_backups} | tee ${TEMP_LOG} + +# --------------------------------------- +# Move log to the last backup of the set +# --------------------------------------- + +move_log ${ccollect_backups} + +# ----------------------------------------- +# Compute the physical amount of disk usage +# ----------------------------------------- + +compute_total_rdu ${ccollect_backups} + +# ----------------- +# Send status email +# ----------------- + +send_report ${new_log} diff --git a/contrib/patrick/rdu b/contrib/patrick/rdu new file mode 100644 index 0000000..aa5ffe4 --- /dev/null +++ b/contrib/patrick/rdu @@ -0,0 +1,65 @@ +#!/bin/sh +# +# ------------------------------------------------------------- +# Get the real disk usage for a group of selected files +# +# This script counts the size of the files and directories +# listed, but exclude files that have hard links referenced outside +# the list. +# +# The undelying objective of this script is to report the +# real amount of disk used for backup solutions that are heavily +# using hard links to save disk space on identical files (I use +# ccollect, but this likely works with rsnapshot) +# ------------------------------------------------------------- +# 20091002 - initial release - pdrolet (rdu@drolet.name) + +# -------------------- +# Parse options +# -------------------- +# Known problem: +# - Command line cannot get a directory with a space in it +# +kdivider=1 +find_options="" +while [ "$#" -ge 1 ]; do + case "$1" in + -m) + kdivider=1024 + ;; + -g) + kdivider=1048576 + ;; + -h|--help) + echo + echo $0: \ \[options below and any \"find\" options\] + echo \ \ -m: result in mega bytes \(rounded up\) + echo \ \ -g: result in giga bytes \(rounded up\) + echo \ \ -h: this help + echo + exit 0 + ;; + *) + find_options="${find_options} $1" + ;; + esac + shift +done + +# ------------------------------------------------------------------------------------------------------ +# Compute the size +# ------------------------------------------------------------------------------------------------------ +# 1) Find selected files and list link count, inodes, file type and size +# 2) Sort (sorts on inodes since link count is constant per inode) +# 3) Merge duplicates using uniq +# (result is occurence count, link count, inode, file type and size) +# 4) Use awk to sum up the file size of each inodes when the occurence count +# and link count are the same. Use %k for size since awk's printf is 32 bits +# 5) Present the result with additional dividers based on command line parameters +# +echo $((( `find ${find_options} -printf '%n %i %y %k \n' \ + | sort -n \ + | uniq -c \ + | awk '{ if (( $1 == $2 ) || ($4 == "d")) { sum += $5; } } END { printf "%u\n",(sum); }'` \ + + ${kdivider} -1 ) / ${kdivider} )) + From 4865f3c8c605b80732f2ff8fe4f2a5df7a3220d8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 30 Oct 2009 19:25:23 +0100 Subject: [PATCH 421/581] extend delete_from_file() to allow removal of suffix files Signed-off-by: Nico Schottelius --- ccollect.sh | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index f2396dc..08cf756 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -100,16 +100,22 @@ pcmd() fi } +# +# ssh-"feature": we cannot do '... read ...; ssh ...; < file', +# because ssh reads stdin! -n does not work -> does not ask for password +# Allow deletion for files with suffix and without suffix +# delete_from_file() { - # - # ssh-"feature": we cannot do '... read ...; ssh ...; < file', - # because ssh reads stdin! -n does not work -> does not ask for password - # file="$1"; shift - while read to_remove; do set -- "$@" "${ddir}/${to_remove}"; done < "${file}" + suffix="$1" # only set for delete_incomplete +# [ "$#" = 1 ] && suffix="$1" && shift + while read to_remove; do + set -- "$@" "${ddir}/${to_remove}" + [ "$suffix" ] && set -- "$@" "$(echo ${to_remove} | sed "s/$suffix\$//")" + done < "${file}" _techo "Removing $@ ..." - pcmd rm ${VVERBOSE} -rf "$@" || _exit_err "Removing $@ failed." + pcmd echo rm ${VVERBOSE} -rf "$@" || _exit_err "Removing $@ failed." } display_version() @@ -425,14 +431,29 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Check: incomplete backups? (needs echo to remove newlines) # + # *.marker: not possible, creates an error, if no *.marker exists + # -> catch return value + + pcmd ls -1 "${ddir}/"*"${CMARKER}" > "${TMP}" 2>/dev/null; ret=$? + + if [ "$ret" -eq 0 ]; then + _techo "Incomplete backups: ${incomplete}" + if [ -f "${c_delete_incomplete}" ]; then + delete_from_file "${TMP}" + fi + fi + incomplete="$(echo \ $(pcmd ls -1 "${ddir}/" | \ - awk '/ENVIRON["CMARKER"]$/ { - print $0; - gsub(ENVIRON["CMARKER"]$,"",$0); - print $0 - }' | \ - tee "${TMP}"))" + awk ' + BEGIN { regexp=ENVIRON["CMARKER"] "$" } + $0 ~ regexp { + print $0; + gsub(ENVIRON["CMARKER"]$,"",$0); + print $0 + }' | tee "${TMP}"))" + +FIXME: stopped here! -> gsub broken if [ "${incomplete}" ]; then _techo "Incomplete backups: ${incomplete}" From 8a70e30d971a3564e722bd3b4dcbb65fc4836e5d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 30 Oct 2009 19:26:32 +0100 Subject: [PATCH 422/581] cleanup delete_from_file(): clean suffix stuff Signed-off-by: Nico Schottelius --- ccollect.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 08cf756..b90c2c6 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -108,10 +108,9 @@ pcmd() delete_from_file() { file="$1"; shift - suffix="$1" # only set for delete_incomplete -# [ "$#" = 1 ] && suffix="$1" && shift + suffix="$1" # only set, if deleting incomplete backups while read to_remove; do - set -- "$@" "${ddir}/${to_remove}" + set -- "$@" "${to_remove}" [ "$suffix" ] && set -- "$@" "$(echo ${to_remove} | sed "s/$suffix\$//")" done < "${file}" _techo "Removing $@ ..." From 086af1497c49faba99f6e64580c8147ee8815404 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 30 Oct 2009 19:42:13 +0100 Subject: [PATCH 423/581] need to unset $@ completly in delete_from_file() Signed-off-by: Nico Schottelius --- ccollect.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index b90c2c6..d060156 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -103,12 +103,12 @@ pcmd() # # ssh-"feature": we cannot do '... read ...; ssh ...; < file', # because ssh reads stdin! -n does not work -> does not ask for password -# Allow deletion for files with suffix and without suffix +# Alsa allow deletion for files without the given suffix # delete_from_file() { file="$1"; shift - suffix="$1" # only set, if deleting incomplete backups + [ $# -eq 1 ] && suffix="$1" && shift # set if deleting incomplete backups while read to_remove; do set -- "$@" "${to_remove}" [ "$suffix" ] && set -- "$@" "$(echo ${to_remove} | sed "s/$suffix\$//")" From ef4291c72293db89900155de1a11fd001dc5001f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 30 Oct 2009 19:42:32 +0100 Subject: [PATCH 424/581] use delete_from_file with suffix Signed-off-by: Nico Schottelius --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index d060156..efd0440 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -438,7 +438,7 @@ while [ "${i}" -lt "${no_sources}" ]; do if [ "$ret" -eq 0 ]; then _techo "Incomplete backups: ${incomplete}" if [ -f "${c_delete_incomplete}" ]; then - delete_from_file "${TMP}" + delete_from_file "${TMP}" "${CMARKER}" fi fi From 9d65e1b1bf8a13e74965a55e6245279b87c3df06 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 30 Oct 2009 19:43:21 +0100 Subject: [PATCH 425/581] remove now obsolete code :-) Signed-off-by: Nico Schottelius --- ccollect.sh | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index efd0440..13cc7b2 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -442,25 +442,6 @@ while [ "${i}" -lt "${no_sources}" ]; do fi fi - incomplete="$(echo \ - $(pcmd ls -1 "${ddir}/" | \ - awk ' - BEGIN { regexp=ENVIRON["CMARKER"] "$" } - $0 ~ regexp { - print $0; - gsub(ENVIRON["CMARKER"]$,"",$0); - print $0 - }' | tee "${TMP}"))" - -FIXME: stopped here! -> gsub broken - - if [ "${incomplete}" ]; then - _techo "Incomplete backups: ${incomplete}" - if [ -f "${c_delete_incomplete}" ]; then - delete_from_file "${TMP}" - fi - fi - # # Interval definition: First try source specific, fallback to default # From 39e8eb4c948bb11cec0b117c47e3e92c3d286480 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 30 Oct 2009 19:45:03 +0100 Subject: [PATCH 426/581] fix incomplete output message Signed-off-by: Nico Schottelius --- ccollect.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 13cc7b2..2fe7a33 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -435,8 +435,8 @@ while [ "${i}" -lt "${no_sources}" ]; do pcmd ls -1 "${ddir}/"*"${CMARKER}" > "${TMP}" 2>/dev/null; ret=$? - if [ "$ret" -eq 0 ]; then - _techo "Incomplete backups: ${incomplete}" + if [ "${ret}" -eq 0 ]; then + _techo "Incomplete backups: $(echo $(cat "${TMP}"))" if [ -f "${c_delete_incomplete}" ]; then delete_from_file "${TMP}" "${CMARKER}" fi From 2a6ab4c125398f917c26f161d361f226a4da6bba Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 30 Oct 2009 19:49:17 +0100 Subject: [PATCH 427/581] adjust ls for existing backups to new delete_from_file behaviour Signed-off-by: Nico Schottelius --- ccollect.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 2fe7a33..5697003 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -457,9 +457,8 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Check: maximum number of backups is reached? - # If so remove. Use grep and ls -p so we only look at directories # - count="$(pcmd ls -p1 "${ddir}" | grep "^${INTERVAL}\..*/\$" | wc -l \ + count="$(pcmd ls -p1 "${ddir}/${INTERVAL}.*/" | wc -l \ | sed 's/^ *//g')" || _exit_err "Counting backups failed" _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" From 1b591a040c27f6886c074ed4de722692ac9e05a0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 31 Oct 2009 07:31:23 +0100 Subject: [PATCH 428/581] -p is not needed, when matching directories with */ Signed-off-by: Nico Schottelius --- ccollect.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index 5697003..6395004 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -458,7 +458,8 @@ while [ "${i}" -lt "${no_sources}" ]; do # # Check: maximum number of backups is reached? # - count="$(pcmd ls -p1 "${ddir}/${INTERVAL}.*/" | wc -l \ + + count="$(pcmd ls -1 "${ddir}/${INTERVAL}.*/" | wc -l \ | sed 's/^ *//g')" || _exit_err "Counting backups failed" _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" From 145c6de2fb75156f8805ddaac90f647f679b25f2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 31 Oct 2009 07:40:55 +0100 Subject: [PATCH 429/581] double check quotes, remove grep Signed-off-by: Nico Schottelius --- ccollect.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 6395004..bac7f2f 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -459,7 +459,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # Check: maximum number of backups is reached? # - count="$(pcmd ls -1 "${ddir}/${INTERVAL}.*/" | wc -l \ + count="$(pcmd ls -1 "${ddir}/${INTERVAL}."*"/" | wc -l \ | sed 's/^ *//g')" || _exit_err "Counting backups failed" _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" @@ -469,9 +469,9 @@ while [ "${i}" -lt "${no_sources}" ]; do remove="$((${count} - ${substract}))" _techo "Removing ${remove} backup(s)..." - pcmd ls -${TSORT}p1r "${ddir}" | grep "^${INTERVAL}\..*/\$" | \ - head -n "${remove}" > "${TMP}" || \ - _exit_err "Listing old backups failed" + pcmd ls -${TSORT}1r "${ddir}/${INTERVAL}."*"/" | + head -n "${remove}" > "${TMP}" || \ + _exit_err "Listing old backups failed" delete_from_file "${TMP}" fi From 435f2140dadf0ff68ffe918b962b22b07172bf2f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 31 Oct 2009 08:14:59 +0100 Subject: [PATCH 430/581] cleanly set suffix Signed-off-by: Nico Schottelius --- ccollect.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index bac7f2f..a0c6489 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -108,13 +108,17 @@ pcmd() delete_from_file() { file="$1"; shift - [ $# -eq 1 ] && suffix="$1" && shift # set if deleting incomplete backups + suffix="" # It will be set, if deleting incomplete backups. + [ $# -eq 1 ] && suffix="$1" && shift while read to_remove; do set -- "$@" "${to_remove}" - [ "$suffix" ] && set -- "$@" "$(echo ${to_remove} | sed "s/$suffix\$//")" + if [ "$suffix" ]; then + to_remove_no_suffix="$(echo ${to_remove} | sed "s/$suffix\$//")" + set -- "$@" "${to_remove_no_suffix}" + fi done < "${file}" _techo "Removing $@ ..." - pcmd echo rm ${VVERBOSE} -rf "$@" || _exit_err "Removing $@ failed." + pcmd rm ${VVERBOSE} -rf "$@" || _exit_err "Removing $@ failed." } display_version() From 9e801582d53efd7d4fba00780f34620824c6834c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 31 Oct 2009 09:03:58 +0100 Subject: [PATCH 431/581] use -d to prevent displaying the content of a directory Signed-off-by: Nico Schottelius --- ccollect.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index a0c6489..0247c00 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -437,7 +437,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # *.marker: not possible, creates an error, if no *.marker exists # -> catch return value - pcmd ls -1 "${ddir}/"*"${CMARKER}" > "${TMP}" 2>/dev/null; ret=$? + pcmd ls -d1 "${ddir}/"*"${CMARKER}" > "${TMP}" 2>/dev/null; ret=$? if [ "${ret}" -eq 0 ]; then _techo "Incomplete backups: $(echo $(cat "${TMP}"))" @@ -463,7 +463,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # Check: maximum number of backups is reached? # - count="$(pcmd ls -1 "${ddir}/${INTERVAL}."*"/" | wc -l \ + count="$(pcmd ls -d1 "${ddir}/${INTERVAL}."*"/" | wc -l \ | sed 's/^ *//g')" || _exit_err "Counting backups failed" _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" @@ -473,7 +473,7 @@ while [ "${i}" -lt "${no_sources}" ]; do remove="$((${count} - ${substract}))" _techo "Removing ${remove} backup(s)..." - pcmd ls -${TSORT}1r "${ddir}/${INTERVAL}."*"/" | + pcmd ls -${TSORT}d1r "${ddir}/${INTERVAL}."*"/" | head -n "${remove}" > "${TMP}" || \ _exit_err "Listing old backups failed" From 59c894137310fb14c6dcf29c4bde3c89ab6a801a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 31 Oct 2009 09:15:53 +0100 Subject: [PATCH 432/581] cleanup destination setting :-) Signed-off-by: Nico Schottelius --- ccollect.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 0247c00..9e779b9 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -495,9 +495,9 @@ while [ "${i}" -lt "${no_sources}" ]; do fi # set time when we really begin to backup, not when we began to remove above - destination_date="$(${CDATE})" - destination_dir="${ddir}/${INTERVAL}.${destination_date}.$$" - destination_full="${destination}/${INTERVAL}.${destination_date}.$$" + destination_name="${INTERVAL}.$(${CDATE}).$$" + destination_dir="${ddir}/${destination_name}" + destination_full="${destination}/${destination_name}" # give some info _techo "Beginning to backup, this may take some time..." From e4dea56e4957ebd2617ab4d864bad8094014d920 Mon Sep 17 00:00:00 2001 From: Patrick Drolet Date: Sat, 31 Oct 2009 09:52:33 +0100 Subject: [PATCH 433/581] Begin to replace false verbose handling Signed-off-by: Nico Schottelius --- ccollect.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 9e779b9..e797c0c 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -118,7 +118,11 @@ delete_from_file() fi done < "${file}" _techo "Removing $@ ..." - pcmd rm ${VVERBOSE} -rf "$@" || _exit_err "Removing $@ failed." +# pcmd rm ${VVERBOSE} -rf "$@" || _exit_err "Removing $@ failed." + if [ ${VVERBOSE} ]; then + echo rm "$@" + fi + pcmd rm -rf "$@" || _exit_err "Removing $@ failed." } display_version() @@ -503,7 +507,12 @@ while [ "${i}" -lt "${no_sources}" ]; do _techo "Beginning to backup, this may take some time..." _techo "Creating ${destination_dir} ..." - pcmd mkdir ${VVERBOSE} "${destination_dir}" || \ +# pcmd mkdir ${VVERBOSE} "${destination_dir}" || \ +# _exit_err "Creating ${destination_dir} failed. Skipping." + if [ ${VVERBOSE} ]; then + echo mkdir "${destination_dir}" + fi + pcmd mkdir "${destination_dir}" || \ _exit_err "Creating ${destination_dir} failed. Skipping." # @@ -515,7 +524,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # the rsync part # _techo "Transferring files..." - rsync "$@" "${source}" "${destination_full}"; ret=$? + rsync $@ "${source}" "${destination_full}"; ret=$? _techo "Finished backup (rsync return code: $ret)." # @@ -553,7 +562,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # if [ -x "${c_post_exec}" ]; then _techo "Executing ${c_post_exec} ..." - "${c_post_exec}"; ret=$? + "${c_post_exec}" "${destination_full}"; ret=$? _techo "Finished ${c_post_exec}." if [ "${ret}" -ne 0 ]; then @@ -571,7 +580,6 @@ while [ "${i}" -lt "${no_sources}" ]; do seconds="$((${seconds} - (${minutes} * 60)))" _techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" - ) | add_name done From e6d89d57fcfd4e334a5a374a9487633e891ba18d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 31 Oct 2009 10:01:11 +0100 Subject: [PATCH 434/581] Fix Patricks patch: remove comments, remove if..then, add quotes for $@, do not add destination_full for post_exec Signed-off-by: Nico Schottelius --- ccollect.sh | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index e797c0c..6959fa0 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -118,10 +118,7 @@ delete_from_file() fi done < "${file}" _techo "Removing $@ ..." -# pcmd rm ${VVERBOSE} -rf "$@" || _exit_err "Removing $@ failed." - if [ ${VVERBOSE} ]; then - echo rm "$@" - fi + [ "${VVERBOSE}" ] && echo rm "$@" pcmd rm -rf "$@" || _exit_err "Removing $@ failed." } @@ -507,11 +504,7 @@ while [ "${i}" -lt "${no_sources}" ]; do _techo "Beginning to backup, this may take some time..." _techo "Creating ${destination_dir} ..." -# pcmd mkdir ${VVERBOSE} "${destination_dir}" || \ -# _exit_err "Creating ${destination_dir} failed. Skipping." - if [ ${VVERBOSE} ]; then - echo mkdir "${destination_dir}" - fi + [ "${VVERBOSE}" ] && echo "mkdir ${destination_dir}" pcmd mkdir "${destination_dir}" || \ _exit_err "Creating ${destination_dir} failed. Skipping." @@ -524,7 +517,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # the rsync part # _techo "Transferring files..." - rsync $@ "${source}" "${destination_full}"; ret=$? + rsync "$@" "${source}" "${destination_full}"; ret=$? _techo "Finished backup (rsync return code: $ret)." # @@ -562,7 +555,7 @@ while [ "${i}" -lt "${no_sources}" ]; do # if [ -x "${c_post_exec}" ]; then _techo "Executing ${c_post_exec} ..." - "${c_post_exec}" "${destination_full}"; ret=$? + "${c_post_exec}"; ret=$? _techo "Finished ${c_post_exec}." if [ "${ret}" -ne 0 ]; then From cf62a0fada3a5daa37c90e2b5c4d916e2a1fb78a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 31 Oct 2009 10:01:58 +0100 Subject: [PATCH 435/581] even more changes for the next version Signed-off-by: Nico Schottelius --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changes/next b/doc/changes/next index 34c9530..a3dc769 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -3,3 +3,4 @@ * Correct output, if configuration is not in cconfig format (Nico Schottelius) * Minor code cleanups and optimisations (Nico Schottelius) * ccollect_analyse_logs.sh traps more errors and warnings (Patrick Drolet) + * Remove -v for mkdir and rm, as they are not POSIX (Patrick Drolet) From 375f9ebafe265cff7a898509911984bdbc37e13b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 31 Oct 2009 10:10:09 +0100 Subject: [PATCH 436/581] add some more notes on post-configuring ccollect Signed-off-by: Nico Schottelius --- doc/ccollect.text | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 100118b..3bfef96 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -264,8 +264,10 @@ After having installed and used ccollect, report success using Configuring ----------- For configuration aid have a look at the above mentioned tools, which can assist -you quite well. When you are successfully using `ccollect`, report success using -`tools/report_success.sh`. +you quite well. When you are successfully using `ccollect`, I would be happy if +you add a link to your website, stating "I backup with ccollect", which points +to the ccollect homepage. So more people now about ccollect, use it and +improve it. You can also report success using `tools/report_success.sh`. Runtime options From c314f284a2b129eed8e324f0284548e9d19fb1b4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 31 Oct 2009 10:18:23 +0100 Subject: [PATCH 437/581] export destination_* for usage in post_exec in documentate it Signed-off-by: Nico Schottelius --- ccollect.sh | 6 +++--- doc/ccollect.text | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 6959fa0..651cd8c 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -496,9 +496,9 @@ while [ "${i}" -lt "${no_sources}" ]; do fi # set time when we really begin to backup, not when we began to remove above - destination_name="${INTERVAL}.$(${CDATE}).$$" - destination_dir="${ddir}/${destination_name}" - destination_full="${destination}/${destination_name}" + export destination_name="${INTERVAL}.$(${CDATE}).$$" + export destination_dir="${ddir}/${destination_name}" + export destination_full="${destination}/${destination_name}" # give some info _techo "Beginning to backup, this may take some time..." diff --git a/doc/ccollect.text b/doc/ccollect.text index 3bfef96..38a93fb 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -599,6 +599,12 @@ respectively after doing the backup for *this specific* source. If you want to have pre-/post-exec before and after *all* backups, see above for general configuration. +The `post_exec` script can access the following exported variables from +ccollect: + +- destination_name: contains the base directory name (`daily.20091031-1013.24496`) +- destination_dir: full path (`/tmp/ccollect/daily.20091031-1013.24496`) +- destination_full: like 'destination_dir', but prepended with the remote_host, if set (`host:/tmp/ccollect/daily.20091031-1013.24496` or `/tmp/ccollect/daily.20091031-1013.24496`) Example: -------------------------------------------------------------------------------- From 7d1669827a5727dae2ee01433cad9169af7b2cd3 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 31 Oct 2009 10:19:03 +0100 Subject: [PATCH 438/581] and... even more changes.. this will be a great one Signed-off-by: Nico Schottelius --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changes/next b/doc/changes/next index a3dc769..45972f9 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -4,3 +4,4 @@ * Minor code cleanups and optimisations (Nico Schottelius) * ccollect_analyse_logs.sh traps more errors and warnings (Patrick Drolet) * Remove -v for mkdir and rm, as they are not POSIX (Patrick Drolet) + * Export destination_* to source specific post_exec (Nico Schottelius) From e1ccba4f576855010b4c2a35f370abe7265f35e0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 13:36:50 +0100 Subject: [PATCH 439/581] update documentation with all exported variables Signed-off-by: Nico Schottelius --- doc/ccollect.text | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 38a93fb..e2090a9 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -335,6 +335,12 @@ If you add '$CCOLLECT_CONF/defaults/`pre_exec`' or will start `pre_exec` before the whole backup process and `post_exec` after backup of all sources is done. +The `pre_exec` and `post_exec` script can access the following exported variables: + +- 'INTERVAL': the interval selected (`daily`) +- 'no_sources': number of sources to backup (`2`) +- 'source_$no': name of the source, '$no' starts at 0 + The following example describes how to report free disk space in human readable format before and after the whole backup process: ------------------------------------------------------------------------- @@ -602,9 +608,10 @@ backups, see above for general configuration. The `post_exec` script can access the following exported variables from ccollect: -- destination_name: contains the base directory name (`daily.20091031-1013.24496`) -- destination_dir: full path (`/tmp/ccollect/daily.20091031-1013.24496`) -- destination_full: like 'destination_dir', but prepended with the remote_host, if set (`host:/tmp/ccollect/daily.20091031-1013.24496` or `/tmp/ccollect/daily.20091031-1013.24496`) +- 'name': name of the source that is being backed up +- 'destination_name': contains the base directory name (`daily.20091031-1013.24496`) +- 'destination_dir': full path (`/tmp/ccollect/daily.20091031-1013.24496`) +- 'destination_full': like 'destination_dir', but prepended with the remote_host, if set (`host:/tmp/ccollect/daily.20091031-1013.24496` or `/tmp/ccollect/daily.20091031-1013.24496`) Example: -------------------------------------------------------------------------------- @@ -710,12 +717,16 @@ Using source names or interval in pre_/post_exec scripts ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The pre-/post_exec scripts can access some internal variables from `ccollect`: -- INTERVAL: The interval specified on the command line -- no_sources: number of sources -- source_$NUM: the name of the source -- name: the name of the currently being backuped source (not available for +- 'INTERVAL': The interval specified on the command line +- 'no_sources': number of sources +- 'source_$NUM': the name of the source +- 'name': the name of the currently being backuped source (not available for generic pre_exec script) +Only available for `post_exec`: + +- 'remote_host': name of host we backup to (empty if unused) + Using rsync protocol without ssh ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 6a8ff3f1d2f0828a59918819e6e60991d9a4cdc5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 13:37:02 +0100 Subject: [PATCH 440/581] better quote TMP Signed-off-by: Nico Schottelius --- ccollect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect.sh b/ccollect.sh index 651cd8c..9cbc96c 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -40,7 +40,7 @@ CPREEXEC="${CDEFAULTS}/pre_exec" CPOSTEXEC="${CDEFAULTS}/post_exec" CMARKER=".ccollect-marker" -export TMP=$(mktemp "/tmp/${__myname}.XXXXXX") +export TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" VERSION="0.8" RELEASE="2009-08-20" HALF_VERSION="ccollect ${VERSION}" From 8b01949f4bd271edce29d48e25f41b47a677db4a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 13:44:43 +0100 Subject: [PATCH 441/581] begin to claeunp the restorign document Signed-off-by: Nico Schottelius --- doc/ccollect-restoring.text | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ccollect-restoring.text b/doc/ccollect-restoring.text index 7bb29ea..8a3e11b 100644 --- a/doc/ccollect-restoring.text +++ b/doc/ccollect-restoring.text @@ -30,7 +30,7 @@ Boot the system to be rescued from a media that contains low level tools for your OS (like partitioning, formatting) and the necessary tools (ssh, tar or rsync). Use -- create the necessary partition table (or however it is called +- create the necessary volumes (like partitions, slices, ...) Get a live-cd, that ships with - rsync / tar From 7e155f4219c964be51dbc512843bf190d70d96f9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 14:00:54 +0100 Subject: [PATCH 442/581] prepare the next release Signed-off-by: Nico Schottelius --- ccollect.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 9cbc96c..163c96e 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -41,8 +41,8 @@ CPOSTEXEC="${CDEFAULTS}/post_exec" CMARKER=".ccollect-marker" export TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" -VERSION="0.8" -RELEASE="2009-08-20" +VERSION="0.8.1" +RELEASE="2009-11-XX" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" From ec61905fc4f72ce7b02d10299b7bbe47f3a7a715 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 14:02:50 +0100 Subject: [PATCH 443/581] always call $@, which is now setup correctly Signed-off-by: Nico Schottelius --- ccollect.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 163c96e..7747fcc 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -89,15 +89,13 @@ add_name() } # -# Execute on remote host, if backing up to a remote host +# Prepend "ssh ${remote_host}", if backing up to a remote host # pcmd() { - if [ "${remote_host}" ]; then - ssh "${remote_host}" "$@" - else - "$@" - fi + [ "${remote_host}" ] && set -- "ssh" "${remote_host}" "$@" + + "$@" } # From afe732a69f27d85ad5a330bbbe222972f162af1b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 14:04:27 +0100 Subject: [PATCH 444/581] more changes for the next version Signed-off-by: Nico Schottelius --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changes/next b/doc/changes/next index 45972f9..2a9a906 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -5,3 +5,4 @@ * ccollect_analyse_logs.sh traps more errors and warnings (Patrick Drolet) * Remove -v for mkdir and rm, as they are not POSIX (Patrick Drolet) * Export destination_* to source specific post_exec (Nico Schottelius) + * Update documentation regarding exported variables (Nico Schottelius) From 49ef5871bceaee013b0a45af02f4ab536ce4a3e9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 14:10:30 +0100 Subject: [PATCH 445/581] remove old braindumps Signed-off-by: Nico Schottelius --- doc/braindumps/LOCAL_vs._REMOTE | 35 --------------------------------- doc/braindumps/README | 1 - 2 files changed, 36 deletions(-) delete mode 100644 doc/braindumps/LOCAL_vs._REMOTE delete mode 100644 doc/braindumps/README diff --git a/doc/braindumps/LOCAL_vs._REMOTE b/doc/braindumps/LOCAL_vs._REMOTE deleted file mode 100644 index f2a40b7..0000000 --- a/doc/braindumps/LOCAL_vs._REMOTE +++ /dev/null @@ -1,35 +0,0 @@ - to Local to Remote - backup destination is exiting - pre/postexec runs locally - --link-dest? - /delete_incomplete - can chech ddir - - can check destination dir - -> dooooooo it before! - - - remote_host! - => rddir_ls: - incomplete: ls -1 "${INTERVAL}"*".${c_marker}" - - host support? - ssh-host-support? - - => ssh_host => save to host - execute commands there! - - rm! - - --link-dest? - - --link-dest=DIR - => remote dirs, rsync remote - => works!!!! - - local_destination - remote_destination - => remote_* - - both - configuration is local (what to where) - diff --git a/doc/braindumps/README b/doc/braindumps/README deleted file mode 100644 index 973addc..0000000 --- a/doc/braindumps/README +++ /dev/null @@ -1 +0,0 @@ -Do not read the files in this directory From e18c9fa94d13999c23cf1be2e18e2a98397fe74d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 14:18:28 +0100 Subject: [PATCH 446/581] remove old todos, create new todo list Signed-off-by: Nico Schottelius --- doc/todo/0.5.2 | 4 --- doc/todo/0.5.3 | 34 ------------------ doc/todo/0.5.3.tonnerre | 11 ------ doc/todo/0.6 | 63 --------------------------------- doc/todo/0.6.1 | 23 ------------ doc/todo/0.6.2 | 1 - doc/todo/0.7.1 | 35 ------------------ doc/todo/0.7.2 | 63 --------------------------------- doc/todo/0.7.3 | 2 -- doc/todo/0.7.4 | 1 - doc/todo/0.8.0 | 6 ---- doc/{todo/extern => todos.text} | 4 +++ 12 files changed, 4 insertions(+), 243 deletions(-) delete mode 100644 doc/todo/0.5.2 delete mode 100644 doc/todo/0.5.3 delete mode 100644 doc/todo/0.5.3.tonnerre delete mode 100644 doc/todo/0.6 delete mode 100644 doc/todo/0.6.1 delete mode 100644 doc/todo/0.6.2 delete mode 100644 doc/todo/0.7.1 delete mode 100644 doc/todo/0.7.2 delete mode 100644 doc/todo/0.7.3 delete mode 100644 doc/todo/0.7.4 delete mode 100644 doc/todo/0.8.0 rename doc/{todo/extern => todos.text} (92%) diff --git a/doc/todo/0.5.2 b/doc/todo/0.5.2 deleted file mode 100644 index 0c1c225..0000000 --- a/doc/todo/0.5.2 +++ /dev/null @@ -1,4 +0,0 @@ -x Fix $? problem -x Check last dir searching -x Check count generation -x Check general functionality (remove testing) diff --git a/doc/todo/0.5.3 b/doc/todo/0.5.3 deleted file mode 100644 index 0019581..0000000 --- a/doc/todo/0.5.3 +++ /dev/null @@ -1,34 +0,0 @@ -Done: -==> screenshot -u0219 zrha166.netstream.ch # ~chdscni9/ccollect.sh weekly zrha166.netstream.ch -2007-08-16-21:49:44: ccollect 0.6: Beginning backup using interval weekly -[zrha166.netstream.ch] 2007-08-16-21:49:44: Beginning to backup -[zrha166.netstream.ch] 2007-08-16-21:49:45: Existing backups: 0 Total keeping backups: 8 -[zrha166.netstream.ch] 2007-08-16-21:49:45: Did not find existing backups for interval weekly. -[zrha166.netstream.ch] 2007-08-16-21:49:45: Using backup from daily. -[zrha166.netstream.ch] 2007-08-16-21:49:45: Beginning to backup, this may take some time... -[zrha166.netstream.ch] 2007-08-16-21:49:45: Creating /etc/ccollect/sources/zrha166.netstream.ch/destination/weekly.20070816-2149.22188 ... -[zrha166.netstream.ch] 2007-08-16-21:49:45: Transferring files... - -- beep-after-delete-hack? - -> tonnerre / #cLinux - -- replace nico-linux-ccollect with nico-ccollect - * ccollect is not Linux specific - -- remove exit-calls - * will leave behind unused temporary file! - * use _exit_err - -X join todos - -- fix possible quoting problems - * rsync_extra (redefine format) - * exclude - * other - * create _rsync, filtering args, creating new $@ - -- check and export variables for use in scripts! - -Contact Julian later: - * integrate updated german documentation diff --git a/doc/todo/0.5.3.tonnerre b/doc/todo/0.5.3.tonnerre deleted file mode 100644 index 4e7b7db..0000000 --- a/doc/todo/0.5.3.tonnerre +++ /dev/null @@ -1,11 +0,0 @@ -NetBSD/i386,amd64,sparc,sparc64 - -13:13 < Tonnerre> telmich, die kleine wä, 2 Variablen aus $(CCOLLECT) zu - machen -13:13 < Tonnerre> telmich, eine fü Sourcepfad und eine fü -Destinationfpad -13:13 < Tonnerre> pfa -13:13 < Tonnerre> d -13:14 < Tonnerre> telmich, die gröre wä die $() durch ${} zu ersetzen, so -dass der Kram auch mit !GNU-Make geht - diff --git a/doc/todo/0.6 b/doc/todo/0.6 deleted file mode 100644 index ee8e97f..0000000 --- a/doc/todo/0.6 +++ /dev/null @@ -1,63 +0,0 @@ -not did, did not remember why I wanted to do that: - -- do sed-time check: - -1.2. replace sed? -compare timing: -_echo () { echo "$name $msg" } -and create -_techo () { echo "$timestamp $name $msg" } -perhaps create -_eecho () { _techo "ERROR $msg" } -? - - - -done: -add note for - 09:24 < telmich> Obri: ~/.ssh/config! - -- implement use of different intervals as source for cloning - * use 'woechentlich' if available and no backup exists for 'daily' - * add 'prefer_latest' to prefer different interval, that's newer than - ours - * or add 'prefer_same_interval' instead? -- implement detection of partial backups -3. detect unfinished backups -sven / markierung - - wie seht der Marker aus? - -> .ccollect-YEAR-MM-DD.HHmm.pid (like the directory) - --> assume incomplete, when we did not finish. - --> means it's complete,when rsync was successful ----> partial implemented in 0.5.2 (commented out) -- do not check by name, but by time - * is ls -t posix? - * also check: -p -1 -- ccollect Zeitausgabe verbessern - - Wofuer wie lange gebraucht - * rm - * klonen (gibt es so ja nicht) - Wenn Summary angegeben ist am Ende ausgeben -- do we want rsync -H by default? - * no: takes much more memory -ssh / port change: - change rsync_extra format -- Variables: - source_$n - no_sources - name -- changed naming of sources: - YYYYMMDD-HHMM.PID (better readable) - => source / backup converter! => not needed! -config: - set destination-base - /etc/ccollect/defaults/source_config - -Documentation: -- hint: backuping backup -- update documentation: - - german doc? - - exit pre/post exec -> error codes (after implementation!) (in 0.4) - - write about fast changing fs -- delete_incomplete - diff --git a/doc/todo/0.6.1 b/doc/todo/0.6.1 deleted file mode 100644 index 99a17eb..0000000 --- a/doc/todo/0.6.1 +++ /dev/null @@ -1,23 +0,0 @@ -- Add filter support - * filter -- add source/ignore_failed_pre_exec -- add source/ignore_failed_post_exec -- do not delete_incomplete, when there's only one backup left! -- .ccollect-marker is deleted by rsync at the beginning! - - fix marking -- add logwrapper -- add loganalyser - speedup is - error codes - vanished files (see netstream)!!! - -Done: -- Improve finding backup from another interval: - o strip of interval name - o run sort -n - o use the last entry -- add --version, -V - -not needed: -- think about 'prefer_same_interval' / 'prefer_latest' - diff --git a/doc/todo/0.6.2 b/doc/todo/0.6.2 deleted file mode 100644 index 05798ff..0000000 --- a/doc/todo/0.6.2 +++ /dev/null @@ -1 +0,0 @@ -- fix delete_incomplete marker diff --git a/doc/todo/0.7.1 b/doc/todo/0.7.1 deleted file mode 100644 index 49df154..0000000 --- a/doc/todo/0.7.1 +++ /dev/null @@ -1,35 +0,0 @@ - - --------------------------------------------------------------------------------- -done: -- tools in makefile -14:15 also alle tools/ccollect_* -14:15 mach mal n besseres Makefile :) -14:15 hatte die extra deswegen umbenannt -14:15 nehme ich mal als hinweis für 0.7.1 - - -- add global delete_incomplete (/etc/ccollect/defaults/delete_incomplete) - -09:31 < Obri> telmich: hab nen kleinen tipp für ccollect -09:32 < Obri> telmich: ich habe hier hosts die nicht immer online sind, das ist dumm weil so das backup - kaputtgeht... -09:32 < Obri> telmich: ich habe jetzt das ein preexec script gebastelt: -09:32 < Obri> ping -c1 -q `cat /etc/ccollect/sources/$name/source | cut -d"@" -f2 | cut -d":" -f1` -09:33 < Obri> telmich: so bricht das backup ab wenn der host nicht erreichbar ist -09:33 < Obri> ohne dass ein altes backup entsorgt wird - - -- remove basename - -> include config from cconf! -> standard! - -reject: --------------------------------------------------------------------------------- -- fix german documentation! - => I'm the coder, somebody else can fix it. -- add wrapper, to do logging and analyse - * output filename in the wrapper, save into variable - => mktemp - * call analyser - => output stdout? - => no use for that currently diff --git a/doc/todo/0.7.2 b/doc/todo/0.7.2 deleted file mode 100644 index 79a50aa..0000000 --- a/doc/todo/0.7.2 +++ /dev/null @@ -1,63 +0,0 @@ --------------------------------------------------------------------------------- -Stats version --------------------------------------------------------------------------------- - -Add tools/ccollect_stats.sh, clearify license --------------------------------------------------------------------------------- -Preamble: - Netstream (www.netstream.ch) may consider using ccollect for backing up many - unix servers and needs some clean reporting. The following things - need to be done, so ccollect will be useful for netstream: - -Logger: - - Needs to write small mails (sysadmins don't have time to read mails) - - Needs to be able to only write a mail on error - * needs configuration option to also mail on warnings - - Should be able to send one mail per backup source - * or one for the whole backup job - -Messages: (to be used for filtering) - Errors: - Read from remote host .*: Connection timed out - - Warnings: - rsync: mknod .* failed: Invalid argument (22) - file has vanished: ".*" - --------------------------------------------------------------------------------- - -Analyzer: - - grosse Dateien - - grosse Veraenderungen --------------------------------------------------------------------------------- -exclude-lists-doku: -freebsd: - /usr/ports/* - /proc/* - /dev/* - /tmp/* - /var/tmp/* -linux: - /sys/* - /proc/* - /dev/* - /tmp/* - --------------------------------------------------------------------------------- -done: - -rsync_extra global! -- \n delimeted --------------------------------------------------------------------------------- - -S, --sparse - Try to handle sparse files efficiently so they take up less space on the des‐ - tination. Conflicts with --inplace because it’s not possible to overwrite - data in a sparse fashion. - --------------------------------------------------------------------------------- - Always report return code! - -[12:00] u0255:ddba034.netstream.ch# rsync -n -a --delete --stats --progress daily.20080324-0313.17841/ daily.20080325-0313.31148/ - -$tool - diff --git a/doc/todo/0.7.3 b/doc/todo/0.7.3 deleted file mode 100644 index 73e5ffc..0000000 --- a/doc/todo/0.7.3 +++ /dev/null @@ -1,2 +0,0 @@ -- add -a (archive) to ccollect_delete_source.text -- add listing of intervals to ccollect_list_intervals diff --git a/doc/todo/0.7.4 b/doc/todo/0.7.4 deleted file mode 100644 index 70515e7..0000000 --- a/doc/todo/0.7.4 +++ /dev/null @@ -1 +0,0 @@ -add support for wipe diff --git a/doc/todo/0.8.0 b/doc/todo/0.8.0 deleted file mode 100644 index 2b5130d..0000000 --- a/doc/todo/0.8.0 +++ /dev/null @@ -1,6 +0,0 @@ -- restructure code to easily allow global versus source options: - f_name=.... - check_option $f_name - => source - => defaults -- support all senseful options as default and source specific diff --git a/doc/todo/extern b/doc/todos.text similarity index 92% rename from doc/todo/extern rename to doc/todos.text index cb42a07..5be3799 100644 --- a/doc/todo/extern +++ b/doc/todos.text @@ -24,3 +24,7 @@ to have. This means I won't code them, so somebody can code them. - add option ("run_only_once") to prevent ccollect to run twice (per source/general) + -> or create wrapper, that takes care of it + +- add support for wipe + From 5d0a3c73d2408fc85eb26f82a66ff15ff5cc9d5e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 14:20:24 +0100 Subject: [PATCH 447/581] begin to cleanup the todo list Signed-off-by: Nico Schottelius --- doc/todos.text | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/todos.text b/doc/todos.text index 5be3799..0182040 100644 --- a/doc/todos.text +++ b/doc/todos.text @@ -1,6 +1,12 @@ +ccollect todos +============== +Nico Schottelius +0.1, for the current ccollect version +:Author Initials: NS + + These todos are things that would be senseful todo, but are just nice to have. This means I won't code them, so somebody can code them. --------------------------------------------------------------------------------- - Add ccollect-restore.sh (new project, perhaps coordinated with jchome's ccollect-config) @@ -28,3 +34,5 @@ to have. This means I won't code them, so somebody can code them. - add support for wipe +- cleanup doc/: remove old stuff, make clear what can be installeld, + cleanup ccollect-restoring.text From 8ae649c761ae6c22ca0478f53ede9ddeeb2423d4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 14:22:08 +0100 Subject: [PATCH 448/581] update release checklist Signed-off-by: Nico Schottelius --- doc/release-checklist | 3 +-- doc/todos.text | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/release-checklist b/doc/release-checklist index 7cba30c..71b40ee 100644 --- a/doc/release-checklist +++ b/doc/release-checklist @@ -1,8 +1,7 @@ * Change version and date in ccollect.sh * Change version in documentation/ccollect.text -* Regenerate documentation * Create tarball -* Transfer to home.schottelius.org +* Transfer to website * Extract files * Update website * Announce on freshmeat diff --git a/doc/todos.text b/doc/todos.text index 0182040..05bb56e 100644 --- a/doc/todos.text +++ b/doc/todos.text @@ -36,3 +36,6 @@ to have. This means I won't code them, so somebody can code them. - cleanup doc/: remove old stuff, make clear what can be installeld, cleanup ccollect-restoring.text + +- clean logwrapper.text and probably create logwrapper, that does + what is being stated in logwrapper.text From e508ef052fce1ad13d14627721d7301caf04a5a1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 14:25:06 +0100 Subject: [PATCH 449/581] reorder operating systems in documentation Signed-off-by: Nico Schottelius --- doc/ccollect.text | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index e2090a9..8bdd81a 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -21,9 +21,9 @@ Supported and tested operating systems and architectures ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ `ccollect` was successfully tested on the following platforms: -- GNU/Linux on amd64/hppa/i386/ppc/ARM - FreeBSD on amd64/i386 -- Mac OS X 10.5 +- GNU/Linux on amd64/arm/hppa/i386/ppc +- Mac OS X 10.5 - NetBSD on alpha/amd64/i386/sparc/sparc64 - OpenBSD on amd64 From d79c2b0a28fa19ff92a5f5cc16128f37b6aaaf57 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 14:36:49 +0100 Subject: [PATCH 450/581] begin to create bigger automated tests Signed-off-by: Nico Schottelius --- Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index cfef1b4..494dbcb 100644 --- a/Makefile +++ b/Makefile @@ -190,8 +190,10 @@ distclean: clean dist: distclean documentation #test: ccollect.sh documentation -test: ccollect.sh +/tmp/ccollect: mkdir -p /tmp/ccollect + +test: ccollect.sh /tmp/ccollect CCOLLECT_CONF=./conf ./ccollect.sh daily from-remote CCOLLECT_CONF=./conf ./ccollect.sh daily local CCOLLECT_CONF=./conf ./ccollect.sh daily "local-with&ersand" @@ -203,5 +205,7 @@ test: ccollect.sh touch /tmp/ccollect/$$(ls /tmp/ccollect | head -n1).ccollect-marker CCOLLECT_CONF=./conf ./ccollect.sh daily delete_incomplete CCOLLECT_CONF=./conf ./ccollect.sh daily no-source-must-fail -# for s in $$(ls ./conf/sources); do CCOLLECT_CONF=./conf echo ./ccollect.sh daily $$s; done -# CCOLLECT_CONF=./conf ./ccollect.sh -a daily + +test2: ccollect.sh /tmp/ccollect + cd ./conf/sources/; for s in *; do CCOLLECT_CONF=../ ../../ccollect.sh daily "$$s"; done + CCOLLECT_CONF=./conf ./ccollect.sh -a daily From a48fe6d41b98b4bee2b89c4a02c18533ace6c1ea Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 14:37:32 +0100 Subject: [PATCH 451/581] +braces Signed-off-by: Nico Schottelius --- Makefile | 1 + ccollect.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 494dbcb..e509290 100644 --- a/Makefile +++ b/Makefile @@ -208,4 +208,5 @@ test: ccollect.sh /tmp/ccollect test2: ccollect.sh /tmp/ccollect cd ./conf/sources/; for s in *; do CCOLLECT_CONF=../ ../../ccollect.sh daily "$$s"; done + touch /tmp/ccollect/$$(ls /tmp/ccollect | head -n1).ccollect-marker CCOLLECT_CONF=./conf ./ccollect.sh -a daily diff --git a/ccollect.sh b/ccollect.sh index 7747fcc..41411da 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -110,7 +110,7 @@ delete_from_file() [ $# -eq 1 ] && suffix="$1" && shift while read to_remove; do set -- "$@" "${to_remove}" - if [ "$suffix" ]; then + if [ "${suffix}" ]; then to_remove_no_suffix="$(echo ${to_remove} | sed "s/$suffix\$//")" set -- "$@" "${to_remove_no_suffix}" fi From 0f7891de8d04c38434e7e310803acb5e5c7c3c4e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 15:03:37 +0100 Subject: [PATCH 452/581] rename $i to $current_source Signed-off-by: Nico Schottelius --- ccollect.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 41411da..9fb73c3 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -247,13 +247,13 @@ fi # # Let's do the backup - here begins the real stuff # -i=0 -while [ "${i}" -lt "${no_sources}" ]; do +current_source=0 +while [ "${current_source}" -lt "${no_sources}" ]; do # # Get current source # - eval name=\"\$source_${i}\" - i=$((${i}+1)) + eval name=\"\$source_${current_source}\" + current_source=$((${current_source}+1)) export name From c2226f913411efb3280c359d683be64f5cc4e736 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 15:07:50 +0100 Subject: [PATCH 453/581] BUGFIX: Use different destination directory based on the source number If you have muliple sources, that go into the same destination directory or specify a source mulitple times on the command line and the backup is done within a minute, the destination directory will still be the name: 497 export destination_name="${INTERVAL}.$(${CDATE}).$$" None of the values will change for the next backup. Thus the new format since ccollect 0.8.1 is 497 export destination_name="${INTERVAL}.$(${CDATE}).$$-${source_no}" which contains the number of the current source. Signed-off-by: Nico Schottelius --- ccollect.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 9fb73c3..491710d 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -247,13 +247,13 @@ fi # # Let's do the backup - here begins the real stuff # -current_source=0 -while [ "${current_source}" -lt "${no_sources}" ]; do +source_no=0 +while [ "${source_no}" -lt "${no_sources}" ]; do # # Get current source # - eval name=\"\$source_${current_source}\" - current_source=$((${current_source}+1)) + eval name=\"\$source_${source_no}\" + source_no=$((${source_no}+1)) export name @@ -494,7 +494,7 @@ while [ "${current_source}" -lt "${no_sources}" ]; do fi # set time when we really begin to backup, not when we began to remove above - export destination_name="${INTERVAL}.$(${CDATE}).$$" + export destination_name="${INTERVAL}.$(${CDATE}).$$-${source_no}" export destination_dir="${ddir}/${destination_name}" export destination_full="${destination}/${destination_name}" From 564ef0bd873044e2c7530bd2cd0e923b8a3ac1d5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 15:11:26 +0100 Subject: [PATCH 454/581] add testing with parallel execution Signed-off-by: Nico Schottelius --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index e509290..4590d29 100644 --- a/Makefile +++ b/Makefile @@ -210,3 +210,4 @@ test2: ccollect.sh /tmp/ccollect cd ./conf/sources/; for s in *; do CCOLLECT_CONF=../ ../../ccollect.sh daily "$$s"; done touch /tmp/ccollect/$$(ls /tmp/ccollect | head -n1).ccollect-marker CCOLLECT_CONF=./conf ./ccollect.sh -a daily + CCOLLECT_CONF=./conf ./ccollect.sh -a -p daily From 7de72e5e8d5a60d082ae12177959c79aefc95f57 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 15:12:16 +0100 Subject: [PATCH 455/581] insert more faults into test setup and remove previous test Signed-off-by: Nico Schottelius --- Makefile | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 4590d29..1ca8502 100644 --- a/Makefile +++ b/Makefile @@ -194,20 +194,8 @@ dist: distclean documentation mkdir -p /tmp/ccollect test: ccollect.sh /tmp/ccollect - CCOLLECT_CONF=./conf ./ccollect.sh daily from-remote - CCOLLECT_CONF=./conf ./ccollect.sh daily local - CCOLLECT_CONF=./conf ./ccollect.sh daily "local-with&ersand" - CCOLLECT_CONF=./conf ./ccollect.sh daily source-without-destination - CCOLLECT_CONF=./conf ./ccollect.sh daily "source with spaces and interval" - CCOLLECT_CONF=./conf ./ccollect.sh daily to-remote - CCOLLECT_CONF=./conf ./ccollect.sh daily with_exec - CCOLLECT_CONF=./conf ./ccollect.sh daily very_verbose - touch /tmp/ccollect/$$(ls /tmp/ccollect | head -n1).ccollect-marker - CCOLLECT_CONF=./conf ./ccollect.sh daily delete_incomplete - CCOLLECT_CONF=./conf ./ccollect.sh daily no-source-must-fail - -test2: ccollect.sh /tmp/ccollect cd ./conf/sources/; for s in *; do CCOLLECT_CONF=../ ../../ccollect.sh daily "$$s"; done touch /tmp/ccollect/$$(ls /tmp/ccollect | head -n1).ccollect-marker CCOLLECT_CONF=./conf ./ccollect.sh -a daily + touch /tmp/ccollect/$$(ls /tmp/ccollect | head -n1).ccollect-marker CCOLLECT_CONF=./conf ./ccollect.sh -a -p daily From e9c02b8e2d0cc9ed2d41f2ea9e2f3536c219cb73 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 15:16:51 +0100 Subject: [PATCH 456/581] plural Signed-off-by: Nico Schottelius --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 558594d..1b5341d 100644 --- a/README +++ b/README @@ -7,7 +7,7 @@ ccollect backups (local or remote) data to local or remote destinations. You can retrieve the latest version of ccollect at [0]. ccollect was inspired by rsnapshot [1], which has some problems: - - configuration parameters has to be TAB seperated + - configuration parameters have to be TAB seperated - you can not specify per source exclude lists - no per source pre/post execution support - no parallel execution From 49cb1f92eeaec36e0d3068ca8845161d5f0fb4c1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 15:17:01 +0100 Subject: [PATCH 457/581] join line Signed-off-by: Nico Schottelius --- ccollect.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 491710d..23bab24 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -462,8 +462,8 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # Check: maximum number of backups is reached? # - count="$(pcmd ls -d1 "${ddir}/${INTERVAL}."*"/" | wc -l \ - | sed 's/^ *//g')" || _exit_err "Counting backups failed" + count="$(pcmd ls -d1 "${ddir}/${INTERVAL}."*"/" | wc -l | sed 's/^ *//g')" \ + || _exit_err "Counting backups failed" _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" From ccf86defaf0ed71cc131d8b1d872902b958745c6 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 15:26:57 +0100 Subject: [PATCH 458/581] move pre_exec part to the top Signed-off-by: Nico Schottelius --- ccollect.sh | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 23bab24..4e04bde 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -270,6 +270,11 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # ( backup="${CSOURCES}/${name}" + c_source="${backup}/source" + c_dest="${backup}/destination" + c_pre_exec="${backup}/pre_exec" + c_post_exec="${backup}/post_exec" + # # Stderr to stdout, so we can produce nice logs # @@ -296,12 +301,19 @@ while [ "${source_no}" -lt "${no_sources}" ]; do fi # - # Read / create configuration + # First execute pre_exec, which may generate destination or other parameters + # + if [ -x "${c_pre_exec}" ]; then + _techo "Executing ${c_pre_exec} ..." + "${c_pre_exec}"; ret="$?" + _techo "Finished ${c_pre_exec} (return code ${ret})." + + [ "${ret}" -eq 0 ] || _exit_err "${c_pre_exec} failed. Skipping." + fi + + # + # Read source configuration # - c_source="${backup}/source" - c_dest="${backup}/destination" - c_pre_exec="${backup}/pre_exec" - c_post_exec="${backup}/post_exec" for opt in verbose very_verbose summary exclude rsync_options \ delete_incomplete remote_host rsync_failure_codes \ mtime quiet_if_down ; do @@ -321,17 +333,6 @@ while [ "${source_no}" -lt "${no_sources}" ]; do TSORT="tc" fi - # - # First execute pre_exec, which may generate destination or other parameters - # - if [ -x "${c_pre_exec}" ]; then - _techo "Executing ${c_pre_exec} ..." - "${c_pre_exec}"; ret="$?" - _techo "Finished ${c_pre_exec} (return code ${ret})." - - [ "${ret}" -eq 0 ] || _exit_err "${c_pre_exec} failed. Skipping." - fi - # # Source configuration checks # From f98853379ee8a55e112f6111454539353749a688 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 15:28:33 +0100 Subject: [PATCH 459/581] also move the interval check further to the beginning Signed-off-by: Nico Schottelius --- ccollect.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 4e04bde..8ef2183 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -324,6 +324,19 @@ while [ "${source_no}" -lt "${no_sources}" ]; do fi done + # + # Interval definition: First try source specific, fallback to default + # + c_interval="$(cat "${backup}/intervals/${INTERVAL}" 2>/dev/null)" + + if [ -z "${c_interval}" ]; then + c_interval="$(cat "${CDEFAULTS}/intervals/${INTERVAL}" 2>/dev/null)" + + if [ -z "${c_interval}" ]; then + _exit_err "No definition for interval \"${INTERVAL}\" found. Skipping." + fi + fi + # # Sort by ctime (default) or mtime (configuration option) # @@ -446,19 +459,6 @@ while [ "${source_no}" -lt "${no_sources}" ]; do fi fi - # - # Interval definition: First try source specific, fallback to default - # - c_interval="$(cat "${backup}/intervals/${INTERVAL}" 2>/dev/null)" - - if [ -z "${c_interval}" ]; then - c_interval="$(cat "${CDEFAULTS}/intervals/${INTERVAL}" 2>/dev/null)" - - if [ -z "${c_interval}" ]; then - _exit_err "No definition for interval \"${INTERVAL}\" found. Skipping." - fi - fi - # # Check: maximum number of backups is reached? # From 545158b56fc6e461b8dc0b9513b032e3c0eb7bc7 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 16:14:29 +0100 Subject: [PATCH 460/581] cleanup for messages and remove unecessary message message=Beginning to backup, this may take some time... Signed-off-by: Nico Schottelius --- ccollect.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 8ef2183..4b8214f 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -462,7 +462,6 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Check: maximum number of backups is reached? # - count="$(pcmd ls -d1 "${ddir}/${INTERVAL}."*"/" | wc -l | sed 's/^ *//g')" \ || _exit_err "Counting backups failed" @@ -487,25 +486,24 @@ while [ "${source_no}" -lt "${no_sources}" ]; do _exit_err "Failed to list contents of ${ddir}." # - # clone from old backup, if existing + # Clone from old backup, if existing # if [ "${last_dir}" ]; then set -- "$@" "--link-dest=${ddir}/${last_dir}" _techo "Hard linking from ${last_dir}" fi - # set time when we really begin to backup, not when we began to remove above + # + # Include current time in name, not the time when we began to remove above + # export destination_name="${INTERVAL}.$(${CDATE}).$$-${source_no}" export destination_dir="${ddir}/${destination_name}" export destination_full="${destination}/${destination_name}" - # give some info - _techo "Beginning to backup, this may take some time..." - - _techo "Creating ${destination_dir} ..." + _techo "Creating directory ${destination_dir} ..." [ "${VVERBOSE}" ] && echo "mkdir ${destination_dir}" pcmd mkdir "${destination_dir}" || \ - _exit_err "Creating ${destination_dir} failed. Skipping." + _exit_err "Creating directory ${destination_dir} failed. Skipping." # # added marking in 0.6 (and remove it, if successful later) From f630bef3b5a549ae5092e24f7f00576ac95af8cd Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 16:15:00 +0100 Subject: [PATCH 461/581] Finally simplify the time calculations! According to http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap01.html a shell must be able to do modulus (=remainder). Zsh, bash and dash confirm this and thus I can save another line and get rid of a very ugly one. Signed-off-by: Nico Schottelius --- ccollect.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index 4b8214f..ba91e49 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -560,14 +560,14 @@ while [ "${source_no}" -lt "${no_sources}" ]; do fi fi - # Calculation + # + # Time calculation + # end_s="$(${SDATE})" - full_seconds="$((${end_s} - ${begin_s}))" hours="$((${full_seconds} / 3600))" - seconds="$((${full_seconds} - (${hours} * 3600)))" - minutes="$((${seconds} / 60))" - seconds="$((${seconds} - (${minutes} * 60)))" + minutes="$(((${full_seconds} % 3600) / 60))" + seconds="$((${full_seconds} % 60))" _techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" ) | add_name From 0b8e6409cf45b8a8af3485ecfced804c29e875f4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 16:18:36 +0100 Subject: [PATCH 462/581] more changes for the upcoming release Signed-off-by: Nico Schottelius --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changes/next b/doc/changes/next index 2a9a906..42f3007 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -6,3 +6,4 @@ * Remove -v for mkdir and rm, as they are not POSIX (Patrick Drolet) * Export destination_* to source specific post_exec (Nico Schottelius) * Update documentation regarding exported variables (Nico Schottelius) + * Simplify time calculation (Nico Schottelius) From 9c474129917b72aade20a9791156319bc61f56d0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 16:21:21 +0100 Subject: [PATCH 463/581] integrate pdf support for documents soon Signed-off-by: Nico Schottelius --- doc/todos.text | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/todos.text b/doc/todos.text index 05bb56e..4fa2a18 100644 --- a/doc/todos.text +++ b/doc/todos.text @@ -39,3 +39,5 @@ to have. This means I won't code them, so somebody can code them. - clean logwrapper.text and probably create logwrapper, that does what is being stated in logwrapper.text + +- include pdf support again (Makefile:72) From 23c395bcbddefe4fb7c4ea6c524df977a9dec75c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Nov 2009 16:27:23 +0100 Subject: [PATCH 464/581] remove some old stuff from the makefile Signed-off-by: Nico Schottelius --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index 1ca8502..3c092f3 100644 --- a/Makefile +++ b/Makefile @@ -128,7 +128,6 @@ TOOLSMAN = $(subst .sh,.text,$(TOOLSMAN1)) TOOLSFP = $(subst ccollect,tools/ccollect,$(TOOLS)) -#t2: $(TOOLSMAN) t2: echo $(TOOLS) - $(TOOLSMAN) - $(TOOLSFP) @@ -189,7 +188,6 @@ distclean: clean # dist: distclean documentation -#test: ccollect.sh documentation /tmp/ccollect: mkdir -p /tmp/ccollect From 44442a09c943036e7d976a3d72b9706c085d8fdd Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 2 Nov 2009 07:45:51 +0100 Subject: [PATCH 465/581] todo for the version after the next version Signed-off-by: Nico Schottelius --- doc/todos.text | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/todos.text b/doc/todos.text index 4fa2a18..cf687cb 100644 --- a/doc/todos.text +++ b/doc/todos.text @@ -41,3 +41,5 @@ to have. This means I won't code them, so somebody can code them. what is being stated in logwrapper.text - include pdf support again (Makefile:72) + +- integrate website into ccollect -> updates are done here From ca9106054b462d2446deff9bb068e3e95fc316ce Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 2 Nov 2009 07:46:39 +0100 Subject: [PATCH 466/581] update version in the documentation Signed-off-by: Nico Schottelius --- doc/ccollect.text | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 8bdd81a..a751abf 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -0.8, for ccollect 0.8, Initial Version from 2006-01-13 +0.8.1, for ccollect 0.8.1, Initial Version from 2006-01-13 :Author Initials: NS @@ -159,7 +159,7 @@ For those who do not want to read the whole long document: -------------------------------------------------------------------------------- # get latest ccollect tarball from http://www.nico.schottelius.org/software/ccollect/ # replace value for CCV with the current version -export CCV=0.8 +export CCV=0.8.1 # # replace 'wget' with 'fetch' on bsd From 86992b9787e7f99750cf1a8671cea87fc98db013 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 2 Nov 2009 07:49:57 +0100 Subject: [PATCH 467/581] begin to update rpm spec file Signed-off-by: Nico Schottelius --- contrib/ccollect.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/ccollect.spec b/contrib/ccollect.spec index 477a878..0e35bb0 100644 --- a/contrib/ccollect.spec +++ b/contrib/ccollect.spec @@ -1,11 +1,11 @@ Summary: (pseudo) incremental backup with different exclude lists using hardlinks and rsync Name: ccollect -Version: 0.8 +Version: 0.8.1 Release: 0 URL: http://www.nico.schottelius.org/software/ccollect Source0: http://www.nico.schottelius.org/software/ccollect/%{name}-%{version}.tar.bz2 -License: LGPL-3 +License: GPL-3 Group: Applications/System Vendor: Nico Schottelius BuildRoot: %{_tmppath}/%{name}-%(id -un) From e47fb78603172b8636956c95025705346ef9bb9c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 23 Dec 2009 18:43:40 +0100 Subject: [PATCH 468/581] import new ccollect_mgr version from patrick Signed-off-by: Nico Schottelius --- contrib/patrick/ccollect_mgr.sh | 467 ++++++++++++++++++-------------- 1 file changed, 269 insertions(+), 198 deletions(-) diff --git a/contrib/patrick/ccollect_mgr.sh b/contrib/patrick/ccollect_mgr.sh index 5678779..fe69286 100644 --- a/contrib/patrick/ccollect_mgr.sh +++ b/contrib/patrick/ccollect_mgr.sh @@ -1,7 +1,7 @@ #!/bin/sh # # ---------------------------------------------------------------------------- -# Last update: 2009-10-29 +# Last update: 2009-12-11 # By : pdrolet (ccollect_mgr@drolet.name) # ---------------------------------------------------------------------------- # Job manager to the ccollect utilities @@ -9,7 +9,8 @@ # # Provides the following features # 1) Determine the interval (daily/weekly/monthly) -# 2) Perform the backups using ccollect +# 2) Check the estimated file transfer size +# 3) Perform the backups using ccollect # 4) Copy the ccollect log to the first backup of the set # 5) Build a periodic report and include the real amount of disk used # 6) Send an email if there has been errors or warnings @@ -48,69 +49,74 @@ # Send warning if the worst case data transfer will be larger than (in MB)... warning_transfer_size=1024 +abort_transfer_size=5120 # Define paths and default file names -ADD_TO_PATH=/opt/bin:/opt/sbin:/usr/local/bin:/usr/local/sbin -CCOLLECT=ccollect.sh -CCOLLECT_CONF=/usr/local/etc/ccollect +ADD_TO_PATH="/opt/bin:/opt/sbin:/usr/local/bin:/usr/local/sbin" +CCOLLECT="ccollect.sh" +CCOLLECT_CONF="/usr/local/etc/ccollect" -per_report=${CCOLLECT_CONF}/periodic_report.log -tmp_report=/tmp/ccollect.$$ -tmp_email=/tmp/email.$$ +PS="/opt/bin/ps" +FIND="/opt/bin/find" + +TEMP_LOG="${CCOLLECT_CONF}"/log.$$ +per_report="${CCOLLECT_CONF}/periodic_report.log" +tmp_report="/tmp/ccollect.$$" +tmp_mgr="/tmp/ccollect_mgr.$$" +tmp_email="/tmp/email.$$" + +backups_not_found="" # Sub routines... -find_interval() +send_email() { - # ---------------------------------------------------- - # Find interval for ccollect backup. - # optional parameters: - # - Day of the week to do weekly backups - # - Do monthly instead of weekly on the Nth week - # ---------------------------------------------------- - - weekly_backup=$1 - monthly_backup=$2 + # Send a simple email using mini-sendmail. - weekday=`date "+%w"` - if [ ${weekday} -eq ${weekly_backup} ]; then - dom=`date "+%d"` - weeknum=$(( ( ${dom} / 7 ) + 1 )) - if [ ${weeknum} -eq ${monthly_backup} ]; then - interval=monthly - else - interval=weekly - fi - else - interval=daily + msg_body_file="$1" + shift + + # ------------------------------ + # Quit if we can't send an email + # ------------------------------ + if [ "${to}" == "" ] || [ "${mail_server}" == "" ]; then + echo "Missing mail server or destination email. No email sent with subject: $@" + exit 1 fi + + echo from: "${from}" > "${tmp_email}" + echo subject: "$@" >> "${tmp_email}" + echo to: "${to}" >> "${tmp_email}" + echo cc: >> "${tmp_email}" + echo bcc: >> "${tmp_email}" + echo "" >> "${tmp_email}" + echo "" >> "${tmp_email}" + cat "${msg_body_file}" >> "${tmp_email}" + echo "" >> "${tmp_email}" + + echo "" + echo Sending email to ${to} to report the following: + echo ----------------------------------------------- + cat "${tmp_email}" + cat "${tmp_email}" | mini_sendmail -f"${from}" -s"${mail_server}" "${to}" + rm "${tmp_email}" } -move_log() +remove_source() { - for backup in $@ ; do - ddir="$(cat "${CCOLLECT_CONF}"/sources/"${backup}"/destination)"; ret="$?" - if [ "${ret}" -ne 0 ]; then - echo "Destination ${CCOLLECT_CONF}/sources/${backup}/destination is not readable... Skipping." - backup_dir="" - else - backup_dir=`cat ${TEMP_LOG} | grep "\[${backup}\] .*: Creating ${ddir}" | awk '{ print $4 }'` - fi - if [ "${backup_dir}" != "" ]; then - new_log=${backup_dir}/ccollect.log - mv ${TEMP_LOG} ${new_log} - echo New Log Location: ${new_log} - return 0 - fi - done - echo "WARNING: none of the backup set have been created" - new_log=${TEMP_LOG} + remove_no=$1 + eval echo Removing backup \"\$source_$1\" + + no_sources="$(( ${no_sources} - 1 ))" + while [ "${remove_no}" -lt "${no_sources}" ]; do + eval source_${remove_no}=\"\$source_$(( ${remove_no} + 1))\" + eval ddir_${remove_no}=\"\$ddir_$(( ${remove_no} + 1))\" + remove_no=$(( ${remove_no} + 1 )) + done } compute_rdu() { - # WARNING: Don't pass a directory with a space as parameter (I'm too new at scripting!) - kdivider=1 find_options="" @@ -123,12 +129,17 @@ compute_rdu() kdivider=1048576 ;; *) - find_options="${find_options} $1" + break ;; esac shift done + if [ "$#" == 0 ]; then + rdu=0 + return 1 + fi + # ------------------------------------------------------------------------------------------------------ # Compute the real disk usage (eg: hard links do files outside the backup set don't count) # ------------------------------------------------------------------------------------------------------ @@ -141,103 +152,88 @@ compute_rdu() # 5) Present the result with additional dividers based on command line parameters # - rdu=$(( ( `/opt/bin/find ${find_options} -printf '%n %i %y %k \n' \ + rdu=$(( ( `"${FIND}" "$@" -printf '%n %i %y %k \n' \ | sort -n \ | uniq -c \ | awk '{ if (( $1 == $2 ) || ($4 == "d")) { sum += $5; } } END { printf "%u\n",(sum); }'` \ + ${kdivider} - 1 ) / ${kdivider} )) - echo RDU for ${find_options} is ${rdu} -} - -compute_total_rdu() -{ - real_usage=0 - - # ------------------------------------------ - # Get the real disk usage for the backup set - # ------------------------------------------ - for backup in $@ ; do - ddir="$(cat "${CCOLLECT_CONF}"/sources/"${backup}"/destination)"; ret="$?" - echo ${backup} - Adding ${ddir} to backup list - backup_dir_list="${backup_dir_list} ${ddir}" - if [ "${ret}" -ne 0 ]; then - echo "Destination ${CCOLLECT_CONF}/sources/${backup}/destination is not readable... Skipping." - else - backup_dir=`find ${ddir}/${interval}.* -maxdepth 0 -type d -print | sort -r | head -n 1` - compute_rdu -m ${backup_dir} - real_usage=$(( ${real_usage} + ${rdu} )) - fi - done - echo Backup list - ${backup_dir_list} -} - -send_email() -{ - # Send a simple email using mini-sendmail. - - msg_body_file=$1 - shift - - # ------------------------------ - # Quit if we can't send an email - # ------------------------------ - if [ "${to}" == "" ] || [ "${mail_server}" == "" ]; then - echo "Missing mail server or destination email. No email sent with subject: $@" - exit 1 - fi - - echo from: ${from} > ${tmp_email} - echo subject: $@ >> ${tmp_email} - echo to: ${to} >> ${tmp_email} - echo cc: >> ${tmp_email} - echo bcc: >> ${tmp_email} - echo "" >> ${tmp_email} - echo "" >> ${tmp_email} - cat ${msg_body_file} >> ${tmp_email} - echo "" >> ${tmp_email} - - echo Sending email to ${to} to report the following error: - echo ----------------------------------------------------- - cat ${tmp_email} - cat ${tmp_email} | mini_sendmail -f${from} -s${mail_server} ${to} - rm ${tmp_email} } check_running_backups() { # Check if a backup is already ongoing. If so, skip and send email # Don't use the ccollect marker as this is no indication if it is still running - - for backup in ${ccollect_backups} ; do + + source_no=0 + while [ "${source_no}" -lt "${no_sources}" ]; do + eval backup=\"\$source_${source_no}\" + PID=$$ - /opt/bin/ps -e -o pid,ppid,args 2> /dev/null | grep -v -e grep -e "${PID}.*ccollect.*${backup}" | grep "ccollect.*${backup}" > /tmp/ccollect_mgr.$$ 2> /dev/null - running_proc=`cat /tmp/ccollect_mgr.$$ | wc -l` + "${PS}" -e -o pid,ppid,args 2> /dev/null \ + | grep -v -e grep -e "${PID}.*ccollect.*${backup}" \ + | grep "ccollect.*${backup}" > "${tmp_mgr}" 2> /dev/null + running_proc=`cat "${tmp_mgr}" | wc -l` + if [ ${running_proc} -gt 0 ]; then + # Remove backup from list running_backups="${running_backups}${backup} " - echo "Process:" - cat /tmp/ccollect.$$ + + echo "Process already running:" + cat "${tmp_mgr}" + + remove_source ${source_no} else - backups_to_do="${backups_to_do}${backup} " + source_no=$(( ${source_no} + 1 )) fi - rm /tmp/ccollect_mgr.$$ + rm "${tmp_mgr}" done - ccollect_backups=${backups_to_do} if [ "${running_backups}" != "" ]; then - echo "skipping ccollect backups already running: ${running_backups}" | tee ${tmp_report} - send_email ${tmp_report} "WARNING - skipping ccollect backups already running: ${running_backups}" - rm ${tmp_report} + echo "skipping ccollect backups already running: ${running_backups}" | tee "${tmp_report}" + send_email "${tmp_report}" "WARNING - skipping ccollect backups already running: ${running_backups}" + rm "${tmp_report}" fi } +find_interval() +{ + # ---------------------------------------------------- + # Find interval for ccollect backup. + # optional parameters: + # - Day of the week to do weekly backups + # - Do monthly instead of weekly on the Nth week + # ---------------------------------------------------- + + weekly_backup="$1" + monthly_backup="$2" + + weekday=`date "+%w"` + if [ ${weekday} -eq ${weekly_backup} ]; then + dom=`date "+%e"` + weeknum=$(( ( ${dom} / 7 ) + 1 )) + if [ "${weeknum}" -eq "${monthly_backup}" ]; then + interval=monthly + else + interval=weekly + fi + else + interval=daily + fi +} + precheck_transfer_size() { # Check the estimated (worst case) transfer size and send email if larger than certain size + # Abort backup if total transfer is larger than maximum limit (ex: an error somewhere + # requires to do full backup and not incremental, which could blow the quota with ISP) # # Be nice and add error checking one day... - for backup in ${ccollect_backups} ; do - ddir="$(cat "${CCOLLECT_CONF}"/sources/"${backup}"/destination)"; ret="$?" + source_no=0 + while [ "${source_no}" -lt "${no_sources}" ]; do + eval backup=\"\$source_${source_no}\" + eval ddir=\"\$ddir_${source_no}\" + last_dir="$(ls -tcp1 "${ddir}" | grep '/$' | head -n 1)" sdir="$(cat "${CCOLLECT_CONF}"/sources/"${backup}"/source)"; ret="$?" if [ -f "${CCOLLECT_CONF}"/sources/"${backup}"/exclude ]; then @@ -245,66 +241,152 @@ precheck_transfer_size() else exclude="" fi + rsync_options="" if [ -f "${CCOLLECT_CONF}"/sources/"${backup}"/rsync_options ]; then while read line; do rsync_options="${rsync_options} ${line}" done < ${CCOLLECT_CONF}/sources/${backup}/rsync_options fi - rsync -n -a --delete --stats ${rsync_options} ${exclude} ${sdir} ${ddir}/${last_dir} > ${tmp_report} - tx_rx=`cat ${tmp_report} | grep "Total transferred file size" | \ + + rsync -n -a --delete --stats ${rsync_options} "${exclude}" "${sdir}" "${ddir}/${last_dir}" > "${tmp_report}" + + tx_rx=`cat "${tmp_report}" | grep "Total transferred file size" | \ awk '{ { tx += $5 } } END { printf "%u",(((tx)+1024*1024-1)/1024/1024); }'` total_xfer=$(( ${total_xfer} + ${tx_rx} )) + + source_no=$(( ${source_no} + 1 )) done - echo Transfer estimation for ${ccollect_backups}: ${total_xfer} MB - if [ ${total_xfer} -gt ${warning_transfer_size} ]; then + echo "Transfer estimation for${ccollect_backups}: ${total_xfer} MB" + + if [ ${total_xfer} -gt ${abort_transfer_size} ]; then + # -------------------------------------------------- + # Send an error if transfer is larger than max limit + # -------------------------------------------------- + # Useful to detect potential issues when there is transfer quota (ex: with ISP) + + echo "Data transfer larger than ${abort_transfer_size} MB is expected for${ccollect_backups}" >> "${tmp_report}" + echo "** BACKUP ABORTED **" >> "${tmp_report}" + + send_email "${tmp_report}" "ERROR: aborted ccollect for${ccollect_backups} -- Estimated Tx+Rx: ${total_xfer} MB" + rm "${tmp_report}" + exit 1 + elif [ ${total_xfer} -gt ${warning_transfer_size} ]; then # -------------------------------------------------- # Send a warning if transfer is expected to be large # -------------------------------------------------- # Useful to detect potential issues when there is transfer quota (ex: with ISP) - echo Data transfer larger than ${warning_transfer_size} MB is expected for ${ccollect_backups} > ${tmp_report} + echo "Data transfer larger than ${warning_transfer_size} MB is expected for${ccollect_backups}" > "${tmp_report}" - send_email ${tmp_report} "WARNING ccollect for ${ccollect_backups} -- Estimated Tx+Rx: ${total_xfer} MB" - rm ${tmp_report} + send_email "${tmp_report}" "WARNING ccollect for${ccollect_backups} -- Estimated Tx+Rx: ${total_xfer} MB" + rm "${tmp_report}" + fi +} + +build_backup_dir_list() +{ + source_no=0 + while [ "${source_no}" -lt "${no_sources}" ]; do + eval backup=\"\$source_${source_no}\" + eval ddir=\"\$ddir_${source_no}\" + + backup_dir="`cat "${TEMP_LOG}" \ + | grep "\[${backup}\] .*: Creating.* ${ddir}" \ + | head -n 1 \ + | sed 's/[^\/]*\//\//; s/ \.\.\.//'`" + + if [ ! -d "${backup_dir}" ]; then + backups_not_found="${backups_not_found}\"${backup}\" " + echo -n "Backup directory for \"${backup}\" not found. " + remove_source "${source_no}" + else + eval export backup_dir_list_${source_no}="${backup_dir}" +# eval echo Backup Dir List: \"\$backup_dir_list_${source_no}\" + source_no=$(( ${source_no} + 1 )) + fi + done +} + +move_log() +{ + if [ "${no_sources}" -gt 0 ]; then + eval log_file=\"\$backup_dir_list_1\"/ccollect.log + mv "${TEMP_LOG}" "${log_file}" + echo New Log Location: "${log_file}" + else + echo "WARNING: none of the backup set have been created" + log_file="${TEMP_LOG}" fi } send_report() { - log=$1 - # Analyze log for periodic report and for error status report - cat ${log} | ccollect_analyse_logs.sh iwe > ${tmp_report} + cat "${log_file}" | ccollect_analyse_logs.sh iwe > "${tmp_report}" # ------------------------- # Build the periodic report # ------------------------- - # Compute the total number of MB sent and received for all the backup sets - tx_rx=`cat ${tmp_report} | \ + tx_rx=`cat "${tmp_report}" | \ grep 'sent [[:digit:]]* bytes received [0-9]* bytes' | \ awk '{ { tx += $3 } { rx += $6} } END \ - { printf "%u",(((tx+rx)+1024*1024-1)/1024/1024); }'` + { printf "%u",(((tx+rx)+(1024*1024)-1)/1024/1024); }'` current_date=`date +'20%y/%m/%d %Hh%M -- '` - + + # ------------------------------------------ + # Get the real disk usage for the backup set + # ------------------------------------------ + total_rdu=0 + source_no=0 + while [ "${source_no}" -lt "${no_sources}" ]; do + eval backup_dir=\"\$backup_dir_list_${source_no}\" + compute_rdu -m "${backup_dir}" + total_rdu=$(( ${total_rdu} + ${rdu} )) + source_no=$(( ${source_no} + 1 )) + done + # --------------------------------------------------------- # Get the disk usage for all backups of each backup sets... - # ** be patient ** + # ** BE PATIENT!!! ** # --------------------------------------------------------- - compute_rdu -g ${backup_dir_list} + historical_rdu=0 + source_no=0 + while [ "${source_no}" -lt "${no_sources}" ]; do + eval backup_dir=\"\$ddir_${source_no}\" + compute_rdu -m "${backup_dir}" + historical_rdu=$(( ${historical_rdu} + ${rdu} )) + source_no=$(( ${source_no} + 1 )) + done + + historical_rdu=$(( (${historical_rdu}+1023) / 1024 )) + + if [ "${no_sources}" -gt 0 ]; then + ccollect_backups="" + else + ccollect_backups="(none performed) " + fi + + source_no=0 + while [ "${source_no}" -lt "${no_sources}" ]; do + eval backup=\"\$source_${source_no}\" + ccollect_backups="${ccollect_backups}\"${backup}\" " + source_no=$(( ${source_no} + 1 )) + done echo ${current_date} Tx+Rx: ${tx_rx} MB -- \ - Disk Usage: ${real_usage} MB -- \ - Backup set \(${interval}\): ${ccollect_backups} -- \ - Historical backups usage: ${rdu} GB >> ${per_report} - + Disk Usage: ${total_rdu} MB -- \ + Backup set \(${interval}\):${ccollect_backups} -- \ + Historical backups usage: ${historical_rdu} GB >> "${per_report}" + echo "Total Data Transfer: ${tx_rx} MB -- Total Disk Usage: ${total_rdu} MB -- Total Historical backups usage: ${historical_rdu} GB" + # ---------------------------------------- # Send a status email if there is an error # ---------------------------------------- - ccollect_we=`cat ${log} | ccollect_analyse_logs.sh we | wc -l` + ccollect_we=`cat "${log_file}" | ccollect_analyse_logs.sh we | wc -l` if [ ${ccollect_we} -ge 1 ]; then - send_email ${tmp_report} "ERROR ccollect for ${ccollect_backups} -- Tx+Rx: ${tx_rx} MB" + send_email "${tmp_report}" "ERROR ccollect for${ccollect_backups} -- Tx+Rx: ${tx_rx} MB" fi # -------------------- @@ -313,27 +395,27 @@ send_report() if [ ${report_interval} == ${interval} ] || [ ${interval} == "monthly" ]; then # Make reporting atomic to handle concurrent ccollect_mgr instances - mv ${per_report} ${per_report}.$$ - cat ${per_report}.$$ >> ${per_report}.history + mv "${per_report}" "${per_report}".$$ + cat "${per_report}".$$ >> "${per_report}".history # Calculate total amount of bytes sent and received - tx_rx=`cat ${per_report}.$$ | \ + tx_rx=`cat "${per_report}".$$ | \ awk '{ { transfer += $5 } } END \ { printf "%u",(transfer); }'` # Send email - send_email ${per_report}.$$ "${report_interval} ccollect status for ${ccollect_backups} -- Tx+Rx: ${tx_rx} MB" - rm ${per_report}.$$ + send_email "${per_report}.$$" "${report_interval} ccollect status for${ccollect_backups} -- Tx+Rx: ${tx_rx} MB" + rm "${per_report}.$$" fi - rm ${tmp_report} + rm "${tmp_report}" } # ------------------------------------------------ # Add to PATH in case we're launching from crontab # ------------------------------------------------ -PATH=${ADD_TO_PATH}:${PATH} +PATH="${ADD_TO_PATH}:${PATH}" # -------------- # Default Values @@ -349,59 +431,74 @@ weekly_backup=1 # Set the monthly backup interval. Default is 4th Monday of every month monthly_backup=4 -show_help=0 - # --------------------------------- # Parse command line # --------------------------------- +show_help=0 +export no_sources=0 + while [ "$#" -ge 1 ]; do case "$1" in -help) show_help=1 ;; -from) - from=$2 + from="$2" shift ;; -to) - to=$2 + to="$2" shift ;; -server|mail_server) - mail_server=$2 + mail_server="$2" shift ;; -weekly) - weekly_backup=$2 + weekly_backup="$2" shift ;; -monthly) - monthly_backup=$2 + monthly_backup="$2" shift ;; -warning_size) - warning_transfer_size=$2 + warning_transfer_size="$2" + shift + ;; + -abort_size) + abort_transfer_size="$2" shift ;; -report) - report_interval=$2 + report_interval="$2" shift ;; -*) - ccollect_options="${ccollect_options} $1" + ccollect_options="${ccollect_options}$1 " ;; daily|weekly|monthly) ;; *) - ccollect_backups="${ccollect_backups}$1 " + eval backup=\"\$1\" + ddir="$(cat "${CCOLLECT_CONF}"/sources/"${backup}"/destination)"; ret="$?" + if [ "${ret}" -ne 0 ]; then + echo "Destination ${CCOLLECT_CONF}/sources/${backup}/destination is not readable... Skipping." + else + ccollect_backups="${ccollect_backups} \"$1\"" + eval export source_${no_sources}=\"\$1\" + eval export ddir_${no_sources}="${ddir}" +# eval echo Adding source \"\$source_${no_sources}\" -- \"\$ddir_${no_sources}\" + no_sources="$(( ${no_sources} + 1 ))" + fi ;; esac shift done -if [ "${ccollect_backups}" == "" ] || [ ${show_help} -eq 1 ]; then - echo +if [ "${no_sources}" -lt 1 ] || [ ${show_help} -eq 1 ]; then + echo "" echo "$0: Syntax" echo " -help This help" echo " -from From email address (ex.: -from nas@home.com)" @@ -414,58 +511,32 @@ if [ "${ccollect_backups}" == "" ] || [ ${show_help} -eq 1 ]; then echo " -report Frequency of report email (daily, weekly or monthly)" echo " Default is ${report_interval}" echo " -warning_size Send a warning email if the transfer size exceed this" - echo " Default is ${warning_transfer_size}" + echo " Default is ${warning_transfer_size} MB" + echo " -abort_size Abort and send an error email if the transfer size exceed this" + echo " Default is ${abort_transfer_size} MB" echo "" echo " other parameters are transfered to ccollect" - echo + echo "" exit 0 fi -# ------------------------------------------------------------------ -# Check if ccollect_mgr is already running for the given backup sets -# ------------------------------------------------------------------ - +#echo Backup sets:"${ccollect_backups}" check_running_backups -if [ "${ccollect_backups}" == "" ]; then +if [ "${no_sources}" -lt 1 ]; then echo "No backup sets are reachable" exit 1 fi -# ---------------------------------------------------------- -# Set the interval type -# -# Here, weeklys are Mondays, and Monthlys are the 4th Monday -# ---------------------------------------------------------- - find_interval ${weekly_backup} ${monthly_backup} echo Interval: ${interval} -# -------------- -# Do the backups -# -------------- -TEMP_LOG=${CCOLLECT_CONF}/log.$$ -echo Backup sets: ${ccollect_backups} - -# Check the transfer size (to issue email warning) precheck_transfer_size -${CCOLLECT} ${ccollect_options} ${interval} ${ccollect_backups} | tee ${TEMP_LOG} +"${CCOLLECT}" ${ccollect_options} ${interval} ${ccollect_backups} | tee "${TEMP_LOG}" -# --------------------------------------- -# Move log to the last backup of the set -# --------------------------------------- +build_backup_dir_list +move_log -move_log ${ccollect_backups} +send_report -# ----------------------------------------- -# Compute the physical amount of disk usage -# ----------------------------------------- - -compute_total_rdu ${ccollect_backups} - -# ----------------- -# Send status email -# ----------------- - -send_report ${new_log} From 72034cb0420fce291b9cc95fc1baba1050b8f9ef Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 26 Mar 2010 09:36:22 +0100 Subject: [PATCH 469/581] add hints on pre_exec error handling Signed-off-by: Nico Schottelius --- contrib/{patrick => ccollect_mgr}/README | 0 contrib/{patrick => ccollect_mgr}/S60ccollect_example | 0 contrib/{patrick => ccollect_mgr}/ccollect_mgr.sh | 0 contrib/{patrick => ccollect_mgr}/rdu | 0 doc/ccollect.text | 8 +++++++- 5 files changed, 7 insertions(+), 1 deletion(-) rename contrib/{patrick => ccollect_mgr}/README (100%) rename contrib/{patrick => ccollect_mgr}/S60ccollect_example (100%) rename contrib/{patrick => ccollect_mgr}/ccollect_mgr.sh (100%) rename contrib/{patrick => ccollect_mgr}/rdu (100%) diff --git a/contrib/patrick/README b/contrib/ccollect_mgr/README similarity index 100% rename from contrib/patrick/README rename to contrib/ccollect_mgr/README diff --git a/contrib/patrick/S60ccollect_example b/contrib/ccollect_mgr/S60ccollect_example similarity index 100% rename from contrib/patrick/S60ccollect_example rename to contrib/ccollect_mgr/S60ccollect_example diff --git a/contrib/patrick/ccollect_mgr.sh b/contrib/ccollect_mgr/ccollect_mgr.sh similarity index 100% rename from contrib/patrick/ccollect_mgr.sh rename to contrib/ccollect_mgr/ccollect_mgr.sh diff --git a/contrib/patrick/rdu b/contrib/ccollect_mgr/rdu similarity index 100% rename from contrib/patrick/rdu rename to contrib/ccollect_mgr/rdu diff --git a/doc/ccollect.text b/doc/ccollect.text index a751abf..56e575b 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -335,11 +335,14 @@ If you add '$CCOLLECT_CONF/defaults/`pre_exec`' or will start `pre_exec` before the whole backup process and `post_exec` after backup of all sources is done. +If `pre_exec` exits with a non-zero return code, the whole backup +process will be aborted. + The `pre_exec` and `post_exec` script can access the following exported variables: - 'INTERVAL': the interval selected (`daily`) - 'no_sources': number of sources to backup (`2`) -- 'source_$no': name of the source, '$no' starts at 0 +- 'source_$no': name of the source, '$no' starts at 0 (`$source_0`) The following example describes how to report free disk space in human readable format before and after the whole backup process: @@ -605,6 +608,9 @@ respectively after doing the backup for *this specific* source. If you want to have pre-/post-exec before and after *all* backups, see above for general configuration. +If `pre_exec` exits with a non-zero return code, the backup +process of `this source` will be aborted (i.e. backup skipped). + The `post_exec` script can access the following exported variables from ccollect: From 63686c3598ab7fd84b2167a59491e7f29fc8ceb7 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 26 Mar 2010 09:37:25 +0100 Subject: [PATCH 470/581] more changes for the next release Signed-off-by: Nico Schottelius --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changes/next b/doc/changes/next index 42f3007..119514f 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -7,3 +7,4 @@ * Export destination_* to source specific post_exec (Nico Schottelius) * Update documentation regarding exported variables (Nico Schottelius) * Simplify time calculation (Nico Schottelius) + * Documentate pre_exec error handling (Nico Schottelius) From fdb68e1adeeedc22ed74cd0209a59251c784b9f6 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 8 Apr 2010 22:00:45 +0200 Subject: [PATCH 471/581] add long path for documentation Signed-off-by: Nico Schottelius --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3c092f3..bd5869d 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ path_destination=${path_dir}/${CCOLLECT_DEST} # where to publish host=localhost dir=/home/users/nico/privat/rechner/netz/seiten/www.nico.schottelius.org/src/software/ccollect -docdir=${dir}/doc +docdir=${dir}/documentation # # Asciidoc will be used to generate other formats later From a8c34581ea90203d90f45e8a8c9bb261ed446af9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 9 Apr 2010 21:05:40 +0200 Subject: [PATCH 472/581] cleanup --- ccollect.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index ba91e49..172e256 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -42,7 +42,7 @@ CMARKER=".ccollect-marker" export TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" VERSION="0.8.1" -RELEASE="2009-11-XX" +RELEASE="2010-03-26" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" @@ -101,7 +101,7 @@ pcmd() # # ssh-"feature": we cannot do '... read ...; ssh ...; < file', # because ssh reads stdin! -n does not work -> does not ask for password -# Alsa allow deletion for files without the given suffix +# Also allow deletion for files without the given suffix # delete_from_file() { @@ -252,11 +252,9 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Get current source # - eval name=\"\$source_${source_no}\" + eval export name=\"\$source_${source_no}\" source_no=$((${source_no}+1)) - export name - # # Start ourself, if we want parallel execution # From 43bba003b2ef15547d6abd25f1a23166d3b9304a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 9 Apr 2010 21:06:24 +0200 Subject: [PATCH 473/581] more cleanups Signed-off-by: Nico Schottelius --- doc/ccollect.text | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 56e575b..b265459 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -646,7 +646,7 @@ Detailed description of "rsync_failure_codes" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ If you have the file `rsync_failure_codes` in your source configuration directory, it should contain a newline-separated list of numbers representing -rsync exit codes. If rsync exits with any code in this list, a marker will +rsync exit codes. If rsync exits with any code in this list, a marker will be left in the destination directory indicating failure of this backup. If you have enabled delete_incomplete, then this backup will be deleted during the next ccollect run on the same interval. @@ -656,7 +656,7 @@ Detailed description of "mtime" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ By default, ccollect.sh chooses the most recent backup directory for cloning or the oldest for deletion based on the directory's last change time (ctime). -With this option, the sorting is done based on modification time (mtime). With +With this option, the sorting is done based on modification time (mtime). With this version of ccollect, the ctime and mtime of your backups will normally be the same and this option has no effect. However, if you, for example, move your backups to another hard disk using cp -a or rsync -a, you should use this From b13ed10eafaf68bbd30c6343662d57fbb095c79d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 27 May 2010 17:11:32 +0200 Subject: [PATCH 474/581] add start script from thorsten Signed-off-by: Nico Schottelius --- .../thorsten_start_ccollect/start_ccollect | 72 +++++++++++++++++++ doc/changes/next | 1 + 2 files changed, 73 insertions(+) create mode 100644 contrib/thorsten_start_ccollect/start_ccollect diff --git a/contrib/thorsten_start_ccollect/start_ccollect b/contrib/thorsten_start_ccollect/start_ccollect new file mode 100644 index 0000000..5a774ed --- /dev/null +++ b/contrib/thorsten_start_ccollect/start_ccollect @@ -0,0 +1,72 @@ +#!/bin/bash + +# Backup-Ordner +BACKUP_DIR="/mnt" + +# ccollect_logwrapper-Skript +CCOLLECT_LOGWRAPPER="./ccollect_logwrapper.sh" + +# letzte Sicherung für Gruppe daily, weekly und monthly in Backup-Ordner ermitteln +DATE_DAILY=` ls $BACKUP_DIR | grep daily | sort -r | sed -e'2,$d' | cut -f 2 -d.` +DATE_WEEKLY=` ls $BACKUP_DIR | grep weekly | sort -r | sed -e'2,$d' | cut -f 2 -d.` +DATE_MONTHLY=`ls $BACKUP_DIR | grep monthly | sort -r | sed -e'2,$d' | cut -f 2 -d.` +DATE_YEARLY=` ls $BACKUP_DIR | grep yearly | sort -r | sed -e'2,$d' | cut -f 2 -d.` + +# Falls Leerstring diesen mit "altem Datum" füllen +if [ -z "$DATE_DAILY" ] ; then DATE_DAILY="20000101-0101" ; fi +if [ -z "$DATE_WEEKLY" ] ; then DATE_WEEKLY="20000101-0101" ; fi +if [ -z "$DATE_MONTHLY" ] ; then DATE_MONTHLY="20000101-0101" ; fi +if [ -z "$DATE_YEARLY" ] ; then DATE_YEARLY="20000101-0101" ; fi + +echo current: $DATE_CUR +echo last daily: $DATE_DAILY +echo last weekly: $DATE_WEEKLY +echo last monthly: $DATE_MONTHLY +echo last yearly: $DATE_YEARLY + +# Datum date-konform wandeln +# Achtung: mit bash - nicht mit sh möglich! +# Alternativ mit expr... konvertieren + +DATE_DAILY=${DATE_DAILY:0:4}-${DATE_DAILY:4:2}-${DATE_DAILY:6:2}" "${DATE_DAILY:9:2}:${DATE_DAILY:11:2}:00 +DATE_WEEKLY=${DATE_WEEKLY:0:4}-${DATE_WEEKLY:4:2}-${DATE_WEEKLY:6:2}" "${DATE_WEEKLY:9:2}:${DATE_WEEKLY:11:2}:00 +DATE_MONTHLY=${DATE_MONTHLY:0:4}-${DATE_MONTHLY:4:2}-${DATE_MONTHLY:6:2}" "${DATE_MONTHLY:9:2}:${DATE_MONTHLY:11:2}:00 +DATE_YEARLY=${DATE_YEARLY:0:4}-${DATE_YEARLY:4:2}-${DATE_YEARLY:6:2}" "${DATE_YEARLY:9:2}:${DATE_YEARLY:11:2}:00 +DATE_CUR=`date "+%Y-%m-%d %T"` + +# Bei Bedarf Backups durchführen + +if [ `date --date "$DATE_YEARLY" +%Y` -ne `date --date "$DATE_CUR" +%Y` ] +then + + # Jahresbackup erzeugen + echo monthly backup started + source $CCOLLECT_LOGWRAPPER -a yearly + +elif [ `date --date "$DATE_MONTHLY" +%Y%m` -ne `date --date "$DATE_CUR" +%Y%m` ] +then + + # Monatsbackup erzeugen + echo monthly backup started + source $CCOLLECT_LOGWRAPPER -a monthly + +elif [ `date --date "$DATE_WEEKLY" +%Y%W` -ne `date --date "$DATE_CUR" +%Y%W` ] +then + + # Wochenbackup erzeugen + echo weekly backup started + source $CCOLLECT_LOGWRAPPER -a weekly + +elif [ `date --date "$DATE_DAILY" +%Y%j` -ne `date --date "$DATE_CUR" +%Y%j` ] +then + + # Tagesbackup erzeugen + echo daily backup started + source $CCOLLECT_LOGWRAPPER -a daily + +else + + # nichts zu tun + echo nothing to do + +fi diff --git a/doc/changes/next b/doc/changes/next index 119514f..8226b02 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -8,3 +8,4 @@ * Update documentation regarding exported variables (Nico Schottelius) * Simplify time calculation (Nico Schottelius) * Documentate pre_exec error handling (Nico Schottelius) + * Added start script (Thorsten Elle) From ac7c703ff07753690b4406a9754ea4ffd53a2afc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 27 May 2010 17:20:11 +0200 Subject: [PATCH 475/581] add autofs hint Signed-off-by: Nico Schottelius --- doc/ccollect.text | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/doc/ccollect.text b/doc/ccollect.text index b265459..a8b83f2 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -971,6 +971,31 @@ you can enter your password (have a look at screen(1), especially "C-a M" and "C-a _", for more information). +Backup fails, if autofs is running, but sources not reachable +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +If you are trying to backup a system containing paths that are managed +by autofs, you may run into this error: + +------------------------------------------------------------------------------- +2009-12-01-23:14:15: ccollect 0.8.1: Beginning backup using interval monatlich +[ikn] 2009-12-01-23:14:15: Beginning to backup +[ikn] 2009-12-01-23:14:15: Executing /home/users/nico/ethz/ccollect/sources/ikn/pre_exec ... +Enter LUKS passphrase: +[ikn] Command successful. +[ikn] key slot 0 unlocked. +[ikn] 2009-12-01-23:14:23: Finished /home/users/nico/ethz/ccollect/sources/ikn/pre_exec (return code 0). [ikn] directory has vanished: "/home/users/nico/privat/firmen/ethz/autofs/projects" +[ikn] directory has vanished: "/home/users/nico/privat/firmen/ethz/autofs/scratch" +[ikn] directory has vanished: "/home/users/nico/privat/firmen/ethz/autofs/sgscratch" +[ikn] directory has vanished: "/home/users/nico/privat/firmen/ethz/autofs/supp" +[ikn] directory has vanished: "/home/users/nico/privat/firmen/ethz/autofs/sysadmin" +[ikn] rsync warning: some files vanished before they could be transferred (code 24) at main.c(1057) [sender=3.0.6] +[ikn] 2009-12-01-23:44:23: Source / is not readable. Skipping. +------------------------------------------------------------------------------- + +Thus, if you are unsure whether autofs paths can be mounted during backup, +stop autofs in pre_exec and reenable it in post_exec. + + Examples -------- From 64824cb3b16b33377d112186a9f8837446b7e98c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 27 May 2010 17:22:29 +0200 Subject: [PATCH 476/581] more changes Signed-off-by: Nico Schottelius --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changes/next b/doc/changes/next index 8226b02..a8f9d3c 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -9,3 +9,4 @@ * Simplify time calculation (Nico Schottelius) * Documentate pre_exec error handling (Nico Schottelius) * Added start script (Thorsten Elle) + * Documentate autofs hint (Nico Schottelius) From 9819c718b1a971f4ac55f700fd5851f072aa823b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 27 May 2010 17:37:20 +0200 Subject: [PATCH 477/581] begin rename from .sh to "" Signed-off-by: Nico Schottelius --- ccollect.sh => ccollect | 0 tools/README | 30 +++++++++---------- ...lect_add_source.sh => ccollect_add_source} | 0 ..._analyse_logs.sh => ccollect_analyse_logs} | 0 ...hive_config.sh => ccollect_archive_config} | 0 ..._check_config.sh => ccollect_check_config} | 0 ...elete_source.sh => ccollect_delete_source} | 0 ...t_intervals.sh => ccollect_list_intervals} | 0 ...lect_logwrapper.sh => ccollect_logwrapper} | 4 +-- tools/{ccollect_stats.sh => ccollect_stats} | 0 ...re-0.4-to-0.4.sh => config-pre-0.4-to-0.4} | 0 ...o-0.4.sub.sh => config-pre-0.4-to-0.4.sub} | 0 ...re-0.6-to-0.6.sh => config-pre-0.6-to-0.6} | 2 +- ...o-0.6.sub.sh => config-pre-0.6-to-0.6.sub} | 0 ...re-0.7-to-0.7.sh => config-pre-0.7-to-0.7} | 2 +- ...o-0.7.sub.sh => config-pre-0.7-to-0.7.sub} | 0 ...-compare.sh => gnu-du-backup-size-compare} | 0 tools/{report_success.sh => report_success} | 0 18 files changed, 19 insertions(+), 19 deletions(-) rename ccollect.sh => ccollect (100%) rename tools/{ccollect_add_source.sh => ccollect_add_source} (100%) rename tools/{ccollect_analyse_logs.sh => ccollect_analyse_logs} (100%) rename tools/{ccollect_archive_config.sh => ccollect_archive_config} (100%) rename tools/{ccollect_check_config.sh => ccollect_check_config} (100%) rename tools/{ccollect_delete_source.sh => ccollect_delete_source} (100%) rename tools/{ccollect_list_intervals.sh => ccollect_list_intervals} (100%) rename tools/{ccollect_logwrapper.sh => ccollect_logwrapper} (94%) rename tools/{ccollect_stats.sh => ccollect_stats} (100%) rename tools/{config-pre-0.4-to-0.4.sh => config-pre-0.4-to-0.4} (100%) rename tools/{config-pre-0.4-to-0.4.sub.sh => config-pre-0.4-to-0.4.sub} (100%) rename tools/{config-pre-0.6-to-0.6.sh => config-pre-0.6-to-0.6} (96%) rename tools/{config-pre-0.6-to-0.6.sub.sh => config-pre-0.6-to-0.6.sub} (100%) rename tools/{config-pre-0.7-to-0.7.sh => config-pre-0.7-to-0.7} (96%) rename tools/{config-pre-0.7-to-0.7.sub.sh => config-pre-0.7-to-0.7.sub} (100%) rename tools/{gnu-du-backup-size-compare.sh => gnu-du-backup-size-compare} (100%) rename tools/{report_success.sh => report_success} (100%) diff --git a/ccollect.sh b/ccollect similarity index 100% rename from ccollect.sh rename to ccollect diff --git a/tools/README b/tools/README index 7312018..cc25edb 100644 --- a/tools/README +++ b/tools/README @@ -1,19 +1,19 @@ Files and their tasks / destinations: -ccollect_add_source.sh: bin -ccollect_analyse_logs.sh: bin -ccollect_create_source2.sh: ??? -ccollect_create_source.sh: ??? -ccollect_delete_source.sh: bin -ccollect_list_intervals.sh: bin -ccollect_logwrapper.sh: bin -ccollect-stats.sh: ??? +ccollect_add_source: bin +ccollect_analyse_logs: bin +ccollect_create_source2: ??? +ccollect_create_source: ??? +ccollect_delete_source: bin +ccollect_list_intervals: bin +ccollect_logwrapper: bin +ccollect-stats: ??? config-pre-0.4-to-0.4.BUGS: only to be used for converting -config-pre-0.4-to-0.4.sh: only to be used for converting -config-pre-0.4-to-0.4.sub.sh: only to be used for converting -config-pre-0.6-to-0.6.sh: only to be used for converting -config-pre-0.6-to-0.6.sub.sh: only to be used for converting -config-pre-0.7-to-0.7.sh: only to be used for converting -config-pre-0.7-to-0.7.sub.sh: only to be used for converting -gnu-du-backup-size-compare.sh +config-pre-0.4-to-0.4: only to be used for converting +config-pre-0.4-to-0.4.sub: only to be used for converting +config-pre-0.6-to-0.6: only to be used for converting +config-pre-0.6-to-0.6.sub: only to be used for converting +config-pre-0.7-to-0.7: only to be used for converting +config-pre-0.7-to-0.7.sub: only to be used for converting +gnu-du-backup-size-compare README diff --git a/tools/ccollect_add_source.sh b/tools/ccollect_add_source similarity index 100% rename from tools/ccollect_add_source.sh rename to tools/ccollect_add_source diff --git a/tools/ccollect_analyse_logs.sh b/tools/ccollect_analyse_logs similarity index 100% rename from tools/ccollect_analyse_logs.sh rename to tools/ccollect_analyse_logs diff --git a/tools/ccollect_archive_config.sh b/tools/ccollect_archive_config similarity index 100% rename from tools/ccollect_archive_config.sh rename to tools/ccollect_archive_config diff --git a/tools/ccollect_check_config.sh b/tools/ccollect_check_config similarity index 100% rename from tools/ccollect_check_config.sh rename to tools/ccollect_check_config diff --git a/tools/ccollect_delete_source.sh b/tools/ccollect_delete_source similarity index 100% rename from tools/ccollect_delete_source.sh rename to tools/ccollect_delete_source diff --git a/tools/ccollect_list_intervals.sh b/tools/ccollect_list_intervals similarity index 100% rename from tools/ccollect_list_intervals.sh rename to tools/ccollect_list_intervals diff --git a/tools/ccollect_logwrapper.sh b/tools/ccollect_logwrapper similarity index 94% rename from tools/ccollect_logwrapper.sh rename to tools/ccollect_logwrapper index ac7f496..95e6fbb 100755 --- a/tools/ccollect_logwrapper.sh +++ b/tools/ccollect_logwrapper @@ -58,7 +58,7 @@ _echo "Starting with arguments: $@" touch "${ccollect_logfile}" || _exit_err "Failed to create ${ccollect_logfile}" # First line in the logfile is always the commandline -echo ccollect.sh "$@" > "${ccollect_logfile}" 2>&1 -ccollect.sh "$@" >> "${ccollect_logfile}" 2>&1 +echo ccollect "$@" > "${ccollect_logfile}" 2>&1 +ccollect "$@" >> "${ccollect_logfile}" 2>&1 _echo "Finished." diff --git a/tools/ccollect_stats.sh b/tools/ccollect_stats similarity index 100% rename from tools/ccollect_stats.sh rename to tools/ccollect_stats diff --git a/tools/config-pre-0.4-to-0.4.sh b/tools/config-pre-0.4-to-0.4 similarity index 100% rename from tools/config-pre-0.4-to-0.4.sh rename to tools/config-pre-0.4-to-0.4 diff --git a/tools/config-pre-0.4-to-0.4.sub.sh b/tools/config-pre-0.4-to-0.4.sub similarity index 100% rename from tools/config-pre-0.4-to-0.4.sub.sh rename to tools/config-pre-0.4-to-0.4.sub diff --git a/tools/config-pre-0.6-to-0.6.sh b/tools/config-pre-0.6-to-0.6 similarity index 96% rename from tools/config-pre-0.6-to-0.6.sh rename to tools/config-pre-0.6-to-0.6 index 58a538a..1a4bc2f 100755 --- a/tools/config-pre-0.6-to-0.6.sh +++ b/tools/config-pre-0.6-to-0.6 @@ -30,7 +30,7 @@ if [ $# -ne 1 ]; then fi dir="$1" -script=$(echo $0 | sed 's/\.sh$/.sub.sh/') +script="${0}.sub" find "${dir}/sources/" -type f -name rsync_options -exec "${script}" {} \; diff --git a/tools/config-pre-0.6-to-0.6.sub.sh b/tools/config-pre-0.6-to-0.6.sub similarity index 100% rename from tools/config-pre-0.6-to-0.6.sub.sh rename to tools/config-pre-0.6-to-0.6.sub diff --git a/tools/config-pre-0.7-to-0.7.sh b/tools/config-pre-0.7-to-0.7 similarity index 96% rename from tools/config-pre-0.7-to-0.7.sh rename to tools/config-pre-0.7-to-0.7 index 6d540ab..3098728 100755 --- a/tools/config-pre-0.7-to-0.7.sh +++ b/tools/config-pre-0.7-to-0.7 @@ -29,7 +29,7 @@ if [ $# -ne 1 ]; then fi dir="$1" -script=$(echo $0 | sed 's/\.sh$/.sub.sh/') +script="${0}.sub" find "${dir}/sources/" -name destination -exec "${script}" {} \; diff --git a/tools/config-pre-0.7-to-0.7.sub.sh b/tools/config-pre-0.7-to-0.7.sub similarity index 100% rename from tools/config-pre-0.7-to-0.7.sub.sh rename to tools/config-pre-0.7-to-0.7.sub diff --git a/tools/gnu-du-backup-size-compare.sh b/tools/gnu-du-backup-size-compare similarity index 100% rename from tools/gnu-du-backup-size-compare.sh rename to tools/gnu-du-backup-size-compare diff --git a/tools/report_success.sh b/tools/report_success similarity index 100% rename from tools/report_success.sh rename to tools/report_success From 073b1138b76a867eb7cd0337853425c4c5578031 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 12 Jan 2011 09:14:58 +0100 Subject: [PATCH 478/581] move gnu-du-backup-size-compare to old/ Signed-off-by: Nico Schottelius --- tools/{ => old}/gnu-du-backup-size-compare | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/{ => old}/gnu-du-backup-size-compare (100%) diff --git a/tools/gnu-du-backup-size-compare b/tools/old/gnu-du-backup-size-compare similarity index 100% rename from tools/gnu-du-backup-size-compare rename to tools/old/gnu-du-backup-size-compare From cbf34deade296075f83453fa27e8ac70395bc43c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 12 Jan 2011 09:15:46 +0100 Subject: [PATCH 479/581] also remove gnu-du-backup-size-compare from docs Signed-off-by: Nico Schottelius --- tools/README | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/README b/tools/README index cc25edb..bbc9706 100644 --- a/tools/README +++ b/tools/README @@ -15,5 +15,4 @@ config-pre-0.6-to-0.6: only to be used for converting config-pre-0.6-to-0.6.sub: only to be used for converting config-pre-0.7-to-0.7: only to be used for converting config-pre-0.7-to-0.7.sub: only to be used for converting -gnu-du-backup-size-compare README From 540d860e284633ee52fd25f1498883803d209b79 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 01:39:00 +0100 Subject: [PATCH 480/581] Do not use --archive on source check Signed-off-by: Nico Schottelius --- ccollect | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ccollect b/ccollect index 172e256..a7ce55b 100755 --- a/ccollect +++ b/ccollect @@ -388,9 +388,9 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # - # Rsync standard options + # Rsync standard options (archive will be added after is-up-check) # - set -- "$@" "--archive" "--delete" "--numeric-ids" "--relative" \ + set -- "$@" "--delete" "--numeric-ids" "--relative" \ "--delete-excluded" "--sparse" # @@ -437,6 +437,11 @@ while [ "${source_no}" -lt "${no_sources}" ]; do _exit_err "Source ${source} is not readable. Skipping." fi + # + # Add --archive for real backup (looks nice in front) + # + set -- "--archive" "$@" + # # Check: destination exists? # From c10b46111b83104035e83dc128bd792c9d78a9af Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 01:40:30 +0100 Subject: [PATCH 481/581] more changes Signed-off-by: Nico Schottelius --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changes/next b/doc/changes/next index a8f9d3c..a63104b 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -10,3 +10,4 @@ * Documentate pre_exec error handling (Nico Schottelius) * Added start script (Thorsten Elle) * Documentate autofs hint (Nico Schottelius) + * Speedup source-is-up check and remove --archive (Nico Schottelius) From 9cb8b99353591bc061d380331965f952efcf1200 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 01:54:55 +0100 Subject: [PATCH 482/581] simply check for incomplete backups Signed-off-by: Nico Schottelius --- ccollect | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/ccollect b/ccollect index a7ce55b..62b3a05 100755 --- a/ccollect +++ b/ccollect @@ -448,18 +448,14 @@ while [ "${source_no}" -lt "${no_sources}" ]; do ( pcmd cd "${ddir}" ) || _exit_err "Cannot change to ${ddir}. Skipping." # - # Check: incomplete backups? (needs echo to remove newlines) + # Check incomplete backups (needs echo to remove newlines) # - # *.marker: not possible, creates an error, if no *.marker exists - # -> catch return value + pcmd ls -d1 "${ddir}" | grep "${CMARKER}\$" > "${TMP}" ||\ + _exit_err "Cannot list incomplete files" - pcmd ls -d1 "${ddir}/"*"${CMARKER}" > "${TMP}" 2>/dev/null; ret=$? - - if [ "${ret}" -eq 0 ]; then - _techo "Incomplete backups: $(echo $(cat "${TMP}"))" - if [ -f "${c_delete_incomplete}" ]; then - delete_from_file "${TMP}" "${CMARKER}" - fi + _techo "Incomplete backups: $(echo $(cat "${TMP}"))" + if [ -f "${c_delete_incomplete}" ]; then + delete_from_file "${TMP}" "${CMARKER}" fi # From e39e53d0fbed1c2b1e56c539c8a661e70d164db7 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 02:04:10 +0100 Subject: [PATCH 483/581] simply check for incomplete backups Signed-off-by: Nico Schottelius --- ccollect | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ccollect b/ccollect index 62b3a05..cd8cf99 100755 --- a/ccollect +++ b/ccollect @@ -450,7 +450,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Check incomplete backups (needs echo to remove newlines) # - pcmd ls -d1 "${ddir}" | grep "${CMARKER}\$" > "${TMP}" ||\ + pcmd ls -d1 "${ddir}" | grep "${CMARKER}\$" > "${TMP}" || \ _exit_err "Cannot list incomplete files" _techo "Incomplete backups: $(echo $(cat "${TMP}"))" @@ -461,6 +461,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Check: maximum number of backups is reached? # + # FIXME: simplify, grep, cd? => no star, does not get expanded on failure count="$(pcmd ls -d1 "${ddir}/${INTERVAL}."*"/" | wc -l | sed 's/^ *//g')" \ || _exit_err "Counting backups failed" From d2cd0c48f34fa0249bc4a20deb354cf4f8c6fe8a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 02:04:31 +0100 Subject: [PATCH 484/581] begin to remove support for backing up to remote hosts Signed-off-by: Nico Schottelius --- ccollect | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ccollect b/ccollect index cd8cf99..f376ca0 100755 --- a/ccollect +++ b/ccollect @@ -88,16 +88,6 @@ add_name() awk "{ print \"[${name}] \" \$0 }" } -# -# Prepend "ssh ${remote_host}", if backing up to a remote host -# -pcmd() -{ - [ "${remote_host}" ] && set -- "ssh" "${remote_host}" "$@" - - "$@" -} - # # ssh-"feature": we cannot do '... read ...; ssh ...; < file', # because ssh reads stdin! -n does not work -> does not ask for password From 0d5b2992c0009cde8910c75512b7f8d824c67984 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 02:06:20 +0100 Subject: [PATCH 485/581] Remove first pcmd use and make cd ddir default for further actions Signed-off-by: Nico Schottelius --- ccollect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect b/ccollect index f376ca0..8673128 100755 --- a/ccollect +++ b/ccollect @@ -435,7 +435,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Check: destination exists? # - ( pcmd cd "${ddir}" ) || _exit_err "Cannot change to ${ddir}. Skipping." + cd "${ddir}" || _exit_err "Cannot change to ${ddir}. Skipping." # # Check incomplete backups (needs echo to remove newlines) From 093de8b0a16048b753191790591574df70608602 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 02:09:27 +0100 Subject: [PATCH 486/581] simplify backup count code Signed-off-by: Nico Schottelius --- ccollect | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ccollect b/ccollect index 8673128..01ef9b1 100755 --- a/ccollect +++ b/ccollect @@ -440,7 +440,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Check incomplete backups (needs echo to remove newlines) # - pcmd ls -d1 "${ddir}" | grep "${CMARKER}\$" > "${TMP}" || \ + ls -1 | grep "${CMARKER}\$" > "${TMP}" || \ _exit_err "Cannot list incomplete files" _techo "Incomplete backups: $(echo $(cat "${TMP}"))" @@ -451,8 +451,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Check: maximum number of backups is reached? # - # FIXME: simplify, grep, cd? => no star, does not get expanded on failure - count="$(pcmd ls -d1 "${ddir}/${INTERVAL}."*"/" | wc -l | sed 's/^ *//g')" \ + count="$(ls -1 | grep "^${INTERVAL}\\." | wc -l | sed 's/^ *//g')" \ || _exit_err "Counting backups failed" _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" From 5066f417a937c4c9e384f821ce2ec0951c8c78ca Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 02:11:28 +0100 Subject: [PATCH 487/581] remove pcmd from backup listing code Signed-off-by: Nico Schottelius --- ccollect | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ccollect b/ccollect index 01ef9b1..a3b14bb 100755 --- a/ccollect +++ b/ccollect @@ -461,8 +461,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do remove="$((${count} - ${substract}))" _techo "Removing ${remove} backup(s)..." - pcmd ls -${TSORT}d1r "${ddir}/${INTERVAL}."*"/" | - head -n "${remove}" > "${TMP}" || \ + ls -${TSORT}d1r | grep "${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ _exit_err "Listing old backups failed" delete_from_file "${TMP}" From a949a9e8e747b776c92aa3cd6c2f161e02f8cb54 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 02:17:00 +0100 Subject: [PATCH 488/581] remove all other pcmd calls Signed-off-by: Nico Schottelius --- ccollect | 12 ++++++------ doc/changes/next | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ccollect b/ccollect index a3b14bb..b3254e1 100755 --- a/ccollect +++ b/ccollect @@ -107,7 +107,7 @@ delete_from_file() done < "${file}" _techo "Removing $@ ..." [ "${VVERBOSE}" ] && echo rm "$@" - pcmd rm -rf "$@" || _exit_err "Removing $@ failed." + rm -rf "$@" || _exit_err "Removing $@ failed." } display_version() @@ -470,7 +470,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Check for backup directory to clone from: Always clone from the latest one! # - last_dir="$(pcmd ls -${TSORT}p1 "${ddir}" | grep '/$' | head -n 1)" || \ + last_dir="$(ls -${TSORT}p1 | grep '/$' | head -n 1)" || \ _exit_err "Failed to list contents of ${ddir}." # @@ -490,13 +490,13 @@ while [ "${source_no}" -lt "${no_sources}" ]; do _techo "Creating directory ${destination_dir} ..." [ "${VVERBOSE}" ] && echo "mkdir ${destination_dir}" - pcmd mkdir "${destination_dir}" || \ + mkdir "${destination_dir}" || \ _exit_err "Creating directory ${destination_dir} failed. Skipping." # # added marking in 0.6 (and remove it, if successful later) # - pcmd touch "${destination_dir}${CMARKER}" + touch "${destination_dir}${CMARKER}" # # the rsync part @@ -508,7 +508,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Set modification time (mtime) to current time, if sorting by mtime is enabled # - [ -f "$c_mtime" ] && pcmd touch "${destination_dir}" + [ -f "$c_mtime" ] && touch "${destination_dir}" # # Check if rsync exit code indicates failure. @@ -526,7 +526,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # Remove marking here unless rsync failed. # if [ -z "$fail" ]; then - pcmd rm "${destination_dir}${CMARKER}" || \ + rm "${destination_dir}${CMARKER}" || \ _exit_err "Removing ${destination_dir}${CMARKER} failed." if [ "${ret}" -ne 0 ]; then _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." diff --git a/doc/changes/next b/doc/changes/next index a63104b..e865dff 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -11,3 +11,4 @@ * Added start script (Thorsten Elle) * Documentate autofs hint (Nico Schottelius) * Speedup source-is-up check and remove --archive (Nico Schottelius) + * Removed support for remote backup (see doc) (Nico Schottelius) From 410cf58067d07a30fd48aedb9dc79bb297c133f3 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 02:17:48 +0100 Subject: [PATCH 489/581] update version info Signed-off-by: Nico Schottelius --- ccollect | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect b/ccollect index b3254e1..bb4c200 100755 --- a/ccollect +++ b/ccollect @@ -41,8 +41,8 @@ CPOSTEXEC="${CDEFAULTS}/post_exec" CMARKER=".ccollect-marker" export TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" -VERSION="0.8.1" -RELEASE="2010-03-26" +VERSION="0.9" +RELEASE="2011-01-XX" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" From 758e5a9059b32c408b049d791f6321ac7e39b03c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 02:20:10 +0100 Subject: [PATCH 490/581] begin to remove remote_host option Signed-off-by: Nico Schottelius --- ccollect | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/ccollect b/ccollect index bb4c200..bc8015a 100755 --- a/ccollect +++ b/ccollect @@ -303,7 +303,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # Read source configuration # for opt in verbose very_verbose summary exclude rsync_options \ - delete_incomplete remote_host rsync_failure_codes \ + delete_incomplete rsync_failure_codes \ mtime quiet_if_down ; do if [ -f "${backup}/${opt}" -o -f "${backup}/no_${opt}" ]; then eval c_$opt=\"${backup}/$opt\" @@ -358,20 +358,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do fi fi - # - # Set pre-cmd, if we backup to a remote host. - # - if [ -f "${c_remote_host}" ]; then - remote_host="$(cat "${c_remote_host}")"; ret="$?" - if [ "${ret}" -ne 0 ]; then - _exit_err "Remote host file ${c_remote_host} is unreadable. Skipping." - fi - destination="${remote_host}:${ddir}" - else - remote_host="" - destination="${ddir}" - fi - export remote_host + destination="${ddir}" # # Parameters: ccollect defaults, configuration options, user options From c7d35464aeadb7c32701a5de9e6fe52772b05a30 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 02:24:21 +0100 Subject: [PATCH 491/581] remove redundant destination variable Signed-off-by: Nico Schottelius --- ccollect | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ccollect b/ccollect index bc8015a..bb98691 100755 --- a/ccollect +++ b/ccollect @@ -358,8 +358,6 @@ while [ "${source_no}" -lt "${no_sources}" ]; do fi fi - destination="${ddir}" - # # Parameters: ccollect defaults, configuration options, user options # @@ -473,7 +471,6 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # export destination_name="${INTERVAL}.$(${CDATE}).$$-${source_no}" export destination_dir="${ddir}/${destination_name}" - export destination_full="${destination}/${destination_name}" _techo "Creating directory ${destination_dir} ..." [ "${VVERBOSE}" ] && echo "mkdir ${destination_dir}" @@ -489,7 +486,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # the rsync part # _techo "Transferring files..." - rsync "$@" "${source}" "${destination_full}"; ret=$? + rsync "$@" "${source}" "${destination_dir}"; ret=$? _techo "Finished backup (rsync return code: $ret)." # From 8c376a31f54d9db5457f42718f72d893b93c869d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 02:25:24 +0100 Subject: [PATCH 492/581] remove to-remote test source Signed-off-by: Nico Schottelius --- conf/sources/to-remote/destination | 1 - conf/sources/to-remote/exclude | 1 - conf/sources/to-remote/remote_host | 1 - conf/sources/to-remote/source | 1 - 4 files changed, 4 deletions(-) delete mode 100644 conf/sources/to-remote/destination delete mode 100644 conf/sources/to-remote/exclude delete mode 100644 conf/sources/to-remote/remote_host delete mode 100644 conf/sources/to-remote/source diff --git a/conf/sources/to-remote/destination b/conf/sources/to-remote/destination deleted file mode 100644 index 8cac69d..0000000 --- a/conf/sources/to-remote/destination +++ /dev/null @@ -1 +0,0 @@ -/tmp/ccollect diff --git a/conf/sources/to-remote/exclude b/conf/sources/to-remote/exclude deleted file mode 100644 index 6b8710a..0000000 --- a/conf/sources/to-remote/exclude +++ /dev/null @@ -1 +0,0 @@ -.git diff --git a/conf/sources/to-remote/remote_host b/conf/sources/to-remote/remote_host deleted file mode 100644 index 2fbb50c..0000000 --- a/conf/sources/to-remote/remote_host +++ /dev/null @@ -1 +0,0 @@ -localhost diff --git a/conf/sources/to-remote/source b/conf/sources/to-remote/source deleted file mode 100644 index e64611b..0000000 --- a/conf/sources/to-remote/source +++ /dev/null @@ -1 +0,0 @@ -/home/users/nico/bin From 51db5e120444606c6b3b429d009dff76ef1d9863 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 02:31:29 +0100 Subject: [PATCH 493/581] begin makefile cleanup Signed-off-by: Nico Schottelius --- Makefile | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index bd5869d..becd519 100644 --- a/Makefile +++ b/Makefile @@ -22,8 +22,8 @@ # INSTALL=install -CCOLLECT_SOURCE=ccollect.sh -CCOLLECT_DEST=ccollect.sh +CCOLLECT_SOURCE=ccollect +CCOLLECT_DEST=ccollect LN=ln -sf ASCIIDOC=asciidoc DOCBOOKTOTEXI=docbook2x-texi @@ -116,20 +116,28 @@ install-manlink: install-man # # Tools # -TOOLS=ccollect_add_source.sh \ - ccollect_analyse_logs.sh \ - ccollect_delete_source.sh \ - ccollect_list_intervals.sh \ - ccollect_logwrapper.sh \ - ccollect_list_intervals.sh +TOOLS2=ccollect_add_source +TOOLS2 += ccollect_analyse_logs -TOOLSMAN1 = $(subst ccollect,doc/man/ccollect,$(TOOLS)) -TOOLSMAN = $(subst .sh,.text,$(TOOLSMAN1)) +TOOLS=ccollect_add_source \ + ccollect_analyse_logs \ + ccollect_delete_source \ + ccollect_list_intervals \ + ccollect_logwrapper \ + ccollect_list_intervals + +# Stick to posix +TOOLSMAN1 = $(TOOLS:ccollect=doc/man/ccollect) +TOOLSMAN = $(TOOLSMAN1:=.text) TOOLSFP = $(subst ccollect,tools/ccollect,$(TOOLS)) +## FIXME: posix make: shell? => + t2: - echo $(TOOLS) - $(TOOLSMAN) - $(TOOLSFP) + echo $(TOOLS) - $(TOOLSFP) + echo $(TOOLSMAN) + echo $(TOOLSFP) # docbook gets .htm, asciidoc directly .html @@ -191,9 +199,9 @@ dist: distclean documentation /tmp/ccollect: mkdir -p /tmp/ccollect -test: ccollect.sh /tmp/ccollect - cd ./conf/sources/; for s in *; do CCOLLECT_CONF=../ ../../ccollect.sh daily "$$s"; done +test: $(CCOLLECT_SOURCE) /tmp/ccollect + cd ./conf/sources/; for s in *; do CCOLLECT_CONF=../ ../../ccollect daily "$$s"; done touch /tmp/ccollect/$$(ls /tmp/ccollect | head -n1).ccollect-marker - CCOLLECT_CONF=./conf ./ccollect.sh -a daily + CCOLLECT_CONF=./conf ./ccollect -a daily touch /tmp/ccollect/$$(ls /tmp/ccollect | head -n1).ccollect-marker - CCOLLECT_CONF=./conf ./ccollect.sh -a -p daily + CCOLLECT_CONF=./conf ./ccollect -a -p daily From 05de81e0f01ebe374ba5bd530e8c0f8b856381c1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 02:31:46 +0100 Subject: [PATCH 494/581] simplify backup counting code Signed-off-by: Nico Schottelius --- ccollect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect b/ccollect index bb98691..9d544ba 100755 --- a/ccollect +++ b/ccollect @@ -436,7 +436,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Check: maximum number of backups is reached? # - count="$(ls -1 | grep "^${INTERVAL}\\." | wc -l | sed 's/^ *//g')" \ + count="$(ls -1 | grep -c "^${INTERVAL}\\.")" \ || _exit_err "Counting backups failed" _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" From 4675bf864c99d51bb199a21e8f06a0896fccaafb Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 02:35:49 +0100 Subject: [PATCH 495/581] rewrite get incomplete backups code Signed-off-by: Nico Schottelius --- ccollect | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ccollect b/ccollect index 9d544ba..b2ff34f 100755 --- a/ccollect +++ b/ccollect @@ -425,12 +425,13 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Check incomplete backups (needs echo to remove newlines) # - ls -1 | grep "${CMARKER}\$" > "${TMP}" || \ - _exit_err "Cannot list incomplete files" + ls -1 | grep "${CMARKER}\$" > "${TMP}"; ret=$? - _techo "Incomplete backups: $(echo $(cat "${TMP}"))" - if [ -f "${c_delete_incomplete}" ]; then - delete_from_file "${TMP}" "${CMARKER}" + if [ "$ret" -eq 0 ]; then + _techo "Incomplete backups: $(echo $(cat "${TMP}"))" + if [ -f "${c_delete_incomplete}" ]; then + delete_from_file "${TMP}" "${CMARKER}" + fi fi # From aaf43af0d9712aea32de8e63f296afea8a24f8e5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 02:37:14 +0100 Subject: [PATCH 496/581] fix count of backups Signed-off-by: Nico Schottelius --- ccollect | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ccollect b/ccollect index b2ff34f..1cd295d 100755 --- a/ccollect +++ b/ccollect @@ -437,8 +437,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Check: maximum number of backups is reached? # - count="$(ls -1 | grep -c "^${INTERVAL}\\.")" \ - || _exit_err "Counting backups failed" + count="$(ls -1 | grep -c "^${INTERVAL}\\.")" _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" From 7b65687da57df2e1e1ce62988f4a10cae250489d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 02:41:22 +0100 Subject: [PATCH 497/581] simplify backup removal code Signed-off-by: Nico Schottelius --- ccollect | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ccollect b/ccollect index 1cd295d..5a254da 100755 --- a/ccollect +++ b/ccollect @@ -442,8 +442,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" if [ "${count}" -ge "${c_interval}" ]; then - substract="$((${c_interval} - 1))" - remove="$((${count} - ${substract}))" + remove="$((${count} - ${c_interval} + 1))" _techo "Removing ${remove} backup(s)..." ls -${TSORT}d1r | grep "${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ From d04972026f3a34cdf966d0d256dac5f52431dcf0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 02:44:37 +0100 Subject: [PATCH 498/581] fix selecting removal backups code Signed-off-by: Nico Schottelius --- ccollect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect b/ccollect index 5a254da..138a809 100755 --- a/ccollect +++ b/ccollect @@ -445,7 +445,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do remove="$((${count} - ${c_interval} + 1))" _techo "Removing ${remove} backup(s)..." - ls -${TSORT}d1r | grep "${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ + ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ _exit_err "Listing old backups failed" delete_from_file "${TMP}" From 9bd09f24a2d1ad4aa3272f2258f8c44330c1a7bb Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 02:47:25 +0100 Subject: [PATCH 499/581] remove directory create code: rsync does that itself Signed-off-by: Nico Schottelius --- ccollect | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ccollect b/ccollect index 138a809..82e4daf 100755 --- a/ccollect +++ b/ccollect @@ -471,11 +471,6 @@ while [ "${source_no}" -lt "${no_sources}" ]; do export destination_name="${INTERVAL}.$(${CDATE}).$$-${source_no}" export destination_dir="${ddir}/${destination_name}" - _techo "Creating directory ${destination_dir} ..." - [ "${VVERBOSE}" ] && echo "mkdir ${destination_dir}" - mkdir "${destination_dir}" || \ - _exit_err "Creating directory ${destination_dir} failed. Skipping." - # # added marking in 0.6 (and remove it, if successful later) # From dcb2b60c41d85e92b949f744122186c3ef997212 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 13:51:02 +0100 Subject: [PATCH 500/581] add temporary todo file Signed-off-by: Nico Schottelius --- TODO | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 TODO diff --git a/TODO b/TODO new file mode 100644 index 0000000..b80db08 --- /dev/null +++ b/TODO @@ -0,0 +1,20 @@ +Hinweis: + Zwei Quellen auf ein Ziel funktioniert nicht, da die beiden + Quellen von den unterschiedlichen Verzeichnissen linken. + +Listing: + .../* funktioniert nicht teilweise (abhängig von der Shell?) + +Isup-check: optional! + +line 318/check no_xxx => correct test? + +REMOVE ALL PCMD code + +Backup to remote can be done via ssh tunnel! + + +% remote host: Allow backup host to access our sshd + ssh -R4242:localhost:22 backupserver "ccollect interval backupremotehost" + + remove $destination (==ddir) From bdd6b1539739ebced7b4101ebb88d039c26c9dea Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 20:14:59 +0100 Subject: [PATCH 501/581] add version information Signed-off-by: Nico Schottelius --- ccollect | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect b/ccollect index 82e4daf..80ad20a 100755 --- a/ccollect +++ b/ccollect @@ -41,8 +41,8 @@ CPOSTEXEC="${CDEFAULTS}/post_exec" CMARKER=".ccollect-marker" export TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" -VERSION="0.9" -RELEASE="2011-01-XX" +VERSION="0.9rc1" +RELEASE="2011-01-15" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" From f7f6b4d88556b79db637a68207921de5a0068004 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Jan 2011 21:19:27 +0100 Subject: [PATCH 502/581] date++ Signed-off-by: Nico Schottelius --- ccollect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect b/ccollect index 82e4daf..c6c39c7 100755 --- a/ccollect +++ b/ccollect @@ -1,6 +1,6 @@ #!/bin/sh # -# 2005-2009 Nico Schottelius (nico-ccollect at schottelius.org) +# 2005-2011 Nico Schottelius (nico-ccollect at schottelius.org) # # This file is part of ccollect. # From ceb2f31e984c326351e2a1ceeb3e17952318606a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 17 Jan 2011 16:49:26 +0100 Subject: [PATCH 503/581] add templates for remote backup replacement Signed-off-by: Nico Schottelius --- tools/called_from_remote_pre_exec | 30 ++++++++++++++++++++++++++++++ tools/ccollect_push | 30 ++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100755 tools/called_from_remote_pre_exec create mode 100755 tools/ccollect_push diff --git a/tools/called_from_remote_pre_exec b/tools/called_from_remote_pre_exec new file mode 100755 index 0000000..f458114 --- /dev/null +++ b/tools/called_from_remote_pre_exec @@ -0,0 +1,30 @@ +#!/bin/sh +# +# 2011 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# Support backup triggering and actual backup through +# ssh tunnel +# +# Use the supplied called_from_remote script as pre…exec +# +# + +export ssh_remote_port="$1"; shift +export backup_host="$1"; shift + +ssh -R$ssh_remote_port:127.0.0.1:22 "$backup_host" "ccollect" "$@" diff --git a/tools/ccollect_push b/tools/ccollect_push new file mode 100755 index 0000000..f458114 --- /dev/null +++ b/tools/ccollect_push @@ -0,0 +1,30 @@ +#!/bin/sh +# +# 2011 Nico Schottelius (nico-ccollect at schottelius.org) +# +# This file is part of ccollect. +# +# ccollect is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ccollect is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with ccollect. If not, see . +# +# Support backup triggering and actual backup through +# ssh tunnel +# +# Use the supplied called_from_remote script as pre…exec +# +# + +export ssh_remote_port="$1"; shift +export backup_host="$1"; shift + +ssh -R$ssh_remote_port:127.0.0.1:22 "$backup_host" "ccollect" "$@" From d67b35da2cca9a9aca43a40411e52ebe7bbd588e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 2 Feb 2011 08:52:49 +0100 Subject: [PATCH 504/581] go back to sourcedir, so destination can be unmounted Signed-off-by: Nico Schottelius --- ccollect | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ccollect b/ccollect index 80ad20a..02d9e5f 100755 --- a/ccollect +++ b/ccollect @@ -472,9 +472,10 @@ while [ "${source_no}" -lt "${no_sources}" ]; do export destination_dir="${ddir}/${destination_name}" # - # added marking in 0.6 (and remove it, if successful later) + # Mark backup running and go back to original directory # touch "${destination_dir}${CMARKER}" + cd "${__abs_mydir}" || _exit_err "Cannot go back to ${__abs_mydir}." # # the rsync part From 1ee71a9dfb862ad3334dad09b1450084ee92cc4c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 2 Feb 2011 08:55:15 +0100 Subject: [PATCH 505/581] rename update to pub target for consistency Signed-off-by: Nico Schottelius --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index becd519..f2867d7 100644 --- a/Makefile +++ b/Makefile @@ -173,7 +173,7 @@ t2: # # Developer targets # -update: +pub: @git push publish-doc: documentation From a729e05132c55c8e9e45a5238e8cdc500f43469b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 2 Feb 2011 09:00:51 +0100 Subject: [PATCH 506/581] adjust version Signed-off-by: Nico Schottelius --- ccollect | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect b/ccollect index 2d557d9..9a6ebcf 100755 --- a/ccollect +++ b/ccollect @@ -41,8 +41,8 @@ CPOSTEXEC="${CDEFAULTS}/post_exec" CMARKER=".ccollect-marker" export TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" -VERSION="0.9rc1" -RELEASE="2011-01-15" +VERSION="0.9rc2" +RELEASE="2011-02-02" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" From e392792e1e5dc25b5e9ad49621b0c29e33fabc32 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 20 Aug 2011 23:31:52 +0200 Subject: [PATCH 507/581] also push to github by default Signed-off-by: Nico Schottelius --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f2867d7..f44a849 100644 --- a/Makefile +++ b/Makefile @@ -174,7 +174,8 @@ t2: # Developer targets # pub: - @git push + git push + git push github publish-doc: documentation @echo "Transferring files to ${host}" From e0d39084c6dcbc372d21c568034e4efe88e11f63 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 20 Aug 2011 23:38:38 +0200 Subject: [PATCH 508/581] begin 0.9 chapter Signed-off-by: Nico Schottelius --- doc/ccollect.text | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index a8b83f2..cacaa6d 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -0.8.1, for ccollect 0.8.1, Initial Version from 2006-01-13 +0.9, for ccollect 0.9, Initial Version from 2006-01-13 :Author Initials: NS @@ -72,8 +72,11 @@ Incompatibilities and changes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Versions 0.8 and 0.9 +^^^^^^^^^^^^^^^^^^^^ + Versions 0.7 and 0.8 -^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^ .The argument order changed: - Old: " [args] " @@ -91,7 +94,7 @@ change for you. - New: Options in $CCOLLECT_CONF/defaults are used as defaults (see below) Versions 0.6 and 0.7 -^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^ .The format of `destination` changed: - Before 0.7 it was a (link to a) directory - As of 0.7 it is a textfile containing the destination @@ -103,7 +106,7 @@ You can update your configuration using `tools/config-pre-0.7-to-0.7.sh`. Versions 0.5 and 0.6 -^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^ .The format of `rsync_options` changed: - Before 0.6 it was whitespace delimeted - As of 0.6 it is newline seperated (so you can pass whitespaces to `rsync`) @@ -120,7 +123,7 @@ XXXXX (- comes before digit). Versions 0.4 and 0.5 -^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^ Not a real incompatibilty, but seems to fit in this section: .0.5 does *NOT* require From dc67c929cfdb440b86f191b286a7e43ebb7a4748 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 20 Aug 2011 23:43:41 +0200 Subject: [PATCH 509/581] begin doc and version modifications for 0.9 Signed-off-by: Nico Schottelius --- ccollect | 4 ++-- doc/ccollect.text | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ccollect b/ccollect index 9a6ebcf..27dbf42 100755 --- a/ccollect +++ b/ccollect @@ -41,8 +41,8 @@ CPOSTEXEC="${CDEFAULTS}/post_exec" CMARKER=".ccollect-marker" export TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" -VERSION="0.9rc2" -RELEASE="2011-02-02" +VERSION="0.9" +RELEASE="2011-09-XX" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" diff --git a/doc/ccollect.text b/doc/ccollect.text index cacaa6d..851bf2f 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -74,6 +74,10 @@ Incompatibilities and changes Versions 0.8 and 0.9 ^^^^^^^^^^^^^^^^^^^^ +- Renamed script to ccollect (.sh is not needed) +- Removed feature to backup to a host via ccollect, added new tool + (FIXME: insert name here) that takes care of this via tunnel +- Perhaps creating subdirectory of source name (idea from Stefan Schlörholz) Versions 0.7 and 0.8 ^^^^^^^^^^^^^^^^^^^^ From b5eede90c6ab86325ba7ffcdc6d40d2af2dfd16e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 5 Nov 2011 22:44:08 +0100 Subject: [PATCH 510/581] ++todo Signed-off-by: Nico Schottelius --- TODO | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/TODO b/TODO index b80db08..ce63297 100644 --- a/TODO +++ b/TODO @@ -18,3 +18,9 @@ Backup to remote can be done via ssh tunnel! ssh -R4242:localhost:22 backupserver "ccollect interval backupremotehost" remove $destination (==ddir) + +-------------------------------------------------------------------------------- + +Remote backups: + +ccollect_backup_to $host $remote_port $source $interval From 10d4942912f2a875fbf2bb6a45f24a5cddf9b0ae Mon Sep 17 00:00:00 2001 From: Jiri Pinkava Date: Sat, 5 Nov 2011 15:58:26 +0100 Subject: [PATCH 511/581] target all in Makefile should be first of all targets --- Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index f44a849..908bd6c 100644 --- a/Makefile +++ b/Makefile @@ -79,13 +79,6 @@ DOCBDOCS = ${DOCS:.text=.docbook} DOC_ALL = ${HTMLDOCS} ${DBHTMLDOCS} ${TEXIDOCS} ${MANPDOCS} ${PDFDOCS} -html: ${HTMLDOCS} -htm: ${DBHTMLDOCS} -info: ${TEXIDOCS} -man: ${MANPDOCS} -pdf: ${PDFDOCS} -documentation: ${DOC_ALL} - # # End user targets # @@ -97,6 +90,13 @@ all: @echo "man: only generate manpage{s}" @echo "install: install ccollect to ${prefix}" +html: ${HTMLDOCS} +htm: ${DBHTMLDOCS} +info: ${TEXIDOCS} +man: ${MANPDOCS} +pdf: ${PDFDOCS} +documentation: ${DOC_ALL} + install: install-link install-manlink install-link: install-script From 20abe4f86b6873711d1bf9223160a62efdf2bd6a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 4 Jan 2013 10:49:53 +0100 Subject: [PATCH 512/581] add standard exclude list for debian Signed-off-by: Nico Schottelius --- contrib/exclude_lists/debian | 1 + 1 file changed, 1 insertion(+) create mode 100644 contrib/exclude_lists/debian diff --git a/contrib/exclude_lists/debian b/contrib/exclude_lists/debian new file mode 100644 index 0000000..5f43d88 --- /dev/null +++ b/contrib/exclude_lists/debian @@ -0,0 +1 @@ +/var/cache/apt/archives/* From ca45e8429b94f07b64a7f900e236cee931cd4bfe Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 28 Apr 2013 19:03:51 +0200 Subject: [PATCH 513/581] minor cleanups/year change Signed-off-by: Nico Schottelius --- ccollect | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ccollect b/ccollect index 27dbf42..f59f4c7 100755 --- a/ccollect +++ b/ccollect @@ -1,6 +1,6 @@ #!/bin/sh # -# 2005-2011 Nico Schottelius (nico-ccollect at schottelius.org) +# 2005-2013 Nico Schottelius (nico-ccollect at schottelius.org) # # This file is part of ccollect. # @@ -42,7 +42,7 @@ CMARKER=".ccollect-marker" export TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" VERSION="0.9" -RELEASE="2011-09-XX" +RELEASE="2013-09-XX" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" @@ -129,8 +129,7 @@ ${__myname}: [args] -v, --verbose: Be very verbose (uses set -x) -V, --version: Print version information - This is version ${VERSION}, released on ${RELEASE} - (the first version was written on 2005-12-05 by Nico Schottelius). + This is version ${VERSION} released on ${RELEASE}. Retrieve latest ccollect at http://www.nico.schottelius.org/software/ccollect/ eof From e2ca223432ca449647c7deb87592a50863e4543e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 29 Apr 2013 10:17:21 +0200 Subject: [PATCH 514/581] indent with 4 spaces Signed-off-by: Nico Schottelius --- ccollect | 684 +++++++++++++++++++++++++++---------------------------- 1 file changed, 342 insertions(+), 342 deletions(-) diff --git a/ccollect b/ccollect index f59f4c7..3c6d77a 100755 --- a/ccollect +++ b/ccollect @@ -72,20 +72,20 @@ trap "rm -f \"${TMP}\"" 1 2 15 # time displaying echo _techo() { - echo "$(${DDATE}): $@" + echo "$(${DDATE}): $@" } # exit on error _exit_err() { - _techo "$@" - rm -f "${TMP}" - exit 1 + _techo "$@" + rm -f "${TMP}" + exit 1 } add_name() { - awk "{ print \"[${name}] \" \$0 }" + awk "{ print \"[${name}] \" \$0 }" } # @@ -95,94 +95,94 @@ add_name() # delete_from_file() { - file="$1"; shift - suffix="" # It will be set, if deleting incomplete backups. - [ $# -eq 1 ] && suffix="$1" && shift - while read to_remove; do - set -- "$@" "${to_remove}" - if [ "${suffix}" ]; then - to_remove_no_suffix="$(echo ${to_remove} | sed "s/$suffix\$//")" - set -- "$@" "${to_remove_no_suffix}" - fi - done < "${file}" - _techo "Removing $@ ..." - [ "${VVERBOSE}" ] && echo rm "$@" - rm -rf "$@" || _exit_err "Removing $@ failed." + file="$1"; shift + suffix="" # It will be set, if deleting incomplete backups. + [ $# -eq 1 ] && suffix="$1" && shift + while read to_remove; do + set -- "$@" "${to_remove}" + if [ "${suffix}" ]; then + to_remove_no_suffix="$(echo ${to_remove} | sed "s/$suffix\$//")" + set -- "$@" "${to_remove_no_suffix}" + fi + done < "${file}" + _techo "Removing $@ ..." + [ "${VVERBOSE}" ] && echo rm "$@" + rm -rf "$@" || _exit_err "Removing $@ failed." } display_version() { - echo "${FULL_VERSION}" - exit 0 + echo "${FULL_VERSION}" + exit 0 } usage() { - cat << eof + cat << eof ${__myname}: [args] - ccollect creates (pseudo) incremental backups + ccollect creates (pseudo) incremental backups - -h, --help: Show this help screen - -a, --all: Backup all sources specified in ${CSOURCES} - -p, --parallel: Parallelise backup processes - -v, --verbose: Be very verbose (uses set -x) - -V, --version: Print version information + -h, --help: Show this help screen + -a, --all: Backup all sources specified in ${CSOURCES} + -p, --parallel: Parallelise backup processes + -v, --verbose: Be very verbose (uses set -x) + -V, --version: Print version information - This is version ${VERSION} released on ${RELEASE}. + This is version ${VERSION} released on ${RELEASE}. - Retrieve latest ccollect at http://www.nico.schottelius.org/software/ccollect/ + Retrieve latest ccollect at http://www.nico.schottelius.org/software/ccollect/ eof - exit 0 + exit 0 } # # Parse options # while [ "$#" -ge 1 ]; do - case "$1" in - -a|--all) - USE_ALL=1 - ;; - -p|--parallel) - PARALLEL=1 - ;; - -v|--verbose) - set -x - ;; - -V|--version) - display_version - ;; - --) - # ignore the -- itself - shift - break - ;; - -h|--help|-*) - usage - ;; - *) - break - ;; - esac - shift + case "$1" in + -a|--all) + USE_ALL=1 + ;; + -p|--parallel) + PARALLEL=1 + ;; + -v|--verbose) + set -x + ;; + -V|--version) + display_version + ;; + --) + # ignore the -- itself + shift + break + ;; + -h|--help|-*) + usage + ;; + *) + break + ;; + esac + shift done # # Setup interval # if [ $# -ge 1 ]; then - export INTERVAL="$1" - shift + export INTERVAL="$1" + shift else - usage + usage fi # # Check for configuraton directory # [ -d "${CCOLLECT_CONF}" ] || _exit_err "No configuration found in " \ - "\"${CCOLLECT_CONF}\" (is \$CCOLLECT_CONF properly set?)" + "\"${CCOLLECT_CONF}\" (is \$CCOLLECT_CONF properly set?)" # # Create (portable!) source "array" @@ -190,46 +190,46 @@ fi export no_sources=0 if [ "${USE_ALL}" = 1 ]; then - # - # Get sources from source configuration - # - ( cd "${CSOURCES}" && ls -1 > "${TMP}" ) || \ - _exit_err "Listing of sources failed. Aborting." + # + # Get sources from source configuration + # + ( cd "${CSOURCES}" && ls -1 > "${TMP}" ) || \ + _exit_err "Listing of sources failed. Aborting." - while read tmp; do - eval export source_${no_sources}=\"${tmp}\" - no_sources=$((${no_sources}+1)) - done < "${TMP}" + while read tmp; do + eval export source_${no_sources}=\"${tmp}\" + no_sources=$((${no_sources}+1)) + done < "${TMP}" else - # - # Get sources from command line - # - while [ "$#" -ge 1 ]; do - eval arg=\"\$1\"; shift + # + # Get sources from command line + # + while [ "$#" -ge 1 ]; do + eval arg=\"\$1\"; shift - eval export source_${no_sources}=\"${arg}\" - no_sources="$((${no_sources}+1))" - done + eval export source_${no_sources}=\"${arg}\" + no_sources="$((${no_sources}+1))" + done fi # # Need at least ONE source to backup # if [ "${no_sources}" -lt 1 ]; then - usage + usage else - _techo "${HALF_VERSION}: Beginning backup using interval ${INTERVAL}" + _techo "${HALF_VERSION}: Beginning backup using interval ${INTERVAL}" fi # # Look for pre-exec command (general) # if [ -x "${CPREEXEC}" ]; then - _techo "Executing ${CPREEXEC} ..." - "${CPREEXEC}"; ret=$? - _techo "Finished ${CPREEXEC} (return code: ${ret})." + _techo "Executing ${CPREEXEC} ..." + "${CPREEXEC}"; ret=$? + _techo "Finished ${CPREEXEC} (return code: ${ret})." - [ "${ret}" -eq 0 ] || _exit_err "${CPREEXEC} failed. Aborting" + [ "${ret}" -eq 0 ] || _exit_err "${CPREEXEC} failed. Aborting" fi ################################################################################ @@ -238,304 +238,304 @@ fi # source_no=0 while [ "${source_no}" -lt "${no_sources}" ]; do - # - # Get current source - # - eval export name=\"\$source_${source_no}\" - source_no=$((${source_no}+1)) + # + # Get current source + # + eval export name=\"\$source_${source_no}\" + source_no=$((${source_no}+1)) - # - # Start ourself, if we want parallel execution - # - if [ "${PARALLEL}" ]; then - "$0" "${INTERVAL}" "${name}" & - continue - fi + # + # Start ourself, if we want parallel execution + # + if [ "${PARALLEL}" ]; then + "$0" "${INTERVAL}" "${name}" & + continue + fi # # Start subshell for easy log editing # ( - backup="${CSOURCES}/${name}" - c_source="${backup}/source" - c_dest="${backup}/destination" - c_pre_exec="${backup}/pre_exec" - c_post_exec="${backup}/post_exec" + backup="${CSOURCES}/${name}" + c_source="${backup}/source" + c_dest="${backup}/destination" + c_pre_exec="${backup}/pre_exec" + c_post_exec="${backup}/post_exec" - # - # Stderr to stdout, so we can produce nice logs - # - exec 2>&1 + # + # Stderr to stdout, so we can produce nice logs + # + exec 2>&1 - # - # Record start of backup: internal and for the user - # - begin_s="$(${SDATE})" - _techo "Beginning to backup" + # + # Record start of backup: internal and for the user + # + begin_s="$(${SDATE})" + _techo "Beginning to backup" - # - # Standard configuration checks - # - if [ ! -e "${backup}" ]; then - _exit_err "Source does not exist." - fi + # + # Standard configuration checks + # + if [ ! -e "${backup}" ]; then + _exit_err "Source does not exist." + fi - # - # Configuration _must_ be a directory (cconfig style) - # - if [ ! -d "${backup}" ]; then - _exit_err "\"${backup}\" is not a cconfig-directory. Skipping." - fi + # + # Configuration _must_ be a directory (cconfig style) + # + if [ ! -d "${backup}" ]; then + _exit_err "\"${backup}\" is not a cconfig-directory. Skipping." + fi - # - # First execute pre_exec, which may generate destination or other parameters - # - if [ -x "${c_pre_exec}" ]; then - _techo "Executing ${c_pre_exec} ..." - "${c_pre_exec}"; ret="$?" - _techo "Finished ${c_pre_exec} (return code ${ret})." + # + # First execute pre_exec, which may generate destination or other parameters + # + if [ -x "${c_pre_exec}" ]; then + _techo "Executing ${c_pre_exec} ..." + "${c_pre_exec}"; ret="$?" + _techo "Finished ${c_pre_exec} (return code ${ret})." - [ "${ret}" -eq 0 ] || _exit_err "${c_pre_exec} failed. Skipping." - fi + [ "${ret}" -eq 0 ] || _exit_err "${c_pre_exec} failed. Skipping." + fi - # - # Read source configuration - # - for opt in verbose very_verbose summary exclude rsync_options \ - delete_incomplete rsync_failure_codes \ - mtime quiet_if_down ; do - if [ -f "${backup}/${opt}" -o -f "${backup}/no_${opt}" ]; then - eval c_$opt=\"${backup}/$opt\" - else - eval c_$opt=\"${CDEFAULTS}/$opt\" - fi - done + # + # Read source configuration + # + for opt in verbose very_verbose summary exclude rsync_options \ + delete_incomplete rsync_failure_codes \ + mtime quiet_if_down ; do + if [ -f "${backup}/${opt}" -o -f "${backup}/no_${opt}" ]; then + eval c_$opt=\"${backup}/$opt\" + else + eval c_$opt=\"${CDEFAULTS}/$opt\" + fi + done - # - # Interval definition: First try source specific, fallback to default - # - c_interval="$(cat "${backup}/intervals/${INTERVAL}" 2>/dev/null)" + # + # Interval definition: First try source specific, fallback to default + # + c_interval="$(cat "${backup}/intervals/${INTERVAL}" 2>/dev/null)" - if [ -z "${c_interval}" ]; then - c_interval="$(cat "${CDEFAULTS}/intervals/${INTERVAL}" 2>/dev/null)" + if [ -z "${c_interval}" ]; then + c_interval="$(cat "${CDEFAULTS}/intervals/${INTERVAL}" 2>/dev/null)" - if [ -z "${c_interval}" ]; then - _exit_err "No definition for interval \"${INTERVAL}\" found. Skipping." - fi - fi + if [ -z "${c_interval}" ]; then + _exit_err "No definition for interval \"${INTERVAL}\" found. Skipping." + fi + fi - # - # Sort by ctime (default) or mtime (configuration option) - # - if [ -f "${c_mtime}" ] ; then - TSORT="t" - else - TSORT="tc" - fi + # + # Sort by ctime (default) or mtime (configuration option) + # + if [ -f "${c_mtime}" ] ; then + TSORT="t" + else + TSORT="tc" + fi - # - # Source configuration checks - # - if [ ! -f "${c_source}" ]; then - _exit_err "Source description \"${c_source}\" is not a file. Skipping." - else - source=$(cat "${c_source}"); ret="$?" - if [ "${ret}" -ne 0 ]; then - _exit_err "Source ${c_source} is not readable. Skipping." - fi - fi + # + # Source configuration checks + # + if [ ! -f "${c_source}" ]; then + _exit_err "Source description \"${c_source}\" is not a file. Skipping." + else + source=$(cat "${c_source}"); ret="$?" + if [ "${ret}" -ne 0 ]; then + _exit_err "Source ${c_source} is not readable. Skipping." + fi + fi - # - # Destination is a path - # - if [ ! -f "${c_dest}" ]; then - _exit_err "Destination ${c_dest} is not a file. Skipping." - else - ddir="$(cat "${c_dest}")"; ret="$?" - if [ "${ret}" -ne 0 ]; then - _exit_err "Destination ${c_dest} is not readable. Skipping." - fi - fi + # + # Destination is a path + # + if [ ! -f "${c_dest}" ]; then + _exit_err "Destination ${c_dest} is not a file. Skipping." + else + ddir="$(cat "${c_dest}")"; ret="$?" + if [ "${ret}" -ne 0 ]; then + _exit_err "Destination ${c_dest} is not readable. Skipping." + fi + fi - # - # Parameters: ccollect defaults, configuration options, user options - # + # + # Parameters: ccollect defaults, configuration options, user options + # - # - # Rsync standard options (archive will be added after is-up-check) - # - set -- "$@" "--delete" "--numeric-ids" "--relative" \ - "--delete-excluded" "--sparse" + # + # Rsync standard options (archive will be added after is-up-check) + # + set -- "$@" "--delete" "--numeric-ids" "--relative" \ + "--delete-excluded" "--sparse" - # - # Exclude list - # - if [ -f "${c_exclude}" ]; then - set -- "$@" "--exclude-from=${c_exclude}" - fi + # + # Exclude list + # + if [ -f "${c_exclude}" ]; then + set -- "$@" "--exclude-from=${c_exclude}" + fi - # - # Output a summary - # - if [ -f "${c_summary}" ]; then - set -- "$@" "--stats" - fi + # + # Output a summary + # + if [ -f "${c_summary}" ]; then + set -- "$@" "--stats" + fi - # - # Verbosity for rsync, rm, and mkdir - # - VVERBOSE="" - if [ -f "${c_very_verbose}" ]; then - set -- "$@" "-vv" - VVERBOSE="-v" - elif [ -f "${c_verbose}" ]; then - set -- "$@" "-v" - fi + # + # Verbosity for rsync, rm, and mkdir + # + VVERBOSE="" + if [ -f "${c_very_verbose}" ]; then + set -- "$@" "-vv" + VVERBOSE="-v" + elif [ -f "${c_verbose}" ]; then + set -- "$@" "-v" + fi - # - # Extra options for rsync provided by the user - # - if [ -f "${c_rsync_options}" ]; then - while read line; do - set -- "$@" "${line}" - done < "${c_rsync_options}" - fi + # + # Extra options for rsync provided by the user + # + if [ -f "${c_rsync_options}" ]; then + while read line; do + set -- "$@" "${line}" + done < "${c_rsync_options}" + fi - # - # Check: source is up and accepting connections (before deleting old backups!) - # - if ! rsync "$@" "${source}" >/dev/null 2>"${TMP}" ; then - if [ ! -f "${c_quiet_if_down}" ]; then - cat "${TMP}" - fi - _exit_err "Source ${source} is not readable. Skipping." - fi + # + # Check: source is up and accepting connections (before deleting old backups!) + # + if ! rsync "$@" "${source}" >/dev/null 2>"${TMP}" ; then + if [ ! -f "${c_quiet_if_down}" ]; then + cat "${TMP}" + fi + _exit_err "Source ${source} is not readable. Skipping." + fi - # - # Add --archive for real backup (looks nice in front) - # - set -- "--archive" "$@" + # + # Add --archive for real backup (looks nice in front) + # + set -- "--archive" "$@" - # - # Check: destination exists? - # - cd "${ddir}" || _exit_err "Cannot change to ${ddir}. Skipping." + # + # Check: destination exists? + # + cd "${ddir}" || _exit_err "Cannot change to ${ddir}. Skipping." - # - # Check incomplete backups (needs echo to remove newlines) - # - ls -1 | grep "${CMARKER}\$" > "${TMP}"; ret=$? + # + # Check incomplete backups (needs echo to remove newlines) + # + ls -1 | grep "${CMARKER}\$" > "${TMP}"; ret=$? - if [ "$ret" -eq 0 ]; then - _techo "Incomplete backups: $(echo $(cat "${TMP}"))" - if [ -f "${c_delete_incomplete}" ]; then - delete_from_file "${TMP}" "${CMARKER}" - fi - fi + if [ "$ret" -eq 0 ]; then + _techo "Incomplete backups: $(echo $(cat "${TMP}"))" + if [ -f "${c_delete_incomplete}" ]; then + delete_from_file "${TMP}" "${CMARKER}" + fi + fi - # - # Check: maximum number of backups is reached? - # - count="$(ls -1 | grep -c "^${INTERVAL}\\.")" + # + # Check: maximum number of backups is reached? + # + count="$(ls -1 | grep -c "^${INTERVAL}\\.")" - _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" + _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" - if [ "${count}" -ge "${c_interval}" ]; then - remove="$((${count} - ${c_interval} + 1))" - _techo "Removing ${remove} backup(s)..." + if [ "${count}" -ge "${c_interval}" ]; then + remove="$((${count} - ${c_interval} + 1))" + _techo "Removing ${remove} backup(s)..." - ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ - _exit_err "Listing old backups failed" + ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ + _exit_err "Listing old backups failed" - delete_from_file "${TMP}" - fi + delete_from_file "${TMP}" + fi - # - # Check for backup directory to clone from: Always clone from the latest one! - # - last_dir="$(ls -${TSORT}p1 | grep '/$' | head -n 1)" || \ - _exit_err "Failed to list contents of ${ddir}." + # + # Check for backup directory to clone from: Always clone from the latest one! + # + last_dir="$(ls -${TSORT}p1 | grep '/$' | head -n 1)" || \ + _exit_err "Failed to list contents of ${ddir}." - # - # Clone from old backup, if existing - # - if [ "${last_dir}" ]; then - set -- "$@" "--link-dest=${ddir}/${last_dir}" - _techo "Hard linking from ${last_dir}" - fi + # + # Clone from old backup, if existing + # + if [ "${last_dir}" ]; then + set -- "$@" "--link-dest=${ddir}/${last_dir}" + _techo "Hard linking from ${last_dir}" + fi - # - # Include current time in name, not the time when we began to remove above - # - export destination_name="${INTERVAL}.$(${CDATE}).$$-${source_no}" - export destination_dir="${ddir}/${destination_name}" + # + # Include current time in name, not the time when we began to remove above + # + export destination_name="${INTERVAL}.$(${CDATE}).$$-${source_no}" + export destination_dir="${ddir}/${destination_name}" - # - # Mark backup running and go back to original directory - # - touch "${destination_dir}${CMARKER}" - cd "${__abs_mydir}" || _exit_err "Cannot go back to ${__abs_mydir}." + # + # Mark backup running and go back to original directory + # + touch "${destination_dir}${CMARKER}" + cd "${__abs_mydir}" || _exit_err "Cannot go back to ${__abs_mydir}." - # - # the rsync part - # - _techo "Transferring files..." - rsync "$@" "${source}" "${destination_dir}"; ret=$? - _techo "Finished backup (rsync return code: $ret)." + # + # the rsync part + # + _techo "Transferring files..." + rsync "$@" "${source}" "${destination_dir}"; ret=$? + _techo "Finished backup (rsync return code: $ret)." - # - # Set modification time (mtime) to current time, if sorting by mtime is enabled - # - [ -f "$c_mtime" ] && touch "${destination_dir}" + # + # Set modification time (mtime) to current time, if sorting by mtime is enabled + # + [ -f "$c_mtime" ] && touch "${destination_dir}" - # - # Check if rsync exit code indicates failure. - # - fail="" - if [ -f "$c_rsync_failure_codes" ]; then - while read code ; do - if [ "$ret" = "$code" ]; then - fail=1 - fi - done <"${c_rsync_failure_codes}" - fi + # + # Check if rsync exit code indicates failure. + # + fail="" + if [ -f "$c_rsync_failure_codes" ]; then + while read code ; do + if [ "$ret" = "$code" ]; then + fail=1 + fi + done <"${c_rsync_failure_codes}" + fi - # - # Remove marking here unless rsync failed. - # - if [ -z "$fail" ]; then - rm "${destination_dir}${CMARKER}" || \ - _exit_err "Removing ${destination_dir}${CMARKER} failed." - if [ "${ret}" -ne 0 ]; then - _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." - fi - else - _techo "Warning: rsync failed with return code $ret." - fi + # + # Remove marking here unless rsync failed. + # + if [ -z "$fail" ]; then + rm "${destination_dir}${CMARKER}" || \ + _exit_err "Removing ${destination_dir}${CMARKER} failed." + if [ "${ret}" -ne 0 ]; then + _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." + fi + else + _techo "Warning: rsync failed with return code $ret." + fi - # - # post_exec - # - if [ -x "${c_post_exec}" ]; then - _techo "Executing ${c_post_exec} ..." - "${c_post_exec}"; ret=$? - _techo "Finished ${c_post_exec}." + # + # post_exec + # + if [ -x "${c_post_exec}" ]; then + _techo "Executing ${c_post_exec} ..." + "${c_post_exec}"; ret=$? + _techo "Finished ${c_post_exec}." - if [ "${ret}" -ne 0 ]; then - _exit_err "${c_post_exec} failed." - fi - fi + if [ "${ret}" -ne 0 ]; then + _exit_err "${c_post_exec} failed." + fi + fi - # - # Time calculation - # - end_s="$(${SDATE})" - full_seconds="$((${end_s} - ${begin_s}))" - hours="$((${full_seconds} / 3600))" - minutes="$(((${full_seconds} % 3600) / 60))" - seconds="$((${full_seconds} % 60))" + # + # Time calculation + # + end_s="$(${SDATE})" + full_seconds="$((${end_s} - ${begin_s}))" + hours="$((${full_seconds} / 3600))" + minutes="$(((${full_seconds} % 3600) / 60))" + seconds="$((${full_seconds} % 60))" - _techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" + _techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" ) | add_name done @@ -543,21 +543,21 @@ done # Be a good parent and wait for our children, if they are running wild parallel # if [ "${PARALLEL}" ]; then - _techo "Waiting for children to complete..." - wait + _techo "Waiting for children to complete..." + wait fi # # Look for post-exec command (general) # if [ -x "${CPOSTEXEC}" ]; then - _techo "Executing ${CPOSTEXEC} ..." - "${CPOSTEXEC}"; ret=$? - _techo "Finished ${CPOSTEXEC} (return code: ${ret})." + _techo "Executing ${CPOSTEXEC} ..." + "${CPOSTEXEC}"; ret=$? + _techo "Finished ${CPOSTEXEC} (return code: ${ret})." - if [ "${ret}" -ne 0 ]; then - _techo "${CPOSTEXEC} failed." - fi + if [ "${ret}" -ne 0 ]; then + _techo "${CPOSTEXEC} failed." + fi fi rm -f "${TMP}" From 977c7e9c1fb4f765bf30bb2da1fc6d572bdcf123 Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Sun, 6 Sep 2015 16:35:53 +0200 Subject: [PATCH 515/581] Added "Error: " prefix in _exit_err() All stdout generated with the _exit_err() function gets a prefix: "Error: " for better usability. --- ccollect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect b/ccollect index 3c6d77a..c9496b4 100755 --- a/ccollect +++ b/ccollect @@ -78,7 +78,7 @@ _techo() # exit on error _exit_err() { - _techo "$@" + _techo "Error: $@" rm -f "${TMP}" exit 1 } From 5356370233e0883b5c6cc62b12c84ef058f8c239 Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Sat, 10 Oct 2015 19:05:39 +0200 Subject: [PATCH 516/581] Creating version 1.0 --- ccollect | 4 ++-- doc/ccollect.text | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ccollect b/ccollect index c9496b4..5454f51 100755 --- a/ccollect +++ b/ccollect @@ -41,8 +41,8 @@ CPOSTEXEC="${CDEFAULTS}/post_exec" CMARKER=".ccollect-marker" export TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" -VERSION="0.9" -RELEASE="2013-09-XX" +VERSION="1.0" +RELEASE="2015-10-10" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" diff --git a/doc/ccollect.text b/doc/ccollect.text index 851bf2f..4c54191 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -72,6 +72,10 @@ Incompatibilities and changes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Versions 0.9 and 1.0 +^^^^^^^^^^^^^^^^^^^^ +- Added "Error: " prefix in _exit_err() + Versions 0.8 and 0.9 ^^^^^^^^^^^^^^^^^^^^ - Renamed script to ccollect (.sh is not needed) From 86d562857781aa80e0323b6aae67f65cc63be61f Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 13 Jun 2016 13:40:32 +0200 Subject: [PATCH 517/581] Implement per source locking. --- ccollect | 87 +++++++++++++++++++++++++++++++++++++++++++++++- doc/changes/next | 1 + 2 files changed, 87 insertions(+), 1 deletion(-) diff --git a/ccollect b/ccollect index 5454f51..20498b2 100755 --- a/ccollect +++ b/ccollect @@ -54,6 +54,67 @@ CDATE="date +%Y%m%d-%H%M" DDATE="date +%Y-%m-%d-%H:%M:%S" SDATE="date +%s" +# +# LOCKING: use flock if available, otherwise mkdir +# Locking is done for each source so that only one instance per source +# can run. +# +LOCKDIR="${CSOURCES}" +# printf pattern: ccollect_.lock +LOCKFILE_PATTERN="ccollect_%s.lock" +LOCKFD=4 + +# +# locking functions using flock +# +lock_flock() +{ + # $1 = source to backup + lockfile="${LOCKDIR}/$(printf "${LOCKFILE_PATTERN}" "$1")" + eval "exec ${LOCKFD}> ${lockfile}" + + flock -n ${LOCKFD} && return 0 || return 1 +} + +unlock_flock() +{ + # $1 = source to backup + lockfile="${LOCKDIR}/$(printf "${LOCKFILE_PATTERN}" "$1")" + eval "exec ${LOCKFD}>&-" + rm -f "${lockfile}" +} + +# +# locking functions using mkdir (mkdir is atomic) +# +lock_mkdir() +{ + # $1 = source to backup + lockfile="${LOCKDIR}/$(printf "${LOCKFILE_PATTERN}" "$1")" + + mkdir "${lockfile}" && return 0 || return 1 +} + +unlock_mkdir() +{ + # $1 = source to backup + lockfile="${LOCKDIR}/$(printf "${LOCKFILE_PATTERN}" "$1")" + + rmdir "${lockfile}" +} + +# +# determine locking tool: flock or mkdir +# +if $(which flock > /dev/null 2>&1) +then + lockf="lock_flock" + unlockf="unlock_flock" +else + lockf="lock_mkdir" + unlockf="unlock_mkdir" +fi + # # unset values # @@ -63,7 +124,8 @@ USE_ALL="" # # catch signals # -trap "rm -f \"${TMP}\"" 1 2 15 +TRAPFUNC="rm -f \"${TMP}\"" +trap "${TRAPFUNC}" 1 2 15 # # Functions @@ -136,6 +198,18 @@ eof exit 0 } +# locking functions +lock() +{ + "${lockf}" "$@" || _exit_err \ + "Only one instance of ${__myname} for source \"$1\" can run at one time." +} + +unlock() +{ + "${unlockf}" "$@" +} + # # Parse options # @@ -287,6 +361,16 @@ while [ "${source_no}" -lt "${no_sources}" ]; do _exit_err "\"${backup}\" is not a cconfig-directory. Skipping." fi + # + # Acquire lock for source. If lock cannot be acquired, lock will exit + # with error message. + # + lock "${name}" + + # redefine trap to also unlock (rm lockfile) + TRAPFUNC="${TRAPFUNC} && unlock \"${name}\"" + trap "${TRAPFUNC}" 1 2 15 + # # First execute pre_exec, which may generate destination or other parameters # @@ -561,4 +645,5 @@ if [ -x "${CPOSTEXEC}" ]; then fi rm -f "${TMP}" +unlock "${name}" _techo "Finished" diff --git a/doc/changes/next b/doc/changes/next index e865dff..05c1a37 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -1,3 +1,4 @@ + * Add locking (Darko Poljak) * Fix source-is-up check (Nikita Koshikov) * Fix some minor command line parsing issues (Nico Schottelius) * Correct output, if configuration is not in cconfig format (Nico Schottelius) From 902a7d667ed41c2142083a0a64a6c0fe17c36d22 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 21 Jul 2016 12:15:37 +0200 Subject: [PATCH 518/581] Introduce -j option and deprecate -p option. --- ccollect | 115 +++++++++++++++++++++++++++++++++++++++--- doc/ccollect.text | 4 +- doc/changes/next | 1 + doc/man/ccollect.text | 12 +++-- 4 files changed, 118 insertions(+), 14 deletions(-) diff --git a/ccollect b/ccollect index 20498b2..de62aa6 100755 --- a/ccollect +++ b/ccollect @@ -20,6 +20,11 @@ # Initially written for SyGroup (www.sygroup.ch) # Date: Mon Nov 14 11:45:11 CET 2005 +# Simulate ccollect without actually performing any backup; +# conf directory need to be specifed. +# Usually used for debugging/testing locking and parallel execution. +SIMULATE="1" + # Error upon expanding unset variables: set -u @@ -41,6 +46,8 @@ CPOSTEXEC="${CDEFAULTS}/post_exec" CMARKER=".ccollect-marker" export TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" +CONTROL_PIPE="/tmp/${__myname}-control-pipe" + VERSION="1.0" RELEASE="2015-10-10" HALF_VERSION="ccollect ${VERSION}" @@ -59,7 +66,10 @@ SDATE="date +%s" # Locking is done for each source so that only one instance per source # can run. # -LOCKDIR="${CSOURCES}" +# Use CCOLLECT_CONF directory for lock files. +# This directory can be set arbitrary so it is writable for user +# executing ccollect. +LOCKDIR="${CCOLLECT_CONF}" # printf pattern: ccollect_.lock LOCKFILE_PATTERN="ccollect_%s.lock" LOCKFD=4 @@ -119,6 +129,7 @@ fi # unset values # PARALLEL="" +MAX_JOBS="" USE_ALL="" # @@ -185,9 +196,11 @@ ${__myname}: [args] ccollect creates (pseudo) incremental backups - -h, --help: Show this help screen - -a, --all: Backup all sources specified in ${CSOURCES} - -p, --parallel: Parallelise backup processes + -h, --help: Show this help screen + -a, --all: Backup all sources specified in ${CSOURCES} + -j [max], --jobs [max] Specifies the number of jobs to run simultaneously. + If max is not specified then parallelise all jobs. + -p, --parallel: Parallelise backup processes (deprecated from 2.0) -v, --verbose: Be very verbose (uses set -x) -V, --version: Print version information @@ -219,7 +232,24 @@ while [ "$#" -ge 1 ]; do USE_ALL=1 ;; -p|--parallel) + _techo "Warning: -p, --parallel option is deprecated," \ + "use -j, --jobs instead." PARALLEL=1 + MAX_JOBS="" + ;; + -j|--jobs) + PARALLEL=1 + if [ "$#" -ge 2 ] + then + case "$2" in + -*) + ;; + *) + MAX_JOBS=$2 + shift + ;; + esac + fi ;; -v|--verbose) set -x @@ -242,6 +272,14 @@ while [ "$#" -ge 1 ]; do shift done +# check that MAX_JOBS is natural number > 0 +# empty string means run all in parallel +echo "${MAX_JOBS}" | awk '/^$/ { exit 0 } /^[1-9][0-9]*$/ { exit 0 } { exit 1 }' +if [ "$?" -ne 0 ] +then + _exit_err "Invalid max jobs value \"${MAX_JOBS}\"" +fi + # # Setup interval # @@ -310,6 +348,26 @@ fi # # Let's do the backup - here begins the real stuff # + +# in PARALLEL mode: +# * create control pipe +# * determine number of jobs to start at once +if [ "${PARALLEL}" ]; then + mkfifo "${CONTROL_PIPE}" + # fd 5 is tied to control pipe + eval "exec 5<>${CONTROL_PIPE}" + TRAPFUNC="${TRAPFUNC}; rm -f \"${CONTROL_PIPE}\"" + trap "${TRAPFUNC}" 0 1 2 15 + + # determine how much parallel jobs to prestart + if [ "${MAX_JOBS}" ] && [ "${MAX_JOBS}" -le "${no_sources}" ] + then + prestart="${MAX_JOBS}" + else + prestart=0 + fi +fi + source_no=0 while [ "${source_no}" -lt "${no_sources}" ]; do # @@ -322,8 +380,35 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # Start ourself, if we want parallel execution # if [ "${PARALLEL}" ]; then - "$0" "${INTERVAL}" "${name}" & - continue + if [ "${SIMULATE}" ] + then + # give some time to awk's srand initialized by curr time + sleep 1 + fi + + if [ ! "${MAX_JOBS}" ] + then + # run all in parallel + "$0" "${INTERVAL}" "${name}" & + continue + elif [ "${prestart}" -gt 0 ] + then + # run prestart child if pending + { "$0" "${INTERVAL}" "${name}"; printf '\n' >&5; } & + prestart=$((${prestart} - 1)) + continue + else + # each time a child finishes we get a line from the pipe + # and then launch another child + while read line + do + { "$0" "${INTERVAL}" "${name}"; printf '\n' >&5; } & + # get out of loop so we can contnue with main loop + # for next source + break + done <&5 + continue + fi fi # @@ -366,9 +451,20 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # with error message. # lock "${name}" + if [ "${SIMULATE}" ] + then + rand_low=3 + rand_high=10 + sleep_time=$(echo '' | awk "{srand(); print int(rand()*($rand_high - $rand_low)) + $rand_low;}") + _techo "simulating backup for ${name}: ${sleep_time} secs ..." + sleep $sleep_time + unlock "${name}" + _techo "Finished backup." + break + fi # redefine trap to also unlock (rm lockfile) - TRAPFUNC="${TRAPFUNC} && unlock \"${name}\"" + TRAPFUNC="${TRAPFUNC}; unlock \"${name}\"" trap "${TRAPFUNC}" 1 2 15 # @@ -620,15 +716,19 @@ while [ "${source_no}" -lt "${no_sources}" ]; do seconds="$((${full_seconds} % 60))" _techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" + + unlock "${name}" ) | add_name done # # Be a good parent and wait for our children, if they are running wild parallel +# After all children are finished then remove control pipe. # if [ "${PARALLEL}" ]; then _techo "Waiting for children to complete..." wait + rm -f "${CONTROL_PIPE}" fi # @@ -645,5 +745,4 @@ if [ -x "${CPOSTEXEC}" ]; then fi rm -f "${TMP}" -unlock "${name}" _techo "Finished" diff --git a/doc/ccollect.text b/doc/ccollect.text index 4c54191..474c491 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1189,12 +1189,12 @@ rsync -av -H --delete /mnt/archiv/ "$DDIR/archiv/" ------------------------------------------------------------------------- -Processes running when doing ccollect -p +Processes running when doing ccollect -j ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Truncated output from `ps axuwwwf`: ------------------------------------------------------------------------- - S+ 11:40 0:00 | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily -p ddba034 ddba045 ddba046 ddba047 ddba049 ddna010 ddna011 + S+ 11:40 0:00 | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily -j ddba034 ddba045 ddba046 ddba047 ddba049 ddna010 ddna011 S+ 11:40 0:00 | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddba034 S+ 11:40 0:00 | | | | \_ /bin/sh /usr/local/bin/ccollect.sh daily ddba034 R+ 11:40 23:40 | | | | | \_ rsync -a --delete --numeric-ids --relative --delete-excluded --link-dest=/home/server/backup/ddba034 diff --git a/doc/changes/next b/doc/changes/next index 05c1a37..2fee139 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -1,3 +1,4 @@ + * Introduce -j option for max parallel jobs, deprecate -p (Darko Poljak) * Add locking (Darko Poljak) * Fix source-is-up check (Nikita Koshikov) * Fix some minor command line parsing issues (Nico Schottelius) diff --git a/doc/man/ccollect.text b/doc/man/ccollect.text index 84c1e37..9fc9086 100644 --- a/doc/man/ccollect.text +++ b/doc/man/ccollect.text @@ -26,14 +26,18 @@ texinfo or html). OPTIONS ------- +-a, --all:: + Backup all sources specified in /etc/ccollect/sources + -h, --help:: Show the help screen --p, --parallel:: - Parallelise backup processes +-j [max], --jobs [max]:: + Specifies the number of jobs to run simultaneously. + If max is not specified then parallelise all jobs. --a, --all:: - Backup all sources specified in /etc/ccollect/sources +-p, --parallel:: + Parallelise backup processes (deprecated from 2.0) -v, --verbose:: Be very verbose (uses set -x) From 1df57c815415f1f542e6ff280be8a6621955d8a3 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 21 Jul 2016 12:16:34 +0200 Subject: [PATCH 519/581] Turn simulation off. --- ccollect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect b/ccollect index de62aa6..7b5b0ca 100755 --- a/ccollect +++ b/ccollect @@ -23,7 +23,7 @@ # Simulate ccollect without actually performing any backup; # conf directory need to be specifed. # Usually used for debugging/testing locking and parallel execution. -SIMULATE="1" +SIMULATE="" # Error upon expanding unset variables: set -u From 01c36fc699f59225a9d10ab1a262d18b80039d9a Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 8 Aug 2016 15:56:19 +0200 Subject: [PATCH 520/581] Check that MAX_JOBS is positive integer or empty using grep. --- ccollect | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ccollect b/ccollect index 7b5b0ca..2929ac3 100755 --- a/ccollect +++ b/ccollect @@ -274,11 +274,13 @@ done # check that MAX_JOBS is natural number > 0 # empty string means run all in parallel -echo "${MAX_JOBS}" | awk '/^$/ { exit 0 } /^[1-9][0-9]*$/ { exit 0 } { exit 1 }' +echo "${MAX_JOBS}" | grep -q -E '^[1-9][0-9]*$|^$' if [ "$?" -ne 0 ] then _exit_err "Invalid max jobs value \"${MAX_JOBS}\"" fi +printf "REMOVE ME\n" +exit 0 # # Setup interval From a18a00e773d7e982138ab6db655158d2840ce63d Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 10 Aug 2016 17:12:18 +0200 Subject: [PATCH 521/581] Drop SIMULATE stuff. --- ccollect | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/ccollect b/ccollect index 2929ac3..80b7066 100755 --- a/ccollect +++ b/ccollect @@ -20,11 +20,6 @@ # Initially written for SyGroup (www.sygroup.ch) # Date: Mon Nov 14 11:45:11 CET 2005 -# Simulate ccollect without actually performing any backup; -# conf directory need to be specifed. -# Usually used for debugging/testing locking and parallel execution. -SIMULATE="" - # Error upon expanding unset variables: set -u @@ -382,12 +377,6 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # Start ourself, if we want parallel execution # if [ "${PARALLEL}" ]; then - if [ "${SIMULATE}" ] - then - # give some time to awk's srand initialized by curr time - sleep 1 - fi - if [ ! "${MAX_JOBS}" ] then # run all in parallel @@ -453,17 +442,6 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # with error message. # lock "${name}" - if [ "${SIMULATE}" ] - then - rand_low=3 - rand_high=10 - sleep_time=$(echo '' | awk "{srand(); print int(rand()*($rand_high - $rand_low)) + $rand_low;}") - _techo "simulating backup for ${name}: ${sleep_time} secs ..." - sleep $sleep_time - unlock "${name}" - _techo "Finished backup." - break - fi # redefine trap to also unlock (rm lockfile) TRAPFUNC="${TRAPFUNC}; unlock \"${name}\"" From 3049849ea698fed16ee78c11733b5fdb29cd27c4 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 10 Aug 2016 17:14:31 +0200 Subject: [PATCH 522/581] Remove testing stuff. --- ccollect | 2 -- 1 file changed, 2 deletions(-) diff --git a/ccollect b/ccollect index 80b7066..82bd8a7 100755 --- a/ccollect +++ b/ccollect @@ -274,8 +274,6 @@ if [ "$?" -ne 0 ] then _exit_err "Invalid max jobs value \"${MAX_JOBS}\"" fi -printf "REMOVE ME\n" -exit 0 # # Setup interval From 6dca5c638d4cbc2d42fbc5a229d7cb13385d5d0f Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 26 Sep 2016 17:27:33 +0200 Subject: [PATCH 523/581] Release 2.0. --- ccollect | 5 +++-- doc/ccollect.text | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ccollect b/ccollect index 82bd8a7..e1074b0 100755 --- a/ccollect +++ b/ccollect @@ -1,6 +1,7 @@ #!/bin/sh # # 2005-2013 Nico Schottelius (nico-ccollect at schottelius.org) +# 2016 Darko Poljak (darko.poljak at gmail.com) # # This file is part of ccollect. # @@ -43,8 +44,8 @@ CMARKER=".ccollect-marker" export TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" CONTROL_PIPE="/tmp/${__myname}-control-pipe" -VERSION="1.0" -RELEASE="2015-10-10" +VERSION="2.0" +RELEASE="2016-09-26" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" diff --git a/doc/ccollect.text b/doc/ccollect.text index 474c491..b1c7dba 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -0.9, for ccollect 0.9, Initial Version from 2006-01-13 +2.0, for ccollect 2.0, Initial Version from 2006-01-13 :Author Initials: NS From fbe17cae44a9b1236cc18c458e4ae16d6fcd8813 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 23 Feb 2017 20:04:53 +0100 Subject: [PATCH 524/581] Improve logging: stdout, file, syslog options. --- ccollect | 135 ++++++++++++++++++++++++++++++++++++------ doc/changes/2.0 | 16 +++++ doc/changes/next | 17 +----- doc/man/ccollect.text | 34 ++++++++++- 4 files changed, 166 insertions(+), 36 deletions(-) create mode 100644 doc/changes/2.0 diff --git a/ccollect b/ccollect index e1074b0..6369e84 100755 --- a/ccollect +++ b/ccollect @@ -127,6 +127,11 @@ fi PARALLEL="" MAX_JOBS="" USE_ALL="" +LOGFILE="" +SYSLOG="" +# e - only errors, a - all output +LOGLEVEL="a" +LOGONLYERRORS="" # # catch signals @@ -138,18 +143,11 @@ trap "${TRAPFUNC}" 1 2 15 # Functions # -# time displaying echo -_techo() +# check if we are running interactive or non-interactive +# see: http://www.tldp.org/LDP/abs/html/intandnonint.html +_is_interactive() { - echo "$(${DDATE}): $@" -} - -# exit on error -_exit_err() -{ - _techo "Error: $@" - rm -f "${TMP}" - exit 1 + [ -t 0 -o -p /dev/stdin ] } add_name() @@ -192,13 +190,16 @@ ${__myname}: [args] ccollect creates (pseudo) incremental backups - -h, --help: Show this help screen - -a, --all: Backup all sources specified in ${CSOURCES} - -j [max], --jobs [max] Specifies the number of jobs to run simultaneously. - If max is not specified then parallelise all jobs. - -p, --parallel: Parallelise backup processes (deprecated from 2.0) - -v, --verbose: Be very verbose (uses set -x) - -V, --version: Print version information + -h, --help: Show this help screen + -a, --all: Backup all sources specified in ${CSOURCES} + -e, --errors: Log only errors + -j [max], --jobs [max] Specifies the number of jobs to run simultaneously. + If max is not specified then parallelise all jobs. + -l FILE, --logfile FILE Log to specified file + -p, --parallel: Parallelise backup processes (deprecated from 2.0) + -s, --syslog: Log to syslog with tag ccollect + -v, --verbose: Be very verbose (uses set -x) + -V, --version: Print version information This is version ${VERSION} released on ${RELEASE}. @@ -219,6 +220,54 @@ unlock() "${unlockf}" "$@" } +# time displaying echo +# stdout version +_techo_stdout() +{ + echo "$(${DDATE}): $@" +} + +# syslog version +_techo_syslog() +{ + logger -t ccollect "$@" +} + +# specified file version +_techo_file() +{ + _techo_stdout "$@" >> "${LOGFILE}" +} + +# determine _techo version before parsing options +if _is_interactive +then + _techof="_techo_stdout" +else + _techof="_techo_syslog" +fi + +# _techo with determined _techo version +_techo() +{ + if [ "${LOGLEVEL}" = "a" ] + then + "${_techof}" "$@" + fi +} + +_techo_err() +{ + _techo "Error: $@" +} + +_exit_err() +{ + _techo_err "$@" + rm -f "${TMP}" + exit 1 +} + # # Parse options # @@ -247,6 +296,28 @@ while [ "$#" -ge 1 ]; do esac fi ;; + -e|--errors) + LOGONLYERRORS="1" + ;; + -l|--logfile) + if [ "$#" -ge 2 ] + then + case "$2" in + -*) + _exit_err "Missing log file" + ;; + *) + LOGFILE="$2" + shift + ;; + esac + else + _exit_err "Missing log file" + fi + ;; + -s|--syslog) + SYSLOG="1" + ;; -v|--verbose) set -x ;; @@ -268,6 +339,34 @@ while [ "$#" -ge 1 ]; do shift done +# determine _techo version and logging level after parsing options +if [ "${LOGFILE}" ] +then + _techof="_techo_file" + LOGLEVEL="a" +elif _is_interactive +then + if [ "${SYSLOG}" ] + then + _techof="_techo_syslog" + LOGLEVEL="a" + else + _techof="_techo_stdout" + LOGLEVEL="e" + fi +else + _techof="_techo_syslog" + LOGLEVEL="a" +fi + +if [ "${LOGFILE}" -o "${SYSLOG}" ] +then + if [ "${LOGONLYERRORS}" ] + then + LOGLEVEL="e" + fi +fi + # check that MAX_JOBS is natural number > 0 # empty string means run all in parallel echo "${MAX_JOBS}" | grep -q -E '^[1-9][0-9]*$|^$' diff --git a/doc/changes/2.0 b/doc/changes/2.0 new file mode 100644 index 0000000..2fee139 --- /dev/null +++ b/doc/changes/2.0 @@ -0,0 +1,16 @@ + * Introduce -j option for max parallel jobs, deprecate -p (Darko Poljak) + * Add locking (Darko Poljak) + * Fix source-is-up check (Nikita Koshikov) + * Fix some minor command line parsing issues (Nico Schottelius) + * Correct output, if configuration is not in cconfig format (Nico Schottelius) + * Minor code cleanups and optimisations (Nico Schottelius) + * ccollect_analyse_logs.sh traps more errors and warnings (Patrick Drolet) + * Remove -v for mkdir and rm, as they are not POSIX (Patrick Drolet) + * Export destination_* to source specific post_exec (Nico Schottelius) + * Update documentation regarding exported variables (Nico Schottelius) + * Simplify time calculation (Nico Schottelius) + * Documentate pre_exec error handling (Nico Schottelius) + * Added start script (Thorsten Elle) + * Documentate autofs hint (Nico Schottelius) + * Speedup source-is-up check and remove --archive (Nico Schottelius) + * Removed support for remote backup (see doc) (Nico Schottelius) diff --git a/doc/changes/next b/doc/changes/next index 2fee139..ec42d4b 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -1,16 +1 @@ - * Introduce -j option for max parallel jobs, deprecate -p (Darko Poljak) - * Add locking (Darko Poljak) - * Fix source-is-up check (Nikita Koshikov) - * Fix some minor command line parsing issues (Nico Schottelius) - * Correct output, if configuration is not in cconfig format (Nico Schottelius) - * Minor code cleanups and optimisations (Nico Schottelius) - * ccollect_analyse_logs.sh traps more errors and warnings (Patrick Drolet) - * Remove -v for mkdir and rm, as they are not POSIX (Patrick Drolet) - * Export destination_* to source specific post_exec (Nico Schottelius) - * Update documentation regarding exported variables (Nico Schottelius) - * Simplify time calculation (Nico Schottelius) - * Documentate pre_exec error handling (Nico Schottelius) - * Added start script (Thorsten Elle) - * Documentate autofs hint (Nico Schottelius) - * Speedup source-is-up check and remove --archive (Nico Schottelius) - * Removed support for remote backup (see doc) (Nico Schottelius) +* Add options for stdout, file and syslog logging (Darko Poljak) diff --git a/doc/man/ccollect.text b/doc/man/ccollect.text index 9fc9086..67f8f47 100644 --- a/doc/man/ccollect.text +++ b/doc/man/ccollect.text @@ -29,6 +29,9 @@ OPTIONS -a, --all:: Backup all sources specified in /etc/ccollect/sources +-e, --errors:: + Log only errors + -h, --help:: Show the help screen @@ -36,14 +39,41 @@ OPTIONS Specifies the number of jobs to run simultaneously. If max is not specified then parallelise all jobs. +-l FILE, --logfile FILE:: + Log to specified file + -p, --parallel:: Parallelise backup processes (deprecated from 2.0) +-s, --syslog:: + Log to syslog with tag ccollect + +-V, --version:: + Show version and exit + -v, --verbose:: Be very verbose (uses set -x) --V, --version:: - Show version and exit + +LOGGING MECHANISM +----------------- +ccollect logging depends on running in non-interactive/interactive mode +and on specified optins. The mechanism behaves as the following: + +non-interactive mode:: + + * standard output goes to syslog + * optional: specify logging into file + * log all output by default + * optional: log only errors + +interactive mode:: + + * standard output goes to stdout + * log only errors + * optional: log into syslog or file + - log all output by default + - optional: log only errors SEE ALSO From 89a82ba55ea72d988eae424c6c711143902b44cc Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 22 Mar 2017 10:24:18 +0100 Subject: [PATCH 525/581] Release 2.1 --- ccollect | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect b/ccollect index 6369e84..47526ad 100755 --- a/ccollect +++ b/ccollect @@ -44,8 +44,8 @@ CMARKER=".ccollect-marker" export TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" CONTROL_PIPE="/tmp/${__myname}-control-pipe" -VERSION="2.0" -RELEASE="2016-09-26" +VERSION="2.1" +RELEASE="2017-03-22" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" From 07c925de5d174b59fd64a9a15f26a0db2caeedf2 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 22 Mar 2017 10:46:57 +0100 Subject: [PATCH 526/581] Release 2.1 --- doc/ccollect.text | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index b1c7dba..74fcab6 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -2.0, for ccollect 2.0, Initial Version from 2006-01-13 +2.1, for ccollect 2.1, Initial Version from 2006-01-13 :Author Initials: NS From 04bf9aff3987c8f2543ff887cbb9f4bc6737e871 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 3 Sep 2017 20:00:54 +0200 Subject: [PATCH 527/581] Bugfix: empty rsync_options line causes destroying source. (#8) Bugfix: empty rsync_options line causes destroying source. --- ccollect | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ccollect b/ccollect index 47526ad..edae187 100755 --- a/ccollect +++ b/ccollect @@ -655,7 +655,17 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # if [ -f "${c_rsync_options}" ]; then while read line; do - set -- "$@" "${line}" + # Trim line. + ln=$(echo "${line}" | awk '{$1=$1;print;}') + # Only if ln is non zero length string. + # + # If ln is empty then rsync '' DEST evaluates + # to transfer current directory to DEST which would + # with specific options destroy DEST content. + if [ -n "${ln}" ] + then + set -- "$@" "${ln}" + fi done < "${c_rsync_options}" fi From b0f131771387cf8eb46d44eb108c891527f5ee68 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 3 Sep 2017 20:02:42 +0200 Subject: [PATCH 528/581] changelog++ --- doc/changes/2.1 | 1 + doc/changes/next | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 doc/changes/2.1 diff --git a/doc/changes/2.1 b/doc/changes/2.1 new file mode 100644 index 0000000..ec42d4b --- /dev/null +++ b/doc/changes/2.1 @@ -0,0 +1 @@ +* Add options for stdout, file and syslog logging (Darko Poljak) diff --git a/doc/changes/next b/doc/changes/next index ec42d4b..0ee09d6 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -1 +1 @@ -* Add options for stdout, file and syslog logging (Darko Poljak) +* Bugfix: empty rsync_options line causes destroying source (Darko Poljak) From e504d1f42b4e4ce73e47e7cdb4d1ae24842e6f85 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 3 Sep 2017 22:29:13 +0200 Subject: [PATCH 529/581] Release 2.2 --- ccollect | 4 ++-- doc/changes/2.2 | 1 + doc/changes/next | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 doc/changes/2.2 diff --git a/ccollect b/ccollect index edae187..35af419 100755 --- a/ccollect +++ b/ccollect @@ -44,8 +44,8 @@ CMARKER=".ccollect-marker" export TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" CONTROL_PIPE="/tmp/${__myname}-control-pipe" -VERSION="2.1" -RELEASE="2017-03-22" +VERSION="2.2" +RELEASE="2017-09-03" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" diff --git a/doc/changes/2.2 b/doc/changes/2.2 new file mode 100644 index 0000000..0ee09d6 --- /dev/null +++ b/doc/changes/2.2 @@ -0,0 +1 @@ +* Bugfix: empty rsync_options line causes destroying source (Darko Poljak) diff --git a/doc/changes/next b/doc/changes/next index 0ee09d6..a767caf 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -1 +1 @@ -* Bugfix: empty rsync_options line causes destroying source (Darko Poljak) +* From 890b166a43c0824d66dfdefd0a38e4643401ec13 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 3 Sep 2017 23:11:13 +0200 Subject: [PATCH 530/581] Release 2.2 --- doc/ccollect.text | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ccollect.text b/doc/ccollect.text index 74fcab6..b97409f 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -2.1, for ccollect 2.1, Initial Version from 2006-01-13 +2.2, for ccollect 2.2, Initial Version from 2006-01-13 :Author Initials: NS From bd0fe050038e3137d2ede6db5126a7fb92cdc64a Mon Sep 17 00:00:00 2001 From: Jun Futagawa Date: Tue, 19 Dec 2017 17:42:49 +0900 Subject: [PATCH 531/581] Update rpm spec file to version 2.2 (#9) --- contrib/ccollect.spec | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/contrib/ccollect.spec b/contrib/ccollect.spec index 0e35bb0..91bb83b 100644 --- a/contrib/ccollect.spec +++ b/contrib/ccollect.spec @@ -1,6 +1,6 @@ Summary: (pseudo) incremental backup with different exclude lists using hardlinks and rsync Name: ccollect -Version: 0.8.1 +Version: 2.2 Release: 0 URL: http://www.nico.schottelius.org/software/ccollect Source0: http://www.nico.schottelius.org/software/ccollect/%{name}-%{version}.tar.bz2 @@ -23,10 +23,10 @@ Only the inodes used by the hardlinks and the changed files need additional spac %install rm -rf $RPM_BUILD_ROOT -#Installing main ccollect.sh and /etc directory +#Installing main ccollect and /etc directory %__install -d 755 %buildroot%_bindir %__install -d 755 %buildroot%_sysconfdir/%name -%__install -m 755 ccollect.sh %buildroot%_bindir/ +%__install -m 755 ccollect %buildroot%_bindir/ #bin files from tools directory for t in $(ls tools/ccollect_*) ; do @@ -45,19 +45,13 @@ done #Addition documentation and some config tools %__install -d 755 %buildroot%_datadir/%name/tools +%__install -m 755 tools/called_from_remote_pre_exec %buildroot%_datadir/%name/tools %__cp -pr tools/config-pre-* %buildroot%_datadir/%name/tools -%__install -m 755 tools/gnu-du-backup-size-compare.sh %buildroot%_datadir/%name/tools -%__install -m 755 tools/report_success.sh %buildroot%_datadir/%name/tools +%__install -m 755 tools/report_success %buildroot%_datadir/%name/tools %clean rm -rf $RPM_BUILD_ROOT -%post -%__ln_s %_bindir/ccollect.sh %_bindir/ccollect - -%preun -unlink %_bindir/ccollect - %files %defattr(-,root,root) %_bindir/ccollect* From fc0b86005c6231eac06204351e9601393aff2e7a Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 30 Jan 2018 09:48:43 +0100 Subject: [PATCH 532/581] Fix parallel mode deadlock when MAX_JOBS > number of sources. --- ccollect | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ccollect b/ccollect index 35af419..6b48606 100755 --- a/ccollect +++ b/ccollect @@ -455,9 +455,14 @@ if [ "${PARALLEL}" ]; then trap "${TRAPFUNC}" 0 1 2 15 # determine how much parallel jobs to prestart - if [ "${MAX_JOBS}" ] && [ "${MAX_JOBS}" -le "${no_sources}" ] + if [ "${MAX_JOBS}" ] then - prestart="${MAX_JOBS}" + if [ "${MAX_JOBS}" -le "${no_sources}" ] + then + prestart="${MAX_JOBS}" + else + prestart="${no_sources}" + fi else prestart=0 fi From eeccc0b26019f3d9d5f4a93e97522f5190b1827f Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 2 Feb 2018 07:57:41 +0100 Subject: [PATCH 533/581] Release 2.3 --- ccollect | 4 ++-- contrib/ccollect.spec | 2 +- doc/ccollect.text | 2 +- doc/changes/2.3 | 1 + doc/changes/next | 1 - 5 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 doc/changes/2.3 diff --git a/ccollect b/ccollect index 6b48606..70a998e 100755 --- a/ccollect +++ b/ccollect @@ -44,8 +44,8 @@ CMARKER=".ccollect-marker" export TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" CONTROL_PIPE="/tmp/${__myname}-control-pipe" -VERSION="2.2" -RELEASE="2017-09-03" +VERSION="2.3" +RELEASE="2018-02-02" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" diff --git a/contrib/ccollect.spec b/contrib/ccollect.spec index 91bb83b..8916b7e 100644 --- a/contrib/ccollect.spec +++ b/contrib/ccollect.spec @@ -1,6 +1,6 @@ Summary: (pseudo) incremental backup with different exclude lists using hardlinks and rsync Name: ccollect -Version: 2.2 +Version: 2.3 Release: 0 URL: http://www.nico.schottelius.org/software/ccollect Source0: http://www.nico.schottelius.org/software/ccollect/%{name}-%{version}.tar.bz2 diff --git a/doc/ccollect.text b/doc/ccollect.text index b97409f..b267cdb 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -2.2, for ccollect 2.2, Initial Version from 2006-01-13 +2.3, for ccollect 2.3, Initial Version from 2006-01-13 :Author Initials: NS diff --git a/doc/changes/2.3 b/doc/changes/2.3 new file mode 100644 index 0000000..960110c --- /dev/null +++ b/doc/changes/2.3 @@ -0,0 +1 @@ +* Bugfix: Fix parallel mode deadlock when max jobs > number of sources (Darko Poljak) diff --git a/doc/changes/next b/doc/changes/next index a767caf..e69de29 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -1 +0,0 @@ -* From 51f468182f5e68147c7c0bbbfb8611750b8cc90c Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 20 Apr 2018 17:27:56 +0200 Subject: [PATCH 534/581] Document Windows(Cygwin) as supported OS. --- doc/ccollect.text | 1 + doc/changes/next | 1 + 2 files changed, 2 insertions(+) diff --git a/doc/ccollect.text b/doc/ccollect.text index b267cdb..5585a97 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -26,6 +26,7 @@ Supported and tested operating systems and architectures - Mac OS X 10.5 - NetBSD on alpha/amd64/i386/sparc/sparc64 - OpenBSD on amd64 +- Windows by installing Cygwin, OpenSSH and rsync It *should* run on any Unix that supports `rsync` and has a POSIX-compatible bourne shell. If your platform is not listed above and you have it successfully diff --git a/doc/changes/next b/doc/changes/next index e69de29..784eac6 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -0,0 +1 @@ +* Add Windows(Cygwin) as supported OS From 420dc3fe7fcf5bfb879e70675cb4d412b969f337 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 20 Sep 2018 16:08:00 +0200 Subject: [PATCH 535/581] Add source name tag in log line --- ccollect | 53 ++++++++++++++++++++++++------------------------ doc/changes/next | 1 + 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/ccollect b/ccollect index 70a998e..04454a1 100755 --- a/ccollect +++ b/ccollect @@ -514,6 +514,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do c_dest="${backup}/destination" c_pre_exec="${backup}/pre_exec" c_post_exec="${backup}/post_exec" + tag="[${name}]" # # Stderr to stdout, so we can produce nice logs @@ -524,13 +525,13 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # Record start of backup: internal and for the user # begin_s="$(${SDATE})" - _techo "Beginning to backup" + _techo "${tag}" "Beginning to backup" # # Standard configuration checks # if [ ! -e "${backup}" ]; then - _exit_err "Source does not exist." + _exit_err "Source \"${backup}\" does not exist." fi # @@ -554,11 +555,11 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # First execute pre_exec, which may generate destination or other parameters # if [ -x "${c_pre_exec}" ]; then - _techo "Executing ${c_pre_exec} ..." + _techo "${tag}" "Executing ${c_pre_exec} ..." "${c_pre_exec}"; ret="$?" - _techo "Finished ${c_pre_exec} (return code ${ret})." + _techo "${tag}" "Finished ${c_pre_exec} (return code ${ret})." - [ "${ret}" -eq 0 ] || _exit_err "${c_pre_exec} failed. Skipping." + [ "${ret}" -eq 0 ] || _exit_err "${tag}" "${c_pre_exec} failed. Skipping." fi # @@ -583,7 +584,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do c_interval="$(cat "${CDEFAULTS}/intervals/${INTERVAL}" 2>/dev/null)" if [ -z "${c_interval}" ]; then - _exit_err "No definition for interval \"${INTERVAL}\" found. Skipping." + _exit_err "${tag}" "No definition for interval \"${INTERVAL}\" found. Skipping." fi fi @@ -612,11 +613,11 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # Destination is a path # if [ ! -f "${c_dest}" ]; then - _exit_err "Destination ${c_dest} is not a file. Skipping." + _exit_err "${tag}" "Destination ${c_dest} is not a file. Skipping." else ddir="$(cat "${c_dest}")"; ret="$?" if [ "${ret}" -ne 0 ]; then - _exit_err "Destination ${c_dest} is not readable. Skipping." + _exit_err "${tag}" "Destination ${c_dest} is not readable. Skipping." fi fi @@ -681,7 +682,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do if [ ! -f "${c_quiet_if_down}" ]; then cat "${TMP}" fi - _exit_err "Source ${source} is not readable. Skipping." + _exit_err "${tag}" "Source ${source} is not readable. Skipping." fi # @@ -692,7 +693,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Check: destination exists? # - cd "${ddir}" || _exit_err "Cannot change to ${ddir}. Skipping." + cd "${ddir}" || _exit_err "${tag}" "Cannot change to ${ddir}. Skipping." # # Check incomplete backups (needs echo to remove newlines) @@ -700,7 +701,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do ls -1 | grep "${CMARKER}\$" > "${TMP}"; ret=$? if [ "$ret" -eq 0 ]; then - _techo "Incomplete backups: $(echo $(cat "${TMP}"))" + _techo "${tag}" "Incomplete backups: $(echo $(cat "${TMP}"))" if [ -f "${c_delete_incomplete}" ]; then delete_from_file "${TMP}" "${CMARKER}" fi @@ -711,14 +712,14 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # count="$(ls -1 | grep -c "^${INTERVAL}\\.")" - _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" + _techo "${tag}" "Existing backups: ${count} Total keeping backups: ${c_interval}" if [ "${count}" -ge "${c_interval}" ]; then remove="$((${count} - ${c_interval} + 1))" - _techo "Removing ${remove} backup(s)..." + _techo "${tag}" "Removing ${remove} backup(s)..." ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ - _exit_err "Listing old backups failed" + _exit_err "${tag}" "Listing old backups failed" delete_from_file "${TMP}" fi @@ -727,14 +728,14 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # Check for backup directory to clone from: Always clone from the latest one! # last_dir="$(ls -${TSORT}p1 | grep '/$' | head -n 1)" || \ - _exit_err "Failed to list contents of ${ddir}." + _exit_err "${tag}" "Failed to list contents of ${ddir}." # # Clone from old backup, if existing # if [ "${last_dir}" ]; then set -- "$@" "--link-dest=${ddir}/${last_dir}" - _techo "Hard linking from ${last_dir}" + _techo "${tag}" "Hard linking from ${last_dir}" fi # @@ -747,14 +748,14 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # Mark backup running and go back to original directory # touch "${destination_dir}${CMARKER}" - cd "${__abs_mydir}" || _exit_err "Cannot go back to ${__abs_mydir}." + cd "${__abs_mydir}" || _exit_err "${tag}" "Cannot go back to ${__abs_mydir}." # # the rsync part # - _techo "Transferring files..." + _techo "${tag}" "Transferring files..." rsync "$@" "${source}" "${destination_dir}"; ret=$? - _techo "Finished backup (rsync return code: $ret)." + _techo "${tag}" "Finished backup (rsync return code: $ret)." # # Set modification time (mtime) to current time, if sorting by mtime is enabled @@ -778,24 +779,24 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # if [ -z "$fail" ]; then rm "${destination_dir}${CMARKER}" || \ - _exit_err "Removing ${destination_dir}${CMARKER} failed." + _exit_err "${tag}" "Removing ${destination_dir}${CMARKER} failed." if [ "${ret}" -ne 0 ]; then - _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." + _techo "${tag}" "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." fi else - _techo "Warning: rsync failed with return code $ret." + _techo "${tag}" "Warning: rsync failed with return code $ret." fi # # post_exec # if [ -x "${c_post_exec}" ]; then - _techo "Executing ${c_post_exec} ..." + _techo "${tag}" "Executing ${c_post_exec} ..." "${c_post_exec}"; ret=$? - _techo "Finished ${c_post_exec}." + _techo "${tag}" "Finished ${c_post_exec}." if [ "${ret}" -ne 0 ]; then - _exit_err "${c_post_exec} failed." + _exit_err "${tag}" "${c_post_exec} failed." fi fi @@ -808,7 +809,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do minutes="$(((${full_seconds} % 3600) / 60))" seconds="$((${full_seconds} % 60))" - _techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" + _techo "${tag}" "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" unlock "${name}" ) | add_name diff --git a/doc/changes/next b/doc/changes/next index 784eac6..07ffe9d 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -1 +1,2 @@ * Add Windows(Cygwin) as supported OS +* Add source name tag in log line From b47a828af0e5e6b3b230aa7338054799767dde2a Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 20 Sep 2018 16:08:00 +0200 Subject: [PATCH 536/581] Add source name tag in log line --- ccollect | 66 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/ccollect b/ccollect index 04454a1..b565355 100755 --- a/ccollect +++ b/ccollect @@ -150,11 +150,6 @@ _is_interactive() [ -t 0 -o -p /dev/stdin ] } -add_name() -{ - awk "{ print \"[${name}] \" \$0 }" -} - # # ssh-"feature": we cannot do '... read ...; ssh ...; < file', # because ssh reads stdin! -n does not work -> does not ask for password @@ -252,7 +247,13 @@ _techo() { if [ "${LOGLEVEL}" = "a" ] then - "${_techof}" "$@" + tag="${name:-}" + if [ "${tag}" ]; then + tag="[${tag}]" + else + tag="" + fi + "${_techof}" ${tag} "$@" fi } @@ -514,7 +515,6 @@ while [ "${source_no}" -lt "${no_sources}" ]; do c_dest="${backup}/destination" c_pre_exec="${backup}/pre_exec" c_post_exec="${backup}/post_exec" - tag="[${name}]" # # Stderr to stdout, so we can produce nice logs @@ -525,7 +525,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # Record start of backup: internal and for the user # begin_s="$(${SDATE})" - _techo "${tag}" "Beginning to backup" + _techo "Beginning to backup" # # Standard configuration checks @@ -555,11 +555,11 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # First execute pre_exec, which may generate destination or other parameters # if [ -x "${c_pre_exec}" ]; then - _techo "${tag}" "Executing ${c_pre_exec} ..." + _techo "Executing ${c_pre_exec} ..." "${c_pre_exec}"; ret="$?" - _techo "${tag}" "Finished ${c_pre_exec} (return code ${ret})." + _techo "Finished ${c_pre_exec} (return code ${ret})." - [ "${ret}" -eq 0 ] || _exit_err "${tag}" "${c_pre_exec} failed. Skipping." + [ "${ret}" -eq 0 ] || _exit_err "${c_pre_exec} failed. Skipping." fi # @@ -584,7 +584,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do c_interval="$(cat "${CDEFAULTS}/intervals/${INTERVAL}" 2>/dev/null)" if [ -z "${c_interval}" ]; then - _exit_err "${tag}" "No definition for interval \"${INTERVAL}\" found. Skipping." + _exit_err "No definition for interval \"${INTERVAL}\" found. Skipping." fi fi @@ -613,11 +613,11 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # Destination is a path # if [ ! -f "${c_dest}" ]; then - _exit_err "${tag}" "Destination ${c_dest} is not a file. Skipping." + _exit_err "Destination ${c_dest} is not a file. Skipping." else ddir="$(cat "${c_dest}")"; ret="$?" if [ "${ret}" -ne 0 ]; then - _exit_err "${tag}" "Destination ${c_dest} is not readable. Skipping." + _exit_err "Destination ${c_dest} is not readable. Skipping." fi fi @@ -682,7 +682,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do if [ ! -f "${c_quiet_if_down}" ]; then cat "${TMP}" fi - _exit_err "${tag}" "Source ${source} is not readable. Skipping." + _exit_err "Source ${source} is not readable. Skipping." fi # @@ -693,7 +693,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Check: destination exists? # - cd "${ddir}" || _exit_err "${tag}" "Cannot change to ${ddir}. Skipping." + cd "${ddir}" || _exit_err "Cannot change to ${ddir}. Skipping." # # Check incomplete backups (needs echo to remove newlines) @@ -701,7 +701,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do ls -1 | grep "${CMARKER}\$" > "${TMP}"; ret=$? if [ "$ret" -eq 0 ]; then - _techo "${tag}" "Incomplete backups: $(echo $(cat "${TMP}"))" + _techo "Incomplete backups: $(echo $(cat "${TMP}"))" if [ -f "${c_delete_incomplete}" ]; then delete_from_file "${TMP}" "${CMARKER}" fi @@ -712,14 +712,14 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # count="$(ls -1 | grep -c "^${INTERVAL}\\.")" - _techo "${tag}" "Existing backups: ${count} Total keeping backups: ${c_interval}" + _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" if [ "${count}" -ge "${c_interval}" ]; then remove="$((${count} - ${c_interval} + 1))" - _techo "${tag}" "Removing ${remove} backup(s)..." + _techo "Removing ${remove} backup(s)..." ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ - _exit_err "${tag}" "Listing old backups failed" + _exit_err "Listing old backups failed" delete_from_file "${TMP}" fi @@ -728,14 +728,14 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # Check for backup directory to clone from: Always clone from the latest one! # last_dir="$(ls -${TSORT}p1 | grep '/$' | head -n 1)" || \ - _exit_err "${tag}" "Failed to list contents of ${ddir}." + _exit_err "Failed to list contents of ${ddir}." # # Clone from old backup, if existing # if [ "${last_dir}" ]; then set -- "$@" "--link-dest=${ddir}/${last_dir}" - _techo "${tag}" "Hard linking from ${last_dir}" + _techo "Hard linking from ${last_dir}" fi # @@ -748,14 +748,14 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # Mark backup running and go back to original directory # touch "${destination_dir}${CMARKER}" - cd "${__abs_mydir}" || _exit_err "${tag}" "Cannot go back to ${__abs_mydir}." + cd "${__abs_mydir}" || _exit_err "Cannot go back to ${__abs_mydir}." # # the rsync part # - _techo "${tag}" "Transferring files..." + _techo "Transferring files..." rsync "$@" "${source}" "${destination_dir}"; ret=$? - _techo "${tag}" "Finished backup (rsync return code: $ret)." + _techo "Finished backup (rsync return code: $ret)." # # Set modification time (mtime) to current time, if sorting by mtime is enabled @@ -779,24 +779,24 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # if [ -z "$fail" ]; then rm "${destination_dir}${CMARKER}" || \ - _exit_err "${tag}" "Removing ${destination_dir}${CMARKER} failed." + _exit_err "Removing ${destination_dir}${CMARKER} failed." if [ "${ret}" -ne 0 ]; then - _techo "${tag}" "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." + _techo "Warning: rsync exited non-zero, the backup may be broken (see rsync errors)." fi else - _techo "${tag}" "Warning: rsync failed with return code $ret." + _techo "Warning: rsync failed with return code $ret." fi # # post_exec # if [ -x "${c_post_exec}" ]; then - _techo "${tag}" "Executing ${c_post_exec} ..." + _techo "Executing ${c_post_exec} ..." "${c_post_exec}"; ret=$? - _techo "${tag}" "Finished ${c_post_exec}." + _techo "Finished ${c_post_exec}." if [ "${ret}" -ne 0 ]; then - _exit_err "${tag}" "${c_post_exec} failed." + _exit_err "${c_post_exec} failed." fi fi @@ -809,10 +809,10 @@ while [ "${source_no}" -lt "${no_sources}" ]; do minutes="$(((${full_seconds} % 3600) / 60))" seconds="$((${full_seconds} % 60))" - _techo "${tag}" "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" + _techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" unlock "${name}" -) | add_name +) done # From a63e16efc5a4db733b5505067468f702e48b3e1e Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 23 Sep 2018 11:42:09 +0200 Subject: [PATCH 537/581] Use better expansion and parameter setting --- ccollect | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ccollect b/ccollect index b565355..c3f6328 100755 --- a/ccollect +++ b/ccollect @@ -247,13 +247,8 @@ _techo() { if [ "${LOGLEVEL}" = "a" ] then - tag="${name:-}" - if [ "${tag}" ]; then - tag="[${tag}]" - else - tag="" - fi - "${_techof}" ${tag} "$@" + set -- ${name:+"[${name}]"} $@ + "${_techof}" "$@" fi } From 71eabe2f23f9a9c5fcd3f4d9a94a3d82d2f5cb2a Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 25 Sep 2018 21:14:55 +0200 Subject: [PATCH 538/581] Release 2.4 --- ccollect | 6 +++--- doc/ccollect.text | 2 +- doc/changes/{next => 2.4} | 0 3 files changed, 4 insertions(+), 4 deletions(-) rename doc/changes/{next => 2.4} (100%) diff --git a/ccollect b/ccollect index c3f6328..3c39d9c 100755 --- a/ccollect +++ b/ccollect @@ -1,7 +1,7 @@ #!/bin/sh # # 2005-2013 Nico Schottelius (nico-ccollect at schottelius.org) -# 2016 Darko Poljak (darko.poljak at gmail.com) +# 2016-2018 Darko Poljak (darko.poljak at gmail.com) # # This file is part of ccollect. # @@ -44,8 +44,8 @@ CMARKER=".ccollect-marker" export TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" CONTROL_PIPE="/tmp/${__myname}-control-pipe" -VERSION="2.3" -RELEASE="2018-02-02" +VERSION="2.4" +RELEASE="2018-09-25" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" diff --git a/doc/ccollect.text b/doc/ccollect.text index 5585a97..9851d08 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -2.3, for ccollect 2.3, Initial Version from 2006-01-13 +2.4, for ccollect 2.4, Initial Version from 2006-01-13 :Author Initials: NS diff --git a/doc/changes/next b/doc/changes/2.4 similarity index 100% rename from doc/changes/next rename to doc/changes/2.4 From 835e21c56c6580debb2d661e3b5145601280294c Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 26 Apr 2019 14:03:01 +0200 Subject: [PATCH 539/581] exit in case of subshell error --- ccollect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect b/ccollect index 3c39d9c..335b51d 100755 --- a/ccollect +++ b/ccollect @@ -807,7 +807,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do _techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" unlock "${name}" -) +) || exit done # From 2725a1ced49d8af47abde2618bc53a08f08499f6 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 26 Apr 2019 14:47:21 +0200 Subject: [PATCH 540/581] github -> code.ungleich.ch --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 908bd6c..dc98502 100644 --- a/Makefile +++ b/Makefile @@ -175,7 +175,6 @@ t2: # pub: git push - git push github publish-doc: documentation @echo "Transferring files to ${host}" From 10dcf076a9f9ccd7e8cca6a514835c1ee0c955ea Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 1 May 2019 14:38:35 +0200 Subject: [PATCH 541/581] Release 2.5 --- ccollect | 6 +++--- doc/ccollect.text | 2 +- doc/changes/2.5 | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 doc/changes/2.5 diff --git a/ccollect b/ccollect index 335b51d..bb44ed6 100755 --- a/ccollect +++ b/ccollect @@ -1,7 +1,7 @@ #!/bin/sh # # 2005-2013 Nico Schottelius (nico-ccollect at schottelius.org) -# 2016-2018 Darko Poljak (darko.poljak at gmail.com) +# 2016-2019 Darko Poljak (darko.poljak at gmail.com) # # This file is part of ccollect. # @@ -44,8 +44,8 @@ CMARKER=".ccollect-marker" export TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" CONTROL_PIPE="/tmp/${__myname}-control-pipe" -VERSION="2.4" -RELEASE="2018-09-25" +VERSION="2.5" +RELEASE="2019-05-01" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" diff --git a/doc/ccollect.text b/doc/ccollect.text index 9851d08..f252b25 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -2.4, for ccollect 2.4, Initial Version from 2006-01-13 +2.5, for ccollect 2.5, Initial Version from 2006-01-13 :Author Initials: NS diff --git a/doc/changes/2.5 b/doc/changes/2.5 new file mode 100644 index 0000000..a6b319c --- /dev/null +++ b/doc/changes/2.5 @@ -0,0 +1 @@ +* Bugfix: exit in case of subshell error From 1628ce58c768211052b9d8d02cd0c4d3c7ea3a17 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 5 Oct 2019 10:48:19 +0200 Subject: [PATCH 542/581] Replace rm with faster rsync --delete with empty src dir --- ccollect | 18 +++++++++++++++--- doc/changes/next | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 doc/changes/next diff --git a/ccollect b/ccollect index bb44ed6..05b7014 100755 --- a/ccollect +++ b/ccollect @@ -160,16 +160,28 @@ delete_from_file() file="$1"; shift suffix="" # It will be set, if deleting incomplete backups. [ $# -eq 1 ] && suffix="$1" && shift + # dirs for deletion will be moved to this trash dir inside destination dir + # - for fast mv operation + trash="$(mktemp -d "trash.XXXXXX")" while read to_remove; do + mv "${to_remove}" "${trash}" || + _exit_err "Moving ${to_remove} to ${trash} failed." set -- "$@" "${to_remove}" if [ "${suffix}" ]; then to_remove_no_suffix="$(echo ${to_remove} | sed "s/$suffix\$//")" + mv "${to_remove_no_suffix}" "${trash}" || + _exit_err "Moving ${to_remove_no_suffix} to ${trash} failed." set -- "$@" "${to_remove_no_suffix}" fi done < "${file}" - _techo "Removing $@ ..." - [ "${VVERBOSE}" ] && echo rm "$@" - rm -rf "$@" || _exit_err "Removing $@ failed." + _techo "Removing $@ in ${trash}..." + empty_dir="empty-dir" + mkdir "${empty_dir}" || _exit_err "Empty directory ${empty_dir} cannot be created." + [ "${VVERBOSE}" ] && echo "rsync -a --delete ${empty_dir} ${trash}" + # rsync needs ending slash for directory content + rsync -a --delete "${empty_dir}/" "${trash}/" || _exit_err "Removing $@ failed." + rmdir "${trash}" || _exit_err "Removing ${trash} directory failed" + rmdir "${empty_dir}" || _exit_err "Removing ${empty_dir} directory failed" } display_version() diff --git a/doc/changes/next b/doc/changes/next new file mode 100644 index 0000000..df06edc --- /dev/null +++ b/doc/changes/next @@ -0,0 +1 @@ +* Performance: replace rm -rf with faster rsync --delete empty src dir From ca6d06c2c32c0296dfc8dcb107d469f863fd67e6 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 10 Oct 2019 10:54:56 +0200 Subject: [PATCH 543/581] Add more verbose logging --- ccollect | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ccollect b/ccollect index 05b7014..8e02524 100755 --- a/ccollect +++ b/ccollect @@ -177,11 +177,12 @@ delete_from_file() _techo "Removing $@ in ${trash}..." empty_dir="empty-dir" mkdir "${empty_dir}" || _exit_err "Empty directory ${empty_dir} cannot be created." - [ "${VVERBOSE}" ] && echo "rsync -a --delete ${empty_dir} ${trash}" + [ "${VVERBOSE}" ] && echo "Starting: rsync -a --delete ${empty_dir} ${trash}" # rsync needs ending slash for directory content rsync -a --delete "${empty_dir}/" "${trash}/" || _exit_err "Removing $@ failed." rmdir "${trash}" || _exit_err "Removing ${trash} directory failed" rmdir "${empty_dir}" || _exit_err "Removing ${empty_dir} directory failed" + [ "${VVERBOSE}" ] && echo "Finished: rsync -a --delete ${empty_dir} ${trash}" } display_version() From 30abef474dea75705ee005a0453ea536e73d2fb8 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 16 Oct 2019 14:03:13 +0200 Subject: [PATCH 544/581] Delete in background and finally wait for children --- ccollect | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ccollect b/ccollect index 8e02524..7ede4dc 100755 --- a/ccollect +++ b/ccollect @@ -711,7 +711,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do if [ "$ret" -eq 0 ]; then _techo "Incomplete backups: $(echo $(cat "${TMP}"))" if [ -f "${c_delete_incomplete}" ]; then - delete_from_file "${TMP}" "${CMARKER}" + delete_from_file "${TMP}" "${CMARKER}" & fi fi @@ -729,7 +729,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ _exit_err "Listing old backups failed" - delete_from_file "${TMP}" + delete_from_file "${TMP}" & fi # @@ -820,6 +820,9 @@ while [ "${source_no}" -lt "${no_sources}" ]; do _techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" unlock "${name}" + + # wait for children (doing delete_from_file) if any still running + wait ) || exit done From bfb3c6338c3e7a5bb1f4dcf8c3e1aa9b1117fad0 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 16 Oct 2019 15:50:54 +0200 Subject: [PATCH 545/581] _techo instead of very verbose --- ccollect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect b/ccollect index 7ede4dc..f424f11 100755 --- a/ccollect +++ b/ccollect @@ -182,7 +182,7 @@ delete_from_file() rsync -a --delete "${empty_dir}/" "${trash}/" || _exit_err "Removing $@ failed." rmdir "${trash}" || _exit_err "Removing ${trash} directory failed" rmdir "${empty_dir}" || _exit_err "Removing ${empty_dir} directory failed" - [ "${VVERBOSE}" ] && echo "Finished: rsync -a --delete ${empty_dir} ${trash}" + _techo "Removing $@ in ${trash} finished." } display_version() From 702cdf931e6b76be8aaad5c8cbfaaf4f9e2dc168 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 17 Oct 2019 06:52:51 +0200 Subject: [PATCH 546/581] Use hidden directory for deletion --- ccollect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect b/ccollect index f424f11..41f23c5 100755 --- a/ccollect +++ b/ccollect @@ -162,7 +162,7 @@ delete_from_file() [ $# -eq 1 ] && suffix="$1" && shift # dirs for deletion will be moved to this trash dir inside destination dir # - for fast mv operation - trash="$(mktemp -d "trash.XXXXXX")" + trash="$(mktemp -d ".trash.XXXXXX")" while read to_remove; do mv "${to_remove}" "${trash}" || _exit_err "Moving ${to_remove} to ${trash} failed." From 51dcf4a02f3b57bc94c1bc15b955ef097bfbf3a6 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 17 Oct 2019 06:52:51 +0200 Subject: [PATCH 547/581] Use hidden empty directory for deletion --- ccollect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect b/ccollect index 41f23c5..c744e27 100755 --- a/ccollect +++ b/ccollect @@ -175,7 +175,7 @@ delete_from_file() fi done < "${file}" _techo "Removing $@ in ${trash}..." - empty_dir="empty-dir" + empty_dir=".empty-dir" mkdir "${empty_dir}" || _exit_err "Empty directory ${empty_dir} cannot be created." [ "${VVERBOSE}" ] && echo "Starting: rsync -a --delete ${empty_dir} ${trash}" # rsync needs ending slash for directory content From 1e18e71b9de892b255516cdd9fbfdfa4304f7c57 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 17 Oct 2019 07:42:31 +0200 Subject: [PATCH 548/581] Use oldest backup as destination dir without deletion --- ccollect | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/ccollect b/ccollect index c744e27..cf7abe9 100755 --- a/ccollect +++ b/ccollect @@ -715,6 +715,12 @@ while [ "${source_no}" -lt "${no_sources}" ]; do fi fi + # + # Include current time in name, not the time when we began to remove above + # + export destination_name="${INTERVAL}.$(${CDATE}).$$-${source_no}" + export destination_dir="${ddir}/${destination_name}" + # # Check: maximum number of backups is reached? # @@ -723,13 +729,26 @@ while [ "${source_no}" -lt "${no_sources}" ]; do _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" if [ "${count}" -ge "${c_interval}" ]; then - remove="$((${count} - ${c_interval} + 1))" - _techo "Removing ${remove} backup(s)..." + # Use oldest directory as new backup destination directory. + # It need not to be deleted, rsync will sync its content. + oldest_bak=$(ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n 1 || \ + _exit_err "Listing oldest backup failed") + _techo "Using ${oldest_bak} for destination dir" + mv "${oldest_bak}" "${destination_dir}" || + _exit_err "Moving oldest backup ${oldest_bak} to ${destination_dir} failed." + # Touch dest dir so it is not sorted wrong in listings below. + touch "${destination_dir}" - ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ - _exit_err "Listing old backups failed" + # We have something to remove only if count > interval. + if [ "${count}" -gt "${c_interval}" ]; then + remove="$((${count} - ${c_interval}))" + _techo "Removing ${remove} backup(s)..." - delete_from_file "${TMP}" & + ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ + _exit_err "Listing old backups failed" + + delete_from_file "${TMP}" & + fi fi # @@ -746,12 +765,6 @@ while [ "${source_no}" -lt "${no_sources}" ]; do _techo "Hard linking from ${last_dir}" fi - # - # Include current time in name, not the time when we began to remove above - # - export destination_name="${INTERVAL}.$(${CDATE}).$$-${source_no}" - export destination_dir="${ddir}/${destination_name}" - # # Mark backup running and go back to original directory # From 2788de47b8a7f5a23192b48f421ed37a059f8bb0 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 17 Oct 2019 07:52:53 +0200 Subject: [PATCH 549/581] Improve log line --- ccollect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect b/ccollect index cf7abe9..af7a2c1 100755 --- a/ccollect +++ b/ccollect @@ -733,7 +733,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # It need not to be deleted, rsync will sync its content. oldest_bak=$(ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n 1 || \ _exit_err "Listing oldest backup failed") - _techo "Using ${oldest_bak} for destination dir" + _techo "Using ${oldest_bak} for destination dir ${destination_dir}" mv "${oldest_bak}" "${destination_dir}" || _exit_err "Moving oldest backup ${oldest_bak} to ${destination_dir} failed." # Touch dest dir so it is not sorted wrong in listings below. From c39205d30898110b40040c6fad2d6a026013b977 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 17 Oct 2019 08:03:12 +0200 Subject: [PATCH 550/581] Exclude destintion dir from listing for last dir --- ccollect | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ccollect b/ccollect index af7a2c1..35d2071 100755 --- a/ccollect +++ b/ccollect @@ -753,8 +753,10 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Check for backup directory to clone from: Always clone from the latest one! + # Exclude destination_dir from listing, it can be touched reused and renamed + # oldest existing destination directory. # - last_dir="$(ls -${TSORT}p1 | grep '/$' | head -n 1)" || \ + last_dir="$(ls -${TSORT}p1 | grep '/$' | grep -v "${destination_dir}" | head -n 1)" || \ _exit_err "Failed to list contents of ${ddir}." # From 7701bdb0a87413bc756ea408656e32d65d7dfb20 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 17 Oct 2019 08:06:13 +0200 Subject: [PATCH 551/581] Use destination dir basename --- ccollect | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ccollect b/ccollect index 35d2071..f5aa145 100755 --- a/ccollect +++ b/ccollect @@ -756,7 +756,8 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # Exclude destination_dir from listing, it can be touched reused and renamed # oldest existing destination directory. # - last_dir="$(ls -${TSORT}p1 | grep '/$' | grep -v "${destination_dir}" | head -n 1)" || \ + dest_dir_name=$(basename "${destination_dir}") + last_dir="$(ls -${TSORT}p1 | grep '/$' | grep -v "${dest_dir_name}" | head -n 1)" || \ _exit_err "Failed to list contents of ${ddir}." # From e44dede92f9114db1ffec24a46f215fb270ed08a Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 17 Oct 2019 09:05:55 +0200 Subject: [PATCH 552/581] ++changelog --- doc/changes/next | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changes/next b/doc/changes/next index df06edc..a68cbbc 100644 --- a/doc/changes/next +++ b/doc/changes/next @@ -1 +1 @@ -* Performance: replace rm -rf with faster rsync --delete empty src dir +* Improve performance, improve process of deletion of old backups From de720ecfe9a71bd2fad3e5ef429629007e8ea6ed Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 17 Oct 2019 11:53:46 +0200 Subject: [PATCH 553/581] If renaming oldest bak dir fails then fallback to removing it --- ccollect | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ccollect b/ccollect index f5aa145..b8011ba 100755 --- a/ccollect +++ b/ccollect @@ -734,14 +734,17 @@ while [ "${source_no}" -lt "${no_sources}" ]; do oldest_bak=$(ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n 1 || \ _exit_err "Listing oldest backup failed") _techo "Using ${oldest_bak} for destination dir ${destination_dir}" - mv "${oldest_bak}" "${destination_dir}" || - _exit_err "Moving oldest backup ${oldest_bak} to ${destination_dir} failed." - # Touch dest dir so it is not sorted wrong in listings below. - touch "${destination_dir}" + if mv "${oldest_bak}" "${destination_dir}"; then + # Touch dest dir so it is not sorted wrong in listings below. + touch "${destination_dir}" - # We have something to remove only if count > interval. - if [ "${count}" -gt "${c_interval}" ]; then + # We have something to remove only if count > interval. remove="$((${count} - ${c_interval}))" + else + _techo_err "Renaming oldest backup ${oldest_bak} to ${destination_dir} failed, removing it." + remove="$((${count} - ${c_interval} + 1))" + fi + if [ "${remove}" -gt 0 ]; then _techo "Removing ${remove} backup(s)..." ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ From 74e3b26790e4b77f2761d62bd6811aab9bfb9bbd Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 12 Nov 2019 17:55:15 +0100 Subject: [PATCH 554/581] Release 2.6 --- ccollect | 4 ++-- doc/ccollect.text | 2 +- doc/changes/{next => 2.6} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename doc/changes/{next => 2.6} (100%) diff --git a/ccollect b/ccollect index b8011ba..4fa6da3 100755 --- a/ccollect +++ b/ccollect @@ -44,8 +44,8 @@ CMARKER=".ccollect-marker" export TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" CONTROL_PIPE="/tmp/${__myname}-control-pipe" -VERSION="2.5" -RELEASE="2019-05-01" +VERSION="2.6" +RELEASE="2019-11-12" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" diff --git a/doc/ccollect.text b/doc/ccollect.text index f252b25..37e4eaf 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -2.5, for ccollect 2.5, Initial Version from 2006-01-13 +2.6, for ccollect 2.6, Initial Version from 2006-01-13 :Author Initials: NS diff --git a/doc/changes/next b/doc/changes/2.6 similarity index 100% rename from doc/changes/next rename to doc/changes/2.6 From 2cefdaa1a5f6adac7240534e558ba9196872cbfa Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 18 Oct 2019 16:24:22 +0200 Subject: [PATCH 555/581] Fix shellcheck reported issues --- ccollect | 115 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 75 insertions(+), 40 deletions(-) diff --git a/ccollect b/ccollect index 4fa6da3..6dd3fc0 100755 --- a/ccollect +++ b/ccollect @@ -27,9 +27,9 @@ set -u # # Standard variables (stolen from cconf) # -__pwd="$(pwd -P)" -__mydir="${0%/*}"; __abs_mydir="$(cd "$__mydir" && pwd -P)" -__myname=${0##*/}; __abs_myname="$__abs_mydir/$__myname" +__mydir="${0%/*}" +__abs_mydir="$(cd "$__mydir" && pwd -P)" +__myname=${0##*/} # # where to find our configuration and temporary file @@ -41,7 +41,8 @@ CPREEXEC="${CDEFAULTS}/pre_exec" CPOSTEXEC="${CDEFAULTS}/post_exec" CMARKER=".ccollect-marker" -export TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" +TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" +export TMP CONTROL_PIPE="/tmp/${__myname}-control-pipe" VERSION="2.6" @@ -76,6 +77,7 @@ LOCKFD=4 lock_flock() { # $1 = source to backup + # shellcheck disable=SC2059 lockfile="${LOCKDIR}/$(printf "${LOCKFILE_PATTERN}" "$1")" eval "exec ${LOCKFD}> ${lockfile}" @@ -85,6 +87,7 @@ lock_flock() unlock_flock() { # $1 = source to backup + # shellcheck disable=SC2059 lockfile="${LOCKDIR}/$(printf "${LOCKFILE_PATTERN}" "$1")" eval "exec ${LOCKFD}>&-" rm -f "${lockfile}" @@ -96,6 +99,7 @@ unlock_flock() lock_mkdir() { # $1 = source to backup + # shellcheck disable=SC2059 lockfile="${LOCKDIR}/$(printf "${LOCKFILE_PATTERN}" "$1")" mkdir "${lockfile}" && return 0 || return 1 @@ -104,6 +108,7 @@ lock_mkdir() unlock_mkdir() { # $1 = source to backup + # shellcheck disable=SC2059 lockfile="${LOCKDIR}/$(printf "${LOCKFILE_PATTERN}" "$1")" rmdir "${lockfile}" @@ -112,7 +117,7 @@ unlock_mkdir() # # determine locking tool: flock or mkdir # -if $(which flock > /dev/null 2>&1) +if command -v flock > /dev/null 2>&1 then lockf="lock_flock" unlockf="unlock_flock" @@ -137,6 +142,7 @@ LOGONLYERRORS="" # catch signals # TRAPFUNC="rm -f \"${TMP}\"" +# shellcheck disable=SC2064 trap "${TRAPFUNC}" 1 2 15 # @@ -147,7 +153,7 @@ trap "${TRAPFUNC}" 1 2 15 # see: http://www.tldp.org/LDP/abs/html/intandnonint.html _is_interactive() { - [ -t 0 -o -p /dev/stdin ] + [ -t 0 ] || [ -p /dev/stdin ] } # @@ -163,26 +169,26 @@ delete_from_file() # dirs for deletion will be moved to this trash dir inside destination dir # - for fast mv operation trash="$(mktemp -d ".trash.XXXXXX")" - while read to_remove; do + while read -r to_remove; do mv "${to_remove}" "${trash}" || _exit_err "Moving ${to_remove} to ${trash} failed." set -- "$@" "${to_remove}" if [ "${suffix}" ]; then - to_remove_no_suffix="$(echo ${to_remove} | sed "s/$suffix\$//")" + to_remove_no_suffix="$(echo "${to_remove}" | sed "s/$suffix\$//")" mv "${to_remove_no_suffix}" "${trash}" || _exit_err "Moving ${to_remove_no_suffix} to ${trash} failed." set -- "$@" "${to_remove_no_suffix}" fi done < "${file}" - _techo "Removing $@ in ${trash}..." + _techo "Removing $* in ${trash}..." empty_dir=".empty-dir" mkdir "${empty_dir}" || _exit_err "Empty directory ${empty_dir} cannot be created." [ "${VVERBOSE}" ] && echo "Starting: rsync -a --delete ${empty_dir} ${trash}" # rsync needs ending slash for directory content - rsync -a --delete "${empty_dir}/" "${trash}/" || _exit_err "Removing $@ failed." + rsync -a --delete "${empty_dir}/" "${trash}/" || _exit_err "Removing $* failed." rmdir "${trash}" || _exit_err "Removing ${trash} directory failed" rmdir "${empty_dir}" || _exit_err "Removing ${empty_dir} directory failed" - _techo "Removing $@ in ${trash} finished." + _techo "Removing $* in ${trash} finished." } display_version() @@ -232,7 +238,7 @@ unlock() # stdout version _techo_stdout() { - echo "$(${DDATE}): $@" + echo "$(${DDATE}): $*" } # syslog version @@ -260,14 +266,16 @@ _techo() { if [ "${LOGLEVEL}" = "a" ] then - set -- ${name:+"[${name}]"} $@ + # name is exported before calling this function + # shellcheck disable=SC2154 + set -- ${name:+"[${name}]"} "$@" "${_techof}" "$@" fi } _techo_err() { - _techo "Error: $@" + _techo "Error: $*" } _exit_err() @@ -368,7 +376,7 @@ else LOGLEVEL="a" fi -if [ "${LOGFILE}" -o "${SYSLOG}" ] +if [ "${LOGFILE}" ] || [ "${SYSLOG}" ] then if [ "${LOGONLYERRORS}" ] then @@ -378,8 +386,7 @@ fi # check that MAX_JOBS is natural number > 0 # empty string means run all in parallel -echo "${MAX_JOBS}" | grep -q -E '^[1-9][0-9]*$|^$' -if [ "$?" -ne 0 ] +if ! echo "${MAX_JOBS}" | grep -q -E '^[1-9][0-9]*$|^$' then _exit_err "Invalid max jobs value \"${MAX_JOBS}\"" fi @@ -412,19 +419,22 @@ if [ "${USE_ALL}" = 1 ]; then ( cd "${CSOURCES}" && ls -1 > "${TMP}" ) || \ _exit_err "Listing of sources failed. Aborting." - while read tmp; do - eval export source_${no_sources}=\"${tmp}\" - no_sources=$((${no_sources}+1)) + while read -r tmp; do + eval export "source_${no_sources}=\"${tmp}\"" + no_sources=$((no_sources + 1)) done < "${TMP}" else # # Get sources from command line # while [ "$#" -ge 1 ]; do - eval arg=\"\$1\"; shift + eval "arg=\"\$1\"" + shift - eval export source_${no_sources}=\"${arg}\" - no_sources="$((${no_sources}+1))" + # arg is assigned in the eval above + # shellcheck disable=SC2154 + eval export "source_${no_sources}=\"${arg}\"" + no_sources="$((no_sources + 1))" done fi @@ -461,6 +471,7 @@ if [ "${PARALLEL}" ]; then # fd 5 is tied to control pipe eval "exec 5<>${CONTROL_PIPE}" TRAPFUNC="${TRAPFUNC}; rm -f \"${CONTROL_PIPE}\"" + # shellcheck disable=SC2064 trap "${TRAPFUNC}" 0 1 2 15 # determine how much parallel jobs to prestart @@ -483,7 +494,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # Get current source # eval export name=\"\$source_${source_no}\" - source_no=$((${source_no}+1)) + source_no=$((source_no + 1)) # # Start ourself, if we want parallel execution @@ -498,12 +509,12 @@ while [ "${source_no}" -lt "${no_sources}" ]; do then # run prestart child if pending { "$0" "${INTERVAL}" "${name}"; printf '\n' >&5; } & - prestart=$((${prestart} - 1)) + prestart=$((prestart - 1)) continue else # each time a child finishes we get a line from the pipe # and then launch another child - while read line + while read -r line do { "$0" "${INTERVAL}" "${name}"; printf '\n' >&5; } & # get out of loop so we can contnue with main loop @@ -557,6 +568,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # redefine trap to also unlock (rm lockfile) TRAPFUNC="${TRAPFUNC}; unlock \"${name}\"" + # shellcheck disable=SC2064 trap "${TRAPFUNC}" 1 2 15 # @@ -576,10 +588,10 @@ while [ "${source_no}" -lt "${no_sources}" ]; do for opt in verbose very_verbose summary exclude rsync_options \ delete_incomplete rsync_failure_codes \ mtime quiet_if_down ; do - if [ -f "${backup}/${opt}" -o -f "${backup}/no_${opt}" ]; then - eval c_$opt=\"${backup}/$opt\" + if [ -f "${backup}/${opt}" ] || [ -f "${backup}/no_${opt}" ]; then + eval "c_$opt=\"${backup}/$opt\"" else - eval c_$opt=\"${CDEFAULTS}/$opt\" + eval "c_$opt=\"${CDEFAULTS}/$opt\"" fi done @@ -599,6 +611,8 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Sort by ctime (default) or mtime (configuration option) # + # variable is assigned using eval + # shellcheck disable=SC2154 if [ -f "${c_mtime}" ] ; then TSORT="t" else @@ -642,6 +656,8 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Exclude list # + # variable is assigned using eval + # shellcheck disable=SC2154 if [ -f "${c_exclude}" ]; then set -- "$@" "--exclude-from=${c_exclude}" fi @@ -649,6 +665,8 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Output a summary # + # variable is assigned using eval + # shellcheck disable=SC2154 if [ -f "${c_summary}" ]; then set -- "$@" "--stats" fi @@ -657,6 +675,8 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # Verbosity for rsync, rm, and mkdir # VVERBOSE="" + # variable is assigned using eval + # shellcheck disable=SC2154 if [ -f "${c_very_verbose}" ]; then set -- "$@" "-vv" VVERBOSE="-v" @@ -667,8 +687,10 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Extra options for rsync provided by the user # + # variable is assigned using eval + # shellcheck disable=SC2154 if [ -f "${c_rsync_options}" ]; then - while read line; do + while read -r line; do # Trim line. ln=$(echo "${line}" | awk '{$1=$1;print;}') # Only if ln is non zero length string. @@ -687,6 +709,8 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # Check: source is up and accepting connections (before deleting old backups!) # if ! rsync "$@" "${source}" >/dev/null 2>"${TMP}" ; then + # variable is assigned using eval + # shellcheck disable=SC2154 if [ ! -f "${c_quiet_if_down}" ]; then cat "${TMP}" fi @@ -706,10 +730,13 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Check incomplete backups (needs echo to remove newlines) # + # shellcheck disable=SC2010 ls -1 | grep "${CMARKER}\$" > "${TMP}"; ret=$? if [ "$ret" -eq 0 ]; then - _techo "Incomplete backups: $(echo $(cat "${TMP}"))" + _techo "Incomplete backups: $(cat "${TMP}")" + # variable is assigned using eval + # shellcheck disable=SC2154 if [ -f "${c_delete_incomplete}" ]; then delete_from_file "${TMP}" "${CMARKER}" & fi @@ -718,12 +745,15 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Include current time in name, not the time when we began to remove above # - export destination_name="${INTERVAL}.$(${CDATE}).$$-${source_no}" - export destination_dir="${ddir}/${destination_name}" + destination_name="${INTERVAL}.$(${CDATE}).$$-${source_no}" + export destination_name + destination_dir="${ddir}/${destination_name}" + export destination_dir # # Check: maximum number of backups is reached? # + # shellcheck disable=SC2010 count="$(ls -1 | grep -c "^${INTERVAL}\\.")" _techo "Existing backups: ${count} Total keeping backups: ${c_interval}" @@ -731,6 +761,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do if [ "${count}" -ge "${c_interval}" ]; then # Use oldest directory as new backup destination directory. # It need not to be deleted, rsync will sync its content. + # shellcheck disable=SC2010 oldest_bak=$(ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n 1 || \ _exit_err "Listing oldest backup failed") _techo "Using ${oldest_bak} for destination dir ${destination_dir}" @@ -739,14 +770,15 @@ while [ "${source_no}" -lt "${no_sources}" ]; do touch "${destination_dir}" # We have something to remove only if count > interval. - remove="$((${count} - ${c_interval}))" + remove="$((count - c_interval))" else _techo_err "Renaming oldest backup ${oldest_bak} to ${destination_dir} failed, removing it." - remove="$((${count} - ${c_interval} + 1))" + remove="$((count - c_interval + 1))" fi if [ "${remove}" -gt 0 ]; then _techo "Removing ${remove} backup(s)..." + # shellcheck disable=SC2010 ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ _exit_err "Listing old backups failed" @@ -760,6 +792,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # oldest existing destination directory. # dest_dir_name=$(basename "${destination_dir}") + # shellcheck disable=SC2010 last_dir="$(ls -${TSORT}p1 | grep '/$' | grep -v "${dest_dir_name}" | head -n 1)" || \ _exit_err "Failed to list contents of ${ddir}." @@ -793,8 +826,10 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # Check if rsync exit code indicates failure. # fail="" + # variable is assigned using eval + # shellcheck disable=SC2154 if [ -f "$c_rsync_failure_codes" ]; then - while read code ; do + while read -r code ; do if [ "$ret" = "$code" ]; then fail=1 fi @@ -831,10 +866,10 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # Time calculation # end_s="$(${SDATE})" - full_seconds="$((${end_s} - ${begin_s}))" - hours="$((${full_seconds} / 3600))" - minutes="$(((${full_seconds} % 3600) / 60))" - seconds="$((${full_seconds} % 60))" + full_seconds="$((end_s - begin_s))" + hours="$((full_seconds / 3600))" + minutes="$(((full_seconds % 3600) / 60))" + seconds="$((full_seconds % 60))" _techo "Backup lasted: ${hours}:${minutes}:${seconds} (h:m:s)" From a5e565b5d69106c11c8090825038b8af51c6fdb5 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 14 Nov 2019 19:16:11 +0100 Subject: [PATCH 556/581] Add shellcheck makefile target --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index dc98502..9b07e09 100644 --- a/Makefile +++ b/Makefile @@ -199,6 +199,9 @@ dist: distclean documentation /tmp/ccollect: mkdir -p /tmp/ccollect +shellcheck: ./ccollect + shellcheck -s sh -f gcc -x ./ccollect + test: $(CCOLLECT_SOURCE) /tmp/ccollect cd ./conf/sources/; for s in *; do CCOLLECT_CONF=../ ../../ccollect daily "$$s"; done touch /tmp/ccollect/$$(ls /tmp/ccollect | head -n1).ccollect-marker From f818f011e3cdd5aa556ee140913f607381555cf5 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 14 Nov 2019 19:20:16 +0100 Subject: [PATCH 557/581] Release 2.7 --- ccollect | 4 ++-- doc/ccollect.text | 2 +- doc/changes/2.7 | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 doc/changes/2.7 diff --git a/ccollect b/ccollect index 6dd3fc0..9077e0f 100755 --- a/ccollect +++ b/ccollect @@ -45,8 +45,8 @@ TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" export TMP CONTROL_PIPE="/tmp/${__myname}-control-pipe" -VERSION="2.6" -RELEASE="2019-11-12" +VERSION="2.7" +RELEASE="2019-11-14" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" diff --git a/doc/ccollect.text b/doc/ccollect.text index 37e4eaf..2478265 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -2.6, for ccollect 2.6, Initial Version from 2006-01-13 +2.7, for ccollect 2.7, Initial Version from 2006-01-13 :Author Initials: NS diff --git a/doc/changes/2.7 b/doc/changes/2.7 new file mode 100644 index 0000000..bafbb01 --- /dev/null +++ b/doc/changes/2.7 @@ -0,0 +1 @@ +* Fix shellcheck reported issues From 401dd4fa8e4a50e7f8a706c35bf5c505b874a205 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 15 Nov 2019 08:29:21 +0100 Subject: [PATCH 558/581] Fix path with spaces in eval --- ccollect | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect b/ccollect index 9077e0f..d89aec1 100755 --- a/ccollect +++ b/ccollect @@ -79,7 +79,7 @@ lock_flock() # $1 = source to backup # shellcheck disable=SC2059 lockfile="${LOCKDIR}/$(printf "${LOCKFILE_PATTERN}" "$1")" - eval "exec ${LOCKFD}> ${lockfile}" + eval "exec ${LOCKFD}> '${lockfile}'" flock -n ${LOCKFD} && return 0 || return 1 } @@ -469,7 +469,7 @@ fi if [ "${PARALLEL}" ]; then mkfifo "${CONTROL_PIPE}" # fd 5 is tied to control pipe - eval "exec 5<>${CONTROL_PIPE}" + eval "exec 5<>'${CONTROL_PIPE}'" TRAPFUNC="${TRAPFUNC}; rm -f \"${CONTROL_PIPE}\"" # shellcheck disable=SC2064 trap "${TRAPFUNC}" 0 1 2 15 From 8f5d9b2c978916d3093ab7c2ce7bb0a94e580018 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 15 Nov 2019 08:28:55 +0100 Subject: [PATCH 559/581] Add unit testing --- .gitignore | 1 - Makefile | 44 ++++++++++++++++++- test/conf/ccollect_local-with | 0 test/conf/ccollect_source | 0 test/conf/defaults/intervals/daily | 1 + test/conf/defaults/intervals/monthly | 1 + test/conf/defaults/intervals/normal | 1 + test/conf/defaults/intervals/weekly | 1 + test/conf/defaults/post_exec | 5 +++ test/conf/defaults/pre_exec | 5 +++ test/conf/defaults/sources/exclude | 1 + test/conf/defaults/sources/rsync_options | 0 test/conf/defaults/sources/verbose | 0 test/conf/defaults/verbose | 0 .../delete_incomplete/delete_incomplete | 0 .../sources/delete_incomplete/destination | 1 + test/conf/sources/delete_incomplete/exclude | 1 + test/conf/sources/delete_incomplete/source | 1 + .../sources/local-with&ersand/destination | 1 + .../conf/sources/local-with&ersand/exclude | 1 + test/conf/sources/local-with&ersand/source | 1 + .../local-with-interval/delete_incomplete | 0 .../sources/local-with-interval/destination | 1 + test/conf/sources/local-with-interval/exclude | 1 + .../local-with-interval/intervals/daily | 1 + test/conf/sources/local-with-interval/source | 1 + test/conf/sources/local-with-interval/verbose | 0 test/conf/sources/local/destination | 1 + test/conf/sources/local/exclude | 1 + test/conf/sources/local/no_verbose | 0 test/conf/sources/local/source | 1 + .../delete_incomplete | 0 .../destination | 1 + .../source with spaces and interval/exclude | 1 + .../source with spaces and interval/source | 1 + .../source with spaces and interval/verbose | 0 test/conf/sources/very_verbose/destination | 1 + test/conf/sources/very_verbose/exclude | 1 + test/conf/sources/very_verbose/source | 1 + test/conf/sources/very_verbose/summary | 0 test/conf/sources/very_verbose/verbose | 0 test/conf/sources/very_verbose/very_verbose | 0 test/conf/sources/with_exec/destination | 1 + test/conf/sources/with_exec/post_exec | 5 +++ test/conf/sources/with_exec/pre_exec | 5 +++ test/conf/sources/with_exec/source | 1 + test/exec.sh | 18 -------- test/local.sh | 1 - test/remote.sh | 1 - test/return-value.sh | 23 ---------- test/test-ccollect-tools.sh | 29 ------------ test/test-ccollect1.sh | 44 ------------------- 52 files changed, 89 insertions(+), 118 deletions(-) create mode 100644 test/conf/ccollect_local-with create mode 100644 test/conf/ccollect_source create mode 100644 test/conf/defaults/intervals/daily create mode 100644 test/conf/defaults/intervals/monthly create mode 100644 test/conf/defaults/intervals/normal create mode 100644 test/conf/defaults/intervals/weekly create mode 100755 test/conf/defaults/post_exec create mode 100755 test/conf/defaults/pre_exec create mode 100644 test/conf/defaults/sources/exclude create mode 100644 test/conf/defaults/sources/rsync_options create mode 100644 test/conf/defaults/sources/verbose create mode 100644 test/conf/defaults/verbose create mode 100644 test/conf/sources/delete_incomplete/delete_incomplete create mode 100644 test/conf/sources/delete_incomplete/destination create mode 100644 test/conf/sources/delete_incomplete/exclude create mode 100644 test/conf/sources/delete_incomplete/source create mode 100644 test/conf/sources/local-with&ersand/destination create mode 100644 test/conf/sources/local-with&ersand/exclude create mode 100644 test/conf/sources/local-with&ersand/source create mode 100644 test/conf/sources/local-with-interval/delete_incomplete create mode 100644 test/conf/sources/local-with-interval/destination create mode 100644 test/conf/sources/local-with-interval/exclude create mode 100644 test/conf/sources/local-with-interval/intervals/daily create mode 100644 test/conf/sources/local-with-interval/source create mode 100644 test/conf/sources/local-with-interval/verbose create mode 100644 test/conf/sources/local/destination create mode 100644 test/conf/sources/local/exclude create mode 100644 test/conf/sources/local/no_verbose create mode 100644 test/conf/sources/local/source create mode 100644 test/conf/sources/source with spaces and interval/delete_incomplete create mode 100644 test/conf/sources/source with spaces and interval/destination create mode 100644 test/conf/sources/source with spaces and interval/exclude create mode 100644 test/conf/sources/source with spaces and interval/source create mode 100644 test/conf/sources/source with spaces and interval/verbose create mode 100644 test/conf/sources/very_verbose/destination create mode 100644 test/conf/sources/very_verbose/exclude create mode 100644 test/conf/sources/very_verbose/source create mode 100644 test/conf/sources/very_verbose/summary create mode 100644 test/conf/sources/very_verbose/verbose create mode 100644 test/conf/sources/very_verbose/very_verbose create mode 100644 test/conf/sources/with_exec/destination create mode 100755 test/conf/sources/with_exec/post_exec create mode 100755 test/conf/sources/with_exec/pre_exec create mode 100644 test/conf/sources/with_exec/source delete mode 100755 test/exec.sh delete mode 100755 test/local.sh delete mode 100755 test/remote.sh delete mode 100755 test/return-value.sh delete mode 100644 test/test-ccollect-tools.sh delete mode 100755 test/test-ccollect1.sh diff --git a/.gitignore b/.gitignore index 4e9c74d..e5c18f6 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,6 @@ doc/man/*.html doc/man/*.htm doc/man/*.texi doc/man/*.man -test/* .*.swp doc/man/*.[0-9] doc/*.xml diff --git a/Makefile b/Makefile index 9b07e09..9b9f3e5 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,8 @@ DOCBDOCS = ${DOCS:.text=.docbook} DOC_ALL = ${HTMLDOCS} ${DBHTMLDOCS} ${TEXIDOCS} ${MANPDOCS} ${PDFDOCS} +TEST_LOG_FILE = /tmp/ccollect/ccollect.log + # # End user targets # @@ -202,9 +204,49 @@ dist: distclean documentation shellcheck: ./ccollect shellcheck -s sh -f gcc -x ./ccollect -test: $(CCOLLECT_SOURCE) /tmp/ccollect +test-nico: $(CCOLLECT_SOURCE) /tmp/ccollect cd ./conf/sources/; for s in *; do CCOLLECT_CONF=../ ../../ccollect daily "$$s"; done touch /tmp/ccollect/$$(ls /tmp/ccollect | head -n1).ccollect-marker CCOLLECT_CONF=./conf ./ccollect -a daily touch /tmp/ccollect/$$(ls /tmp/ccollect | head -n1).ccollect-marker CCOLLECT_CONF=./conf ./ccollect -a -p daily + +test-dir-source: + mkdir -p /tmp/ccollect/source + cp -R -f ./* /tmp/ccollect/source + +test-dir-destination: + mkdir -p /tmp/ccollect/backup + +test-dir-destination-chint: + mkdir -p /tmp/ccollect/backup-chint + +test-fixed-intervals: $(CCOLLECT_SOURCE) test-dir-source test-dir-destination test-dir-destination-chint + for s in ./test/conf/sources/*; do \ + CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily "$$(basename $$s)"; \ + test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0"; \ + done + CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} -a -v daily + test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0" + CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} -a -p daily + test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0" + @printf "\nFixed intervals test ended successfully\n" + +test-interval-changing: $(CCOLLECT_SOURCE) test-dir-source test-dir-destination-chint + rm -rf /tmp/ccollect/backup-chint/* + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "0" + printf "3" > ./test/conf/sources/local-with-interval/intervals/daily + for x in 1 2 3 4 5; do CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily local-with-interval; done + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "3" + printf "5" > ./test/conf/sources/local-with-interval/intervals/daily + for x in 1 2 3 4 5 6 7; do CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily local-with-interval; done + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "5" + printf "4" > ./test/conf/sources/local-with-interval/intervals/daily + for x in 1 2 3 4 5 6; do CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily local-with-interval; done + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "4" + printf "3" > ./test/conf/sources/local-with-interval/intervals/daily + @printf "\nInterval changing test ended successfully\n" + +test: test-fixed-intervals test-interval-changing + test -f "${TEST_LOG_FILE}" + @printf "\nTests ended successfully\n" diff --git a/test/conf/ccollect_local-with b/test/conf/ccollect_local-with new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/ccollect_source b/test/conf/ccollect_source new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/defaults/intervals/daily b/test/conf/defaults/intervals/daily new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/test/conf/defaults/intervals/daily @@ -0,0 +1 @@ +5 diff --git a/test/conf/defaults/intervals/monthly b/test/conf/defaults/intervals/monthly new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/test/conf/defaults/intervals/monthly @@ -0,0 +1 @@ +4 diff --git a/test/conf/defaults/intervals/normal b/test/conf/defaults/intervals/normal new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/test/conf/defaults/intervals/normal @@ -0,0 +1 @@ +4 diff --git a/test/conf/defaults/intervals/weekly b/test/conf/defaults/intervals/weekly new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/test/conf/defaults/intervals/weekly @@ -0,0 +1 @@ +2 diff --git a/test/conf/defaults/post_exec b/test/conf/defaults/post_exec new file mode 100755 index 0000000..8aee58f --- /dev/null +++ b/test/conf/defaults/post_exec @@ -0,0 +1,5 @@ +#!/bin/cat + +###################################################################### +General post_exec executed. +###################################################################### diff --git a/test/conf/defaults/pre_exec b/test/conf/defaults/pre_exec new file mode 100755 index 0000000..ecd2857 --- /dev/null +++ b/test/conf/defaults/pre_exec @@ -0,0 +1,5 @@ +#!/bin/cat + +###################################################################### +General pre__exec executed. +###################################################################### diff --git a/test/conf/defaults/sources/exclude b/test/conf/defaults/sources/exclude new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/test/conf/defaults/sources/exclude @@ -0,0 +1 @@ +.git diff --git a/test/conf/defaults/sources/rsync_options b/test/conf/defaults/sources/rsync_options new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/defaults/sources/verbose b/test/conf/defaults/sources/verbose new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/defaults/verbose b/test/conf/defaults/verbose new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/delete_incomplete/delete_incomplete b/test/conf/sources/delete_incomplete/delete_incomplete new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/delete_incomplete/destination b/test/conf/sources/delete_incomplete/destination new file mode 100644 index 0000000..c2a7c55 --- /dev/null +++ b/test/conf/sources/delete_incomplete/destination @@ -0,0 +1 @@ +/tmp/ccollect/backup diff --git a/test/conf/sources/delete_incomplete/exclude b/test/conf/sources/delete_incomplete/exclude new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/test/conf/sources/delete_incomplete/exclude @@ -0,0 +1 @@ +.git diff --git a/test/conf/sources/delete_incomplete/source b/test/conf/sources/delete_incomplete/source new file mode 100644 index 0000000..9e90576 --- /dev/null +++ b/test/conf/sources/delete_incomplete/source @@ -0,0 +1 @@ +/tmp/ccollect/source diff --git a/test/conf/sources/local-with&ersand/destination b/test/conf/sources/local-with&ersand/destination new file mode 100644 index 0000000..c2a7c55 --- /dev/null +++ b/test/conf/sources/local-with&ersand/destination @@ -0,0 +1 @@ +/tmp/ccollect/backup diff --git a/test/conf/sources/local-with&ersand/exclude b/test/conf/sources/local-with&ersand/exclude new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/test/conf/sources/local-with&ersand/exclude @@ -0,0 +1 @@ +.git diff --git a/test/conf/sources/local-with&ersand/source b/test/conf/sources/local-with&ersand/source new file mode 100644 index 0000000..9e90576 --- /dev/null +++ b/test/conf/sources/local-with&ersand/source @@ -0,0 +1 @@ +/tmp/ccollect/source diff --git a/test/conf/sources/local-with-interval/delete_incomplete b/test/conf/sources/local-with-interval/delete_incomplete new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/local-with-interval/destination b/test/conf/sources/local-with-interval/destination new file mode 100644 index 0000000..4de7e06 --- /dev/null +++ b/test/conf/sources/local-with-interval/destination @@ -0,0 +1 @@ +/tmp/ccollect/backup-chint diff --git a/test/conf/sources/local-with-interval/exclude b/test/conf/sources/local-with-interval/exclude new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/test/conf/sources/local-with-interval/exclude @@ -0,0 +1 @@ +.git diff --git a/test/conf/sources/local-with-interval/intervals/daily b/test/conf/sources/local-with-interval/intervals/daily new file mode 100644 index 0000000..e440e5c --- /dev/null +++ b/test/conf/sources/local-with-interval/intervals/daily @@ -0,0 +1 @@ +3 \ No newline at end of file diff --git a/test/conf/sources/local-with-interval/source b/test/conf/sources/local-with-interval/source new file mode 100644 index 0000000..9e90576 --- /dev/null +++ b/test/conf/sources/local-with-interval/source @@ -0,0 +1 @@ +/tmp/ccollect/source diff --git a/test/conf/sources/local-with-interval/verbose b/test/conf/sources/local-with-interval/verbose new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/local/destination b/test/conf/sources/local/destination new file mode 100644 index 0000000..c2a7c55 --- /dev/null +++ b/test/conf/sources/local/destination @@ -0,0 +1 @@ +/tmp/ccollect/backup diff --git a/test/conf/sources/local/exclude b/test/conf/sources/local/exclude new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/test/conf/sources/local/exclude @@ -0,0 +1 @@ +.git diff --git a/test/conf/sources/local/no_verbose b/test/conf/sources/local/no_verbose new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/local/source b/test/conf/sources/local/source new file mode 100644 index 0000000..9e90576 --- /dev/null +++ b/test/conf/sources/local/source @@ -0,0 +1 @@ +/tmp/ccollect/source diff --git a/test/conf/sources/source with spaces and interval/delete_incomplete b/test/conf/sources/source with spaces and interval/delete_incomplete new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/source with spaces and interval/destination b/test/conf/sources/source with spaces and interval/destination new file mode 100644 index 0000000..c2a7c55 --- /dev/null +++ b/test/conf/sources/source with spaces and interval/destination @@ -0,0 +1 @@ +/tmp/ccollect/backup diff --git a/test/conf/sources/source with spaces and interval/exclude b/test/conf/sources/source with spaces and interval/exclude new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/test/conf/sources/source with spaces and interval/exclude @@ -0,0 +1 @@ +.git diff --git a/test/conf/sources/source with spaces and interval/source b/test/conf/sources/source with spaces and interval/source new file mode 100644 index 0000000..9e90576 --- /dev/null +++ b/test/conf/sources/source with spaces and interval/source @@ -0,0 +1 @@ +/tmp/ccollect/source diff --git a/test/conf/sources/source with spaces and interval/verbose b/test/conf/sources/source with spaces and interval/verbose new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/very_verbose/destination b/test/conf/sources/very_verbose/destination new file mode 100644 index 0000000..c2a7c55 --- /dev/null +++ b/test/conf/sources/very_verbose/destination @@ -0,0 +1 @@ +/tmp/ccollect/backup diff --git a/test/conf/sources/very_verbose/exclude b/test/conf/sources/very_verbose/exclude new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/test/conf/sources/very_verbose/exclude @@ -0,0 +1 @@ +.git diff --git a/test/conf/sources/very_verbose/source b/test/conf/sources/very_verbose/source new file mode 100644 index 0000000..9e90576 --- /dev/null +++ b/test/conf/sources/very_verbose/source @@ -0,0 +1 @@ +/tmp/ccollect/source diff --git a/test/conf/sources/very_verbose/summary b/test/conf/sources/very_verbose/summary new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/very_verbose/verbose b/test/conf/sources/very_verbose/verbose new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/very_verbose/very_verbose b/test/conf/sources/very_verbose/very_verbose new file mode 100644 index 0000000..e69de29 diff --git a/test/conf/sources/with_exec/destination b/test/conf/sources/with_exec/destination new file mode 100644 index 0000000..c2a7c55 --- /dev/null +++ b/test/conf/sources/with_exec/destination @@ -0,0 +1 @@ +/tmp/ccollect/backup diff --git a/test/conf/sources/with_exec/post_exec b/test/conf/sources/with_exec/post_exec new file mode 100755 index 0000000..abc0a40 --- /dev/null +++ b/test/conf/sources/with_exec/post_exec @@ -0,0 +1,5 @@ +#!/bin/cat + +###################################################################### +Source post_exec executed. +###################################################################### diff --git a/test/conf/sources/with_exec/pre_exec b/test/conf/sources/with_exec/pre_exec new file mode 100755 index 0000000..ba7b2af --- /dev/null +++ b/test/conf/sources/with_exec/pre_exec @@ -0,0 +1,5 @@ +#!/bin/cat + +###################################################################### +Source pre_exec executed. +###################################################################### diff --git a/test/conf/sources/with_exec/source b/test/conf/sources/with_exec/source new file mode 100644 index 0000000..9e90576 --- /dev/null +++ b/test/conf/sources/with_exec/source @@ -0,0 +1 @@ +/tmp/ccollect/source diff --git a/test/exec.sh b/test/exec.sh deleted file mode 100755 index bdf601d..0000000 --- a/test/exec.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -host="home.schottelius.org" -host="" -set -x -pcmd() -{ - echo "$#", "$@" - if [ "$host" ]; then - ssh "$host" "$@" - else - $@ - fi -} - -#pcmd ls / -#pcmd cd /; ls "/is not there" -pcmd cd / && ls diff --git a/test/local.sh b/test/local.sh deleted file mode 100755 index c2430fd..0000000 --- a/test/local.sh +++ /dev/null @@ -1 +0,0 @@ -CCOLLECT_CONF=./conf ./ccollect.sh daily -v local1 diff --git a/test/remote.sh b/test/remote.sh deleted file mode 100755 index 2af364e..0000000 --- a/test/remote.sh +++ /dev/null @@ -1 +0,0 @@ -CCOLLECT_CONF=./conf ./ccollect.sh daily -v remote1 diff --git a/test/return-value.sh b/test/return-value.sh deleted file mode 100755 index 554def0..0000000 --- a/test/return-value.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -ls /surely-not-existent$$ 2>/dev/null - -if [ "$?" -ne 0 ]; then - echo "$?" -fi - -ls /surely-not-existent$$ 2>/dev/null - -ret=$? - -if [ "$ret" -ne 0 ]; then - echo "$ret" -fi - -# if is true, ls is fales -if [ "foo" = "foo" ]; then - ls /surely-not-existent$$ 2>/dev/null -fi - -# but that's still the return of ls and not of fi -echo $? diff --git a/test/test-ccollect-tools.sh b/test/test-ccollect-tools.sh deleted file mode 100644 index 5980d04..0000000 --- a/test/test-ccollect-tools.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# -# 2009 Nico Schottelius (nico-ccollect at schottelius.org) -# -# This file is part of ccollect. -# -# ccollect is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# ccollect is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with ccollect. If not, see . -# -# -# Test the ccollect tools suite -# - -set -x - -tmp="$(mktemp /tmp/ccollect-tools.XXXXXXXXXXX)" - - -rm -rf "${tmp}" diff --git a/test/test-ccollect1.sh b/test/test-ccollect1.sh deleted file mode 100755 index c5acf54..0000000 --- a/test/test-ccollect1.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# -# Nico Schottelius -# Date: 27-Jan-2007 -# Last Modified: - -# Description: -# - -ccollect=../ccollect.sh -testdir="$(dirname $0)/test-backups" -confdir="$(dirname $0)/test-config" -source="$(hostname)" -source_source="/tmp" -interval="taeglich" - - -# backup destination -mkdir -p "$testdir" -source_dest="$(cd "$testdir"; pwd -P)" - -# configuration -mkdir -p "${confdir}/sources/${source}" -ln -s "$source_dest" "${confdir}/sources/${source}/destination" -echo "$source_source" > "${confdir}/sources/${source}/source" -touch "${confdir}/sources/${source}/summary" -touch "${confdir}/sources/${source}/verbose" - -mkdir -p "${confdir}/defaults/intervals/" -echo 3 > "${confdir}/defaults/intervals/$interval" - -# create backups - -CCOLLECT_CONF="$confdir" "$ccollect" "$interval" -p -a -touch "${source_source}/$(date +%s)-$$.1982" - -CCOLLECT_CONF="$confdir" "$ccollect" "$interval" -p -a -touch "${source_source}/$(date +%s)-$$.42" - -CCOLLECT_CONF="$confdir" "$ccollect" "$interval" -p -a - -du -sh "$testdir" -du -shl "$testdir" - -echo "Delete $testdir and $confdir after test" From 5ce3fddf6272cb443f37cde21512bce5eedf9d21 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 19 Nov 2019 18:25:10 +0100 Subject: [PATCH 560/581] Define gitlab CI --- .gitlab-ci.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..b499ddc --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,20 @@ +stages: + - test + +unit_tests: + stage: test + before_script: + - 'apk update' + - 'apk add make rsync' + script: + - make test + +shellcheck: + stage: test + before_script: + - 'apk update' + - 'apk add make' + - 'wget https://storage.googleapis.com/shellcheck/shellcheck-stable.linux.x86_64.tar.xz' + - 'tar xf shellcheck-stable.linux.x86_64.tar.xz && mv shellcheck-stable/shellcheck /usr/bin/' + script: + - make shellcheck From 9ed5912461dcd9b56836ad643d1cfc8b9ff95983 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 25 Nov 2019 08:42:42 +0100 Subject: [PATCH 561/581] Improve unit tests --- Makefile | 14 +++++++------- test/conf/defaults/post_exec | 6 ++---- test/conf/defaults/pre_exec | 6 ++---- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 9b9f3e5..ced0d28 100644 --- a/Makefile +++ b/Makefile @@ -224,26 +224,26 @@ test-dir-destination-chint: test-fixed-intervals: $(CCOLLECT_SOURCE) test-dir-source test-dir-destination test-dir-destination-chint for s in ./test/conf/sources/*; do \ CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily "$$(basename $$s)"; \ - test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0"; \ + test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0" || { cat ${TEST_LOG_FILE}; exit 1; }; \ done CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} -a -v daily - test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0" + test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0" || { cat ${TEST_LOG_FILE}; exit 1; } CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} -a -p daily - test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0" + test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0" || { cat ${TEST_LOG_FILE}; exit 1; } @printf "\nFixed intervals test ended successfully\n" test-interval-changing: $(CCOLLECT_SOURCE) test-dir-source test-dir-destination-chint rm -rf /tmp/ccollect/backup-chint/* - test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "0" + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "0" || { cat ${TEST_LOG_FILE}; exit 1; } printf "3" > ./test/conf/sources/local-with-interval/intervals/daily for x in 1 2 3 4 5; do CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily local-with-interval; done - test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "3" + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "3" || { cat ${TEST_LOG_FILE}; exit 1; } printf "5" > ./test/conf/sources/local-with-interval/intervals/daily for x in 1 2 3 4 5 6 7; do CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily local-with-interval; done - test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "5" + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "5" || { cat ${TEST_LOG_FILE}; exit 1; } printf "4" > ./test/conf/sources/local-with-interval/intervals/daily for x in 1 2 3 4 5 6; do CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily local-with-interval; done - test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "4" + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "4" || { cat ${TEST_LOG_FILE}; exit 1; } printf "3" > ./test/conf/sources/local-with-interval/intervals/daily @printf "\nInterval changing test ended successfully\n" diff --git a/test/conf/defaults/post_exec b/test/conf/defaults/post_exec index 8aee58f..0dac0ed 100755 --- a/test/conf/defaults/post_exec +++ b/test/conf/defaults/post_exec @@ -1,5 +1,3 @@ -#!/bin/cat +#!/bin/sh -###################################################################### -General post_exec executed. -###################################################################### +echo 'General post_exec executed.' diff --git a/test/conf/defaults/pre_exec b/test/conf/defaults/pre_exec index ecd2857..451fdad 100755 --- a/test/conf/defaults/pre_exec +++ b/test/conf/defaults/pre_exec @@ -1,5 +1,3 @@ -#!/bin/cat +#!/bin/sh -###################################################################### -General pre__exec executed. -###################################################################### +echo 'General pre__exec executed.' From 42bd1afb09ce17d84520ae2649c8af1dd91ced8b Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 25 Nov 2019 13:35:22 +0100 Subject: [PATCH 562/581] Fix quoting in tests --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ced0d28..52b7a56 100644 --- a/Makefile +++ b/Makefile @@ -223,7 +223,7 @@ test-dir-destination-chint: test-fixed-intervals: $(CCOLLECT_SOURCE) test-dir-source test-dir-destination test-dir-destination-chint for s in ./test/conf/sources/*; do \ - CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily "$$(basename $$s)"; \ + CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily "$$(basename '$$s')"; \ test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0" || { cat ${TEST_LOG_FILE}; exit 1; }; \ done CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} -a -v daily From 6c24e8a7d35fd7132d2f2b6bbe3977159cf3054b Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 25 Nov 2019 13:35:22 +0100 Subject: [PATCH 563/581] Fix quoting in tests --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 52b7a56..1e783fc 100644 --- a/Makefile +++ b/Makefile @@ -223,7 +223,7 @@ test-dir-destination-chint: test-fixed-intervals: $(CCOLLECT_SOURCE) test-dir-source test-dir-destination test-dir-destination-chint for s in ./test/conf/sources/*; do \ - CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily "$$(basename '$$s')"; \ + CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily "$$(basename "$$s")"; \ test "$$(ls -1 /tmp/ccollect/backup | wc -l)" -gt "0" || { cat ${TEST_LOG_FILE}; exit 1; }; \ done CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} -a -v daily From 61ab45fc651b9fafb6da4de208fe0a7d5769c447 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 25 Nov 2019 13:50:30 +0100 Subject: [PATCH 564/581] Fix excluding destination dir from removal Touch can lead to wrong ls order, and destination dir gets selected for removal. Use grep -v to exclude, instead of touch. --- ccollect | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ccollect b/ccollect index d89aec1..61e4ebd 100755 --- a/ccollect +++ b/ccollect @@ -767,20 +767,27 @@ while [ "${source_no}" -lt "${no_sources}" ]; do _techo "Using ${oldest_bak} for destination dir ${destination_dir}" if mv "${oldest_bak}" "${destination_dir}"; then # Touch dest dir so it is not sorted wrong in listings below. - touch "${destination_dir}" + ls_rm_exclude=$(basename "${destination_dir}") # We have something to remove only if count > interval. remove="$((count - c_interval))" else _techo_err "Renaming oldest backup ${oldest_bak} to ${destination_dir} failed, removing it." remove="$((count - c_interval + 1))" + ls_rm_exclude="" fi if [ "${remove}" -gt 0 ]; then _techo "Removing ${remove} backup(s)..." - # shellcheck disable=SC2010 - ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ - _exit_err "Listing old backups failed" + if [ -z "${ls_rm_exclude}" ]; then + # shellcheck disable=SC2010 + ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ + _exit_err "Listing old backups failed" + else + # shellcheck disable=SC2010 + ls -${TSORT}1r | grep -v "${ls_rm_exclude}" | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ + _exit_err "Listing old backups failed" + fi delete_from_file "${TMP}" & fi From 589fed6107e4cd0c719e523b81f1ae7ff5b55677 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 25 Nov 2019 14:41:41 +0100 Subject: [PATCH 565/581] ++changelog --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changes/next diff --git a/doc/changes/next b/doc/changes/next new file mode 100644 index 0000000..563b438 --- /dev/null +++ b/doc/changes/next @@ -0,0 +1 @@ +* Fix excluding destination dir from removal From 987277f1cf2d02f2c2e527c423f90becd0e0b4f9 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 25 Nov 2019 20:52:48 +0100 Subject: [PATCH 566/581] Update Makefile Simplify and generalize. --- Makefile | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 1e783fc..789e099 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ ASCIIDOC=asciidoc DOCBOOKTOTEXI=docbook2x-texi DOCBOOKTOMAN=docbook2x-man XSLTPROC=xsltproc -XSL=/usr/share/xml/docbook/stylesheet/nwalsh/html/docbook.xsl +XSL=/usr/local/share/xsl/docbook/html/docbook.xsl A2X=a2x prefix=/usr/packages/ccollect-git @@ -41,11 +41,7 @@ manlink=/usr/local/man/man1 path_dir=/usr/local/bin path_destination=${path_dir}/${CCOLLECT_DEST} - -# where to publish -host=localhost -dir=/home/users/nico/privat/rechner/netz/seiten/www.nico.schottelius.org/src/software/ccollect -docdir=${dir}/documentation +docs_archive_name=docs.tar # # Asciidoc will be used to generate other formats later @@ -91,6 +87,8 @@ all: @echo "info: only generate Texinfo" @echo "man: only generate manpage{s}" @echo "install: install ccollect to ${prefix}" + @echo "shellcheck: shellcheck ccollect script" + @echo "test: run unit tests" html: ${HTMLDOCS} htm: ${DBHTMLDOCS} @@ -179,9 +177,9 @@ pub: git push publish-doc: documentation - @echo "Transferring files to ${host}" @chmod a+r ${DOCS} ${DOC_ALL} - @tar c ${DOCS} ${DOC_ALL} | ssh ${host} "cd ${dir}; tar xv" + @tar cf ${docs_archive_name} ${DOCS} ${DOC_ALL} + @echo "Documentation files are in ${docs_archive_name}" # # Distribution From 5341de86fb331512dd442bbbcc8d68d20e6b06a5 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 26 Nov 2019 06:10:17 +0100 Subject: [PATCH 567/581] Release 2.8 --- ccollect | 4 ++-- doc/ccollect.text | 2 +- doc/changes/{next => 2.8} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename doc/changes/{next => 2.8} (100%) diff --git a/ccollect b/ccollect index 61e4ebd..39799cd 100755 --- a/ccollect +++ b/ccollect @@ -45,8 +45,8 @@ TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" export TMP CONTROL_PIPE="/tmp/${__myname}-control-pipe" -VERSION="2.7" -RELEASE="2019-11-14" +VERSION="2.8" +RELEASE="2019-11-26" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" diff --git a/doc/ccollect.text b/doc/ccollect.text index 2478265..84c326e 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -2.7, for ccollect 2.7, Initial Version from 2006-01-13 +2.8, for ccollect 2.8, Initial Version from 2006-01-13 :Author Initials: NS diff --git a/doc/changes/next b/doc/changes/2.8 similarity index 100% rename from doc/changes/next rename to doc/changes/2.8 From 109b70ea769755fbb576e3ee83af399fb5735e9e Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 2 Dec 2019 09:26:47 +0100 Subject: [PATCH 568/581] gitlab runner should have necessary tools --- .gitlab-ci.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b499ddc..5391f4d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,18 +3,10 @@ stages: unit_tests: stage: test - before_script: - - 'apk update' - - 'apk add make rsync' script: - make test shellcheck: stage: test - before_script: - - 'apk update' - - 'apk add make' - - 'wget https://storage.googleapis.com/shellcheck/shellcheck-stable.linux.x86_64.tar.xz' - - 'tar xf shellcheck-stable.linux.x86_64.tar.xz && mv shellcheck-stable/shellcheck /usr/bin/' script: - make shellcheck From a261ef841eb76595d169eef334b8f004a2d3737c Mon Sep 17 00:00:00 2001 From: Steffen Zieger Date: Sun, 24 May 2020 16:40:04 +0200 Subject: [PATCH 569/581] make rsync return code available in post_exec --- ccollect | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ccollect b/ccollect index 39799cd..679e3ca 100755 --- a/ccollect +++ b/ccollect @@ -824,6 +824,11 @@ while [ "${source_no}" -lt "${no_sources}" ]; do rsync "$@" "${source}" "${destination_dir}"; ret=$? _techo "Finished backup (rsync return code: $ret)." + # + # export rsync return code, might be useful in post_exec + # + export rsync_return_code=$ret + # # Set modification time (mtime) to current time, if sorting by mtime is enabled # From 28dec3694ae11b3924ba76c7de830183857d08bd Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 24 May 2020 17:29:29 +0200 Subject: [PATCH 570/581] ++changelog --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changes/next diff --git a/doc/changes/next b/doc/changes/next new file mode 100644 index 0000000..45097c7 --- /dev/null +++ b/doc/changes/next @@ -0,0 +1 @@ +* Make rsync return code available in post_exec (Steffen Zieger) From 7a7dec7751862ca1eec30f2041c80e40746766b3 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 25 May 2020 12:05:35 +0200 Subject: [PATCH 571/581] Release 2.9 --- ccollect | 4 ++-- doc/ccollect.text | 2 +- doc/changes/{next => 2.9} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename doc/changes/{next => 2.9} (100%) diff --git a/ccollect b/ccollect index 679e3ca..01c5d05 100755 --- a/ccollect +++ b/ccollect @@ -45,8 +45,8 @@ TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" export TMP CONTROL_PIPE="/tmp/${__myname}-control-pipe" -VERSION="2.8" -RELEASE="2019-11-26" +VERSION="2.9" +RELEASE="2020-05-25" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" diff --git a/doc/ccollect.text b/doc/ccollect.text index 84c326e..bc8326a 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -2.8, for ccollect 2.8, Initial Version from 2006-01-13 +2.9, for ccollect 2.9, Initial Version from 2006-01-13 :Author Initials: NS diff --git a/doc/changes/next b/doc/changes/2.9 similarity index 100% rename from doc/changes/next rename to doc/changes/2.9 From 616b1d9e3e9cf996e1f90bfc8ede58143ed0e7e7 Mon Sep 17 00:00:00 2001 From: Steffen Zieger Date: Mon, 25 May 2020 16:16:32 +0200 Subject: [PATCH 572/581] Add 'current' symlink to backup destinations --- ccollect | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ccollect b/ccollect index 01c5d05..b4af2f1 100755 --- a/ccollect +++ b/ccollect @@ -861,6 +861,16 @@ while [ "${source_no}" -lt "${no_sources}" ]; do _techo "Warning: rsync failed with return code $ret." fi + # + # Create symlink to newest backup + # + # shellcheck disable=SC2010 + latest_dir="$(ls -${TSORT}p1 "${ddir}" | grep '/$' | head -n 1)" || \ + _exit_err "Failed to list content of ${ddir}." + + ln -snf "${ddir}${latest_dir}" "${ddir}current" || \ + _exit_err "Failed to create 'current' symlink." + # # post_exec # From 309d8dc773182a053619a93bc099f88f087b4c0e Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 25 May 2020 17:52:23 +0200 Subject: [PATCH 573/581] ++changelog --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changes/next diff --git a/doc/changes/next b/doc/changes/next new file mode 100644 index 0000000..1d1e85d --- /dev/null +++ b/doc/changes/next @@ -0,0 +1 @@ +* Add 'current' symlink to backup destinations (Steffen Zieger) From 08cb857664a6dbcbacaffc020c747db554ebbf15 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 26 Aug 2020 08:36:43 +0200 Subject: [PATCH 574/581] Release 2.10 --- ccollect | 4 ++-- doc/ccollect.text | 2 +- doc/changes/{next => 2.10} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename doc/changes/{next => 2.10} (100%) diff --git a/ccollect b/ccollect index b4af2f1..2deaa2d 100755 --- a/ccollect +++ b/ccollect @@ -45,8 +45,8 @@ TMP="$(mktemp "/tmp/${__myname}.XXXXXX")" export TMP CONTROL_PIPE="/tmp/${__myname}-control-pipe" -VERSION="2.9" -RELEASE="2020-05-25" +VERSION="2.10" +RELEASE="2020-08-26" HALF_VERSION="ccollect ${VERSION}" FULL_VERSION="ccollect ${VERSION} (${RELEASE})" diff --git a/doc/ccollect.text b/doc/ccollect.text index bc8326a..f075b9a 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -1,7 +1,7 @@ ccollect - Installing, Configuring and Using ============================================ Nico Schottelius -2.9, for ccollect 2.9, Initial Version from 2006-01-13 +2.10, for ccollect 2.10, Initial Version from 2006-01-13 :Author Initials: NS diff --git a/doc/changes/next b/doc/changes/2.10 similarity index 100% rename from doc/changes/next rename to doc/changes/2.10 From 2ca7598593befc52bff6b51b330bbcf508e20387 Mon Sep 17 00:00:00 2001 From: Jun Futagawa Date: Wed, 25 Nov 2020 11:24:37 +0900 Subject: [PATCH 575/581] Improve 'current' symlink to backup destinations --- ccollect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccollect b/ccollect index 2deaa2d..8b8f9e5 100755 --- a/ccollect +++ b/ccollect @@ -868,7 +868,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do latest_dir="$(ls -${TSORT}p1 "${ddir}" | grep '/$' | head -n 1)" || \ _exit_err "Failed to list content of ${ddir}." - ln -snf "${ddir}${latest_dir}" "${ddir}current" || \ + ln -snf "${ddir}/${latest_dir}" "${ddir}/current" || \ _exit_err "Failed to create 'current' symlink." # From 7d298d2b51f30f95407e2bdfc8e4e04fb14f66e2 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 25 Nov 2020 16:17:29 +0100 Subject: [PATCH 576/581] ++changelog --- doc/changes/next | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changes/next diff --git a/doc/changes/next b/doc/changes/next new file mode 100644 index 0000000..81efe7b --- /dev/null +++ b/doc/changes/next @@ -0,0 +1 @@ +* Fix 'current' symlink (Jun Futagawa) From 40dbfbd3a38b2064b095bea621600be1637dbd2d Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 25 Nov 2020 16:20:28 +0100 Subject: [PATCH 577/581] Fix test: also count 'current' symlink --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 789e099..cda6d81 100644 --- a/Makefile +++ b/Makefile @@ -235,13 +235,13 @@ test-interval-changing: $(CCOLLECT_SOURCE) test-dir-source test-dir-destination- test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "0" || { cat ${TEST_LOG_FILE}; exit 1; } printf "3" > ./test/conf/sources/local-with-interval/intervals/daily for x in 1 2 3 4 5; do CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily local-with-interval; done - test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "3" || { cat ${TEST_LOG_FILE}; exit 1; } + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "4" || { cat ${TEST_LOG_FILE}; exit 1; } printf "5" > ./test/conf/sources/local-with-interval/intervals/daily for x in 1 2 3 4 5 6 7; do CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily local-with-interval; done - test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "5" || { cat ${TEST_LOG_FILE}; exit 1; } + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "6" || { cat ${TEST_LOG_FILE}; exit 1; } printf "4" > ./test/conf/sources/local-with-interval/intervals/daily for x in 1 2 3 4 5 6; do CCOLLECT_CONF=./test/conf ./ccollect -l ${TEST_LOG_FILE} daily local-with-interval; done - test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "4" || { cat ${TEST_LOG_FILE}; exit 1; } + test "$$(ls -1 /tmp/ccollect/backup-chint | wc -l)" -eq "5" || { cat ${TEST_LOG_FILE}; exit 1; } printf "3" > ./test/conf/sources/local-with-interval/intervals/daily @printf "\nInterval changing test ended successfully\n" From b50b3f64dc86182f93c348b4ff9d286d70bc7d28 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 25 Nov 2020 16:21:44 +0100 Subject: [PATCH 578/581] Update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e5c18f6..6a82cbe 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ doc/*.xml doc/*/*.xml *.texi *.fo +*.lock From cdd34a3416cd5c70c0334329eb6c0204f7c643bd Mon Sep 17 00:00:00 2001 From: skybeam Date: Sat, 14 Jan 2023 21:57:24 +0000 Subject: [PATCH 579/581] Allow interval per source to be overwritten to 0 to skip the source in this interval. This change allows to overwrite an interval to 0 for a specific source in order to skip it for this interval. This is useful if you have default intervals configured and you would like to skip certain sources for specific intervals. --- ccollect | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ccollect b/ccollect index 8b8f9e5..5aaefe2 100755 --- a/ccollect +++ b/ccollect @@ -765,7 +765,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do oldest_bak=$(ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n 1 || \ _exit_err "Listing oldest backup failed") _techo "Using ${oldest_bak} for destination dir ${destination_dir}" - if mv "${oldest_bak}" "${destination_dir}"; then + if mv "${oldest_bak}" "${destination_dir}" 2>/dev/null; then # Touch dest dir so it is not sorted wrong in listings below. ls_rm_exclude=$(basename "${destination_dir}") @@ -779,7 +779,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do if [ "${remove}" -gt 0 ]; then _techo "Removing ${remove} backup(s)..." - if [ -z "${ls_rm_exclude}" ]; then + if [ -z "${ls_rm_exclude}" -o ${c_interval} -le 0 ]; then # shellcheck disable=SC2010 ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ _exit_err "Listing old backups failed" @@ -793,6 +793,14 @@ while [ "${source_no}" -lt "${no_sources}" ]; do fi fi + # + # Skip backup of this source if interval is zero. + # + if [ ${c_interval} -le 0 ]; then + _techo "Skipping backup for this interval." + exit 0 + fi + # # Check for backup directory to clone from: Always clone from the latest one! # Exclude destination_dir from listing, it can be touched reused and renamed From ebded3049a9081769f05e67a5f6802adf906e6ac Mon Sep 17 00:00:00 2001 From: skybeam Date: Sun, 15 Jan 2023 22:31:02 +0000 Subject: [PATCH 580/581] Update 'ccollect' --- ccollect | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccollect b/ccollect index 5aaefe2..86acec5 100755 --- a/ccollect +++ b/ccollect @@ -779,7 +779,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do if [ "${remove}" -gt 0 ]; then _techo "Removing ${remove} backup(s)..." - if [ -z "${ls_rm_exclude}" -o ${c_interval} -le 0 ]; then + if [ -z "${ls_rm_exclude}" -o ${c_interval} -eq 0 ]; then # shellcheck disable=SC2010 ls -${TSORT}1r | grep "^${INTERVAL}\\." | head -n "${remove}" > "${TMP}" || \ _exit_err "Listing old backups failed" @@ -796,7 +796,7 @@ while [ "${source_no}" -lt "${no_sources}" ]; do # # Skip backup of this source if interval is zero. # - if [ ${c_interval} -le 0 ]; then + if [ ${c_interval} -eq 0 ]; then _techo "Skipping backup for this interval." exit 0 fi From 1cc921ad8630cf9d7bbefd2281e6853c1454d501 Mon Sep 17 00:00:00 2001 From: skybeam Date: Sun, 15 Jan 2023 23:32:27 +0000 Subject: [PATCH 581/581] Interval value of 0 to skip interval for speicific sources. Update documentation to specify that intervals with value 0 are valid to skip an interval explicitly for a given source. --- doc/ccollect.text | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/ccollect.text b/doc/ccollect.text index f075b9a..6aee365 100644 --- a/doc/ccollect.text +++ b/doc/ccollect.text @@ -339,6 +339,9 @@ Example: -------------------------------------------------------------------------------- This means to keep 28 daily backups, 12 monthly backups and 4 weekly. +If you set a value of 0 the interval will be skipped. This is useful mainly on +source level in order to skip a certain interval for a specific source. + General pre- and post-execution ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -420,6 +423,12 @@ Example: /home/nico/vpn -------------------------------------------------------------------------------- +You can overwrite a default interval at source level. Setting it to 0 will skip +this interval on a specific source allowing you to skip an interval for a +specific source only while keeping source-specific interval amounts (or default +values) for any other source. + + Default options ^^^^^^^^^^^^^^^ If you add '$CCOLLECT_CONF/defaults/`option_name`', the value will