From: Alan Jack Pippin Date: Mon, 21 Nov 2005 03:35:00 +0000 (-0700) Subject: 1) Modified main.cpp to save backup db to a tmp file. X-Git-Tag: release-0.4~14^2~1 X-Git-Url: http://git.pippins.net/embedvideo/.git/%27%20%20%20%20.%20%24GLOBALS%5B%27phpgw%27%5D-%3Elink%28%27inc/jquery/static/.%24link.?a=commitdiff_plain;h=18ca258203f2ef6f669dbcdf687038947eab3791;p=backups%2F.git 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. --- 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"