From 18ca258203f2ef6f669dbcdf687038947eab3791 Mon Sep 17 00:00:00 2001 From: Alan Jack Pippin Date: Sun, 20 Nov 2005 20:35:00 -0700 Subject: [PATCH] 1) Modified main.cpp to save backup db to a tmp file. 2) Modified pack-image.sh to move tmp backup db over the existing backup db once it is determined that there have not been any errors during the backup process. 3) Fixed bug in pack-image.sh related to handling excludedirs properly. --- .gitignore | 1 + main.cpp | 2 +- scripts/pack-image.sh | 10 +++++----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 3201815..c72ba0b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ configure depcomp install-sh missing +install diff --git a/main.cpp b/main.cpp index 2dd8048..81b3b2c 100644 --- a/main.cpp +++ b/main.cpp @@ -10,7 +10,7 @@ using namespace std; static const unsigned int bytes_in_block = 0x800; -static const char * dbname = "/var/lib/backups/backups.db"; +static const char * dbname = "/var/lib/backups/backups.db.tmp"; unsigned long long read_time( istream &i ) { string date_string; diff --git a/scripts/pack-image.sh b/scripts/pack-image.sh index 9a06f71..4f9c828 100755 --- a/scripts/pack-image.sh +++ b/scripts/pack-image.sh @@ -57,13 +57,12 @@ echo "-> Running find to get the status of files" { for type in d f l; do findformat="$type %#m %u %g %s %CY%Cm%Cd%CH%CM%CS 0 %p\0" - if [ -z $excludeddirs ] + if [ -z $excludedirs ] then find $backupdirs -type $type -printf "$findformat" else - regex=`echo $excludedirs | sed -e 's/ /.*\\\\|/g'` - regex=`echo "'\($regex.*\)'"` - find $backupdirs -type $type -o -regex $regex -prune -o -printf "$findformat" + echo $excludedirs | sed -e 's/ /\n/g' > $tmpdir/excluded + find $backupdirs -type $type -printf "$findformat" | grep -z -v -f $tmpdir/excluded fi done } > $currentfiles @@ -81,11 +80,12 @@ cat $backups | rsync $rsyncopts / $isomountdir if [ $? != 0 ] then umount $isomountdir - rm -rf $isomountdir $isoimage + rm -rf $isomountdir $isoimage $backupdb.tmp err "Unable to rsync to pack the image" fi echo "-> Copying over database and status file" +mv $backupdb.tmp $backupdb cp $statusfile $backupdb $restorescript $isomountdir [ $? != 0 ] && err "Unable to copy the database and status file" -- 2.34.1