From d8f9460417bda64c8204c87b318b3432ad4a90a3 Mon Sep 17 00:00:00 2001 From: "Carl N. Baldwin" Date: Sat, 29 Oct 2005 12:45:44 -0600 Subject: [PATCH] Create cron.sh for running from cron also create config.sh --- scripts/Makefile.am | 4 +++- scripts/burn-imgs.sh | 7 ++----- scripts/config.sh | 24 ++++++++++++++++++++++++ scripts/cron.sh | 12 ++++++++++++ scripts/pack-image.sh | 13 ++++--------- 5 files changed, 45 insertions(+), 15 deletions(-) create mode 100755 scripts/config.sh create mode 100755 scripts/cron.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 -- 2.34.1