]> git.sesse.net Git - backup.sh/blobdiff - backup.sh
Kill the sdx files; they are not very useful.
[backup.sh] / backup.sh
index 961c0c2ea88c7ae391a3a3d1e8936576ca9ecd9b..7a273182b3186b55e4af03e2c8c15980d602e96a 100755 (executable)
--- a/backup.sh
+++ b/backup.sh
@@ -76,26 +76,29 @@ umask 027
 
 backup()
 {
-       infomsg "$computer:$filesystem $backuplevel backup\n"
+       infomsg "$computer:$filesystem $backuplevel backup"
 
-       SNARFILE="${storagedir}/${computer}/${sfilesystem}/.incremental.snar"
-       incrementalsnar="/root/.backup/${sfilesystem}.snar"
+       localsnar="${storagedir}/${computer}/${sfilesystem}/.incremental.snar"
+       remotesnar="/root/.backup/${sfilesystem}.snar"
        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
-                       if ! scp $SNARFILE root@$computer:$incrementalsnar; then
+               if [ -s "$localsnar" ]; then
+                       if ! scp $localsnar root@$computer:$remotesnar; then
                                diemsg "Could not copy .incremental.snar to $computer"
                        fi
-                       lastcmd="--listed-incremental=$incrementalsnar --no-check-device"
+                       lastcmd="--listed-incremental=$remotesnar --no-check-device"
                else
                        infomsg "Missing incremental.snar for $filesystem, doing date-based backup instead until next full backup"
-                       incrementalsnar=""
+                       remotesnar=""
                        lastd=`cat ../.date`
                        lastcmd="--newer='$lastd'"
                fi
        else
-               lastcmd="--listed-incremental=$incrementalsnar"
+               # Note: Since we rm-ed .backup previously, and we don't scp over
+               # anything in this branch, this file will not exist, and we
+               # will be doing a full backup (but we want the output of it).
+               lastcmd="--listed-incremental=$remotesnar"
        fi
 
        # We try to run tar on the remote computer
@@ -117,27 +120,24 @@ backup()
        if [ $? -eq 0 ] && [ -s $TARFILE ]; then
                # File is >0 in size and neither cat or tar tzvf failed; we assume it worked.
  
-               if [ "$incrementalsnar" ]; then
-                       if ! scp root@$computer:$incrementalsnar $SNARFILE.tmp; then
+               if [ "$remotesnar" ]; then
+                       if ! scp root@$computer:$remotesnar $localsnar.tmp; then
                                diemsg "Could not copy .incremental.snar from $computer"
                        fi
                fi
 
                # Move tar file in place
                mv $TARFILE $DATE.tgz
-               if [ "$incrementalsnar" ]; then
-                       mv $SNARFILE.tmp $SNARFILE
+               if [ "$remotesnar" ]; then
+                       mv $localsnar.tmp $localsnar
                fi
 
                # Update timestamp
                echo $DATEs > ../.date && touch -t $DATE ../.date
 
-               # Make a sorted file list as well
-               sort -k6 < $DATE.idx > $DATE.sdx
-
                # Fix permissions
                chmod 600 *tgz                      #only for us
-               chmod 644 *sdx *idx 2>/dev/null     #everyone can read
+               chmod 644 *idx 2>/dev/null          #everyone can read
 
                # Let the remote computer know that we ran a successful backup (for nagios)
                ssh root@$computer touch $filesystem/.lastbackup
@@ -281,7 +281,7 @@ if ! ssh root@$computer "[ ! -f /root/.backup/postexec ] || /bin/bash -x /root/.
 fi
 
 # Use warn so that we will get an email even on success.
-warnmsg "$computer: Backup completed successfully."
+warnmsg "Backup completed successfully."
 
 # Remove lockfile
 rm $LOCKFILE