]> git.sesse.net Git - backup.sh/blobdiff - backup.sh
Fix outdated comment.
[backup.sh] / backup.sh
index b672257073f722e6d80693eb8b45d8e28d9a9102..780a2d76ccd282cf837d4ffe45eaf824230298de 100755 (executable)
--- a/backup.sh
+++ b/backup.sh
@@ -31,7 +31,6 @@
 # o $R has no proper meaning because of the forking subshell stuff. We need a
 #   more robust way of returning non-zero on errors, which we probably don't
 #   right now.
-# o The code around line 211 and downwards is messy.
 #
 
 # Configuration
@@ -63,12 +62,12 @@ trap die SIGINT SIGTERM
 
 # Don't start if we're already running
 if [ -e $LOCKFILE ]; then
-       echo `date`": $LOCKFILE exists, exiting."
-       echo `date`": $LOCKFILE exists, exiting." >&2
+       echo `date`": $LOCKFILE exists for pid `cat $LOCKFILE`, exiting."
+       echo `date`": $LOCKFILE exists for pid `cat $LOCKFILE`, exiting." >&2
        exit 1
 fi;
 touch $LOCKFILE
-echo "$$" > $LOCKFILE
+echo $$ > $LOCKFILE
 
 #syntax of remotestat:
 #hostname:/directory/
@@ -148,7 +147,7 @@ backup()
   echo $DATEs > ../.date && touch -t $DATE ../.date
 
   # Make a sorted filelist as well
-  sort -k6 < $DATE.sdx > $DATE.sdx
+  sort -k6 < $DATE.idx > $DATE.sdx
 
   # Fix permissions
   chmod 600 *tgz                      #only for us
@@ -213,21 +212,20 @@ do
  fi
 
  # Try to copy preeexec and postexec if they exist
-# TODO: Gah, clean this mess!
- [ -f $confdir/preexec.$computer ] && (
-    scp $confdir/preexec.$computer  root@$computer:~/.backup/preexec >&2 ||
-     ( echo `date`" $computer: Could not copy preexec.$computer to $computer:~/.backup/preexec - skipping backup of $computer"
-       R=1
-       continue
-     )
-    )
- [ -f $confdir/postexec.$computer ] && (
-    scp $confdir/postexec.$computer root@$computer:~/.backup/postexec >&2 ||
-     ( echo `date`" $computer: Could not copy postexec.$computer to $computer:~/.backup/postexec - skipping backup of $computer"
-       R=1
-       continue
-     )
-    )
+ if [ -f $confdir/preexec.$computer ]; then
+   if ! scp $confdir/preexec.$computer  root@$computer:~/.backup/preexec >&2; then
+     echo `date`" $computer: Could not copy preexec.$computer to $computer:~/.backup/preexec - skipping backup of $computer"
+     R=1
+     continue
+   fi
+ fi
+ if [ -f $confdir/postexec.$computer ]; then
+   if ! scp $confdir/postexec.$computer root@$computer:~/.backup/postexec >&2; then
+     echo `date`" $computer: Could not copy postexec.$computer to $computer:~/.backup/postexec - skipping backup of $computer"
+     R=1
+     continue
+   fi
+ fi
 
  # Try to run preexec if it exist
  if ! ssh root@$computer "[ ! -f ~/.backup/preexec ] || /bin/bash -x ~/.backup/preexec" >&2; then