]> git.sesse.net Git - backup.sh/blobdiff - backup.sh
More if/then consistency fixes.
[backup.sh] / backup.sh
index 48307bc92ad3b81c994b3aa3b6d3920019b216be..b17ad65dffec7564860599e1f3c4e93614f85211 100755 (executable)
--- a/backup.sh
+++ b/backup.sh
@@ -77,8 +77,7 @@ backup()
 
        SNARFILE="${storagedir}/${computer}/${sfilesystem}/.incremental.snar"
        incrementalsnar="/root/.backup/${sfilesystem}.snar"
-       if [ "$backuplevel" = "daglig" ]
-       then
+       if [ "$backuplevel" = "daglig" ]; then
                # If incremental backup, we need to copy the incremental status to $computer.
                # If it does not exist, whine a bit and then run date-based instead.
                if [ -s "$SNARFILE" ]; then
@@ -123,7 +122,9 @@ backup()
 
                # Move tar file in place
                mv $TARFILE $DATE.tgz
-               mv $SNARFILE.tmp $SNARFILE
+               if [ "$incrementalsnar" ]; then
+                       mv $SNARFILE.tmp $SNARFILE
+               fi
 
                # Update timestamp
                echo $DATEs > ../.date && touch -t $DATE ../.date
@@ -215,11 +216,9 @@ for filesystem in $filesystems; do
        # Default backuplevel
        backuplevel=daglig
 
-       if [ ! -f $storagedir/$computer/$sfilesystem/.date ]
-       then
+       if [ ! -s $storagedir/$computer/$sfilesystem/.date ]; then
                # Take the first full backup of this filesystem on this computer
                backuplevel=full
-               echo $DATEs > $storagedir/$computer/$sfilesystem/.date
        fi
 
        # Check if we want a full backup
@@ -242,7 +241,7 @@ for filesystem in $filesystems; do
        fi
 
        # We want to be here
-       cd $storagedir/$computer/$sfilesystem/$backuplevelmsg || die "$storagedir/$computer/$sfilesystem/$backuplevel does not exist"
+       cd $storagedir/$computer/$sfilesystem/$backuplevel || diemsg "$storagedir/$computer/$sfilesystem/$backuplevel does not exist"
 
        # Perform the actual backup
        backup
@@ -277,6 +276,9 @@ done
 if ! ssh root@$computer "[ ! -f /root/.backup/postexec ] || /bin/bash -x /root/.backup/postexec" >&2; then
        diemsg "Could not run $computer:/root/.backup/postexec"
 fi
+       
+echo `date`": $computer: Backup completed successfully."
+echo `date`": $computer: Backup completed successfully." >&2
 
 # Remove lockfile
 rm $LOCKFILE