From: Carl N. Baldwin <cnb@Cone.local>
Date: Sat, 29 Oct 2005 18:45:44 +0000 (-0600)
Subject: Create cron.sh for running from cron also create config.sh
X-Git-Tag: release-0.4~43
X-Git-Url: http://git.pippins.net/checkmark.gif?a=commitdiff_plain;h=d8f9460417bda64c8204c87b318b3432ad4a90a3;p=backups%2F.git

Create cron.sh for running from cron also create config.sh
---

diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index eea43a0..391c6a7 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -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
 
diff --git a/scripts/burn-imgs.sh b/scripts/burn-imgs.sh
index a6a5ba9..8439a9b 100755
--- a/scripts/burn-imgs.sh
+++ b/scripts/burn-imgs.sh
@@ -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
index 0000000..26463ae
--- /dev/null
+++ b/scripts/config.sh
@@ -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
index 0000000..b4bf021
--- /dev/null
+++ b/scripts/cron.sh
@@ -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)"
diff --git a/scripts/pack-image.sh b/scripts/pack-image.sh
index 918ac43..60e6c50 100755
--- a/scripts/pack-image.sh
+++ b/scripts/pack-image.sh
@@ -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