From c027e80dd5f2ac433fefeb76dabc4a3f7aed988b Mon Sep 17 00:00:00 2001 From: root Date: Thu, 26 Jul 2007 02:22:12 +0000 Subject: [PATCH] Now implements locking and catch of SIGINT and SIGTERM --- backup.sh | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/backup.sh b/backup.sh index ed089e5..0a4cb4a 100755 --- 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" + -- 2.39.2