Create cron.sh for running from cron also create config.sh
authorCarl N. Baldwin <cnb@Cone.local>
Sat, 29 Oct 2005 18:45:44 +0000 (12:45 -0600)
committerCarl N. Baldwin <cnb@Cone.local>
Sat, 29 Oct 2005 18:45:44 +0000 (12:45 -0600)
scripts/Makefile.am
scripts/burn-imgs.sh
scripts/config.sh [new file with mode: 0755]
scripts/cron.sh [new file with mode: 0755]
scripts/pack-image.sh

index eea43a0e52552fd5eea29f013085b63364a01b36..391c6a7fa94c64ee836a16df34483f04a1e955b8 100644 (file)
@@ -1,7 +1,9 @@
 bin_SCRIPTS = \
-       pack-image.sh \
+       config.sh \
+       cron.sh \
        files-from-date.sh \
        list-dates.sh \
+       pack-image.sh \
        restore-script.sh \
        restore.sh
 
index a6a5ba9db6ad6fce932bcaa47e0cd3982aa8b750..8439a9b4252a80915597e17a0da54e4c439c4985 100755 (executable)
@@ -1,11 +1,8 @@
 #!/bin/sh
 
-PATH=/bin:/usr/bin
+PATH=$(dirname $0):/bin:/usr/bin
 
-mailto=carl@ecbaldwin.net
-dev="/dev/hdc"
-sdev="ATA:1,0,0"
-imagedir="/backup/imgs"
+. config.sh
 
 # Discover disk images by looking for .img.md5sum files in $imagedir
 imgmd5=$(ls $imagedir/*.img.md5sum | head -n 1)
diff --git a/scripts/config.sh b/scripts/config.sh
new file mode 100755 (executable)
index 0000000..26463ae
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/echo This file should be sourced .
+
+mailto='carl@ecbaldwin.net'
+datadir="/var/lib/backups"
+tmpdir="/dev/shm/backups"
+currentfiles="$tmpdir/files.db"
+backupdb="$datadir/backups.db"
+backups="$tmpdir/backup-list.db"
+statusfile="$tmpdir/backup-status.txt"
+imagedir="/backup/imgs"
+lastbackupfile="$imagedir/lastbackup"
+dev="/dev/hdc"
+sdev="ATA:1,0,0"
+
+backupdirs="
+/etc
+/home
+/var/backups
+/var/lib/debfoster
+/var/lib/dpkg
+/var/lib/ip6tables
+/var/lib/iptables
+/var/lib/mailman
+"
diff --git a/scripts/cron.sh b/scripts/cron.sh
new file mode 100755 (executable)
index 0000000..b4bf021
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+export PATH=$(dirname $0):/bin:/usr/bin
+
+. config.sh
+
+if [ -n "$(find $lastbackupfile -mtime +14)" ]; then
+  echo "Running backups from cron..."
+  exec pack-image.sh
+fi
+
+echo "Not running backups today.  Backups were last run on $(<$lastbackupfile)"
index 918ac43c81f777bb3b93b190a7a6d5912a9f9177..60e6c50ca3370dd0037d65aa7066a4822528847a 100755 (executable)
@@ -4,17 +4,10 @@ scriptsdir=$(dirname $0)
 
 export PATH=$scriptsdir:$PATH
 
+. config.sh
+
 # file locations and other values
 today=$(date +%Y%m%d%H%M%S)
-mailto='carl@ecbaldwin.net'
-datadir="/var/lib/backups"
-backupdirs="/home /etc /var/backups /var/lib/debfoster /var/lib/mailman /var/lib/iptables /var/lib/ip6tables /var/lib/dpkg"
-tmpdir="/dev/shm/backups"
-currentfiles="$tmpdir/files.db"
-backupdb="$datadir/backups.db"
-backups="$tmpdir/backup-list.db"
-statusfile="$tmpdir/backup-status.txt"
-imagedir="/backup/imgs"
 isoimage="$imagedir/$today.img"
 isomountdir="$isoimage.mnt"
 restorescript="$scriptsdir/restore.sh"
@@ -58,3 +51,5 @@ echo "Calculating md5sum for image"
 md5sum $isoimage | awk '{print$1}' > $isoimage.md5sum
 
 cat $statusfile | mailx -s "DVD image available to burn - $today" $mailto
+
+echo $today > $lastbackupfile