]> git.sesse.net Git - backup.sh/commitdiff
Now implements locking and catch of SIGINT and SIGTERM
authorroot <empty>
Thu, 26 Jul 2007 02:22:12 +0000 (02:22 +0000)
committerroot <empty>
Thu, 26 Jul 2007 02:22:12 +0000 (02:22 +0000)
backup.sh

index ed089e58c866b9bcdff7bf30139a557444e13bd0..0a4cb4ac2a61e7869b115fe1777974f3bd40f201 100755 (executable)
--- a/backup.sh
+++ b/backup.sh
@@ -1,5 +1,22 @@
 #!/bin/sh
 
+# Locking
+LOCKFILE=/home/backup/backuprun.lockfile
+
+# Die gracefully (ie. remove lockfile)
+die() {
+       rm $LOCKFILE
+       exit 255
+}
+
+trap die SIGINT SIGTERM
+
+if [ -e $LOCKFILE ]; then
+       echo `date`": $LOCKFILE exists, exiting."
+       exit 1
+fi;
+touch $LOCKFILE
+
 #dirs
 confdir=/home/backup/conf/           #configuration files
 storagedir=/backup                   #mountpoint of huge disc
@@ -200,7 +217,7 @@ do
  
   #gå ned i rett katalog, eller dø 
   # TODO bør sende mail om dette skjer!
-  cd $storagedir/$computer/$sfilesystem/$backuplevel || exit 1
+  cd $storagedir/$computer/$sfilesystem/$backuplevel || die
 
   #perform the actual backup
   backup
@@ -239,14 +256,9 @@ done &
 
 wait
 
-#create report
-# (Hasn't been working for years -berge)
-#/home/backup/report.sh $storagedir > /tmp/report.txt
-#[ ! -z $remotestat ] && scp /tmp/report.txt $remotestat
-###
-
 # print diskusage to logfile
 echo "Current disk usage:"
-df -k
+df -k $storagedir
 
 echo `date`": Backup run ended"
+