From 26208191cbd7c6ec3f79f9cfd863b78d323eaacf Mon Sep 17 00:00:00 2001 From: Alan Jack Pippin Date: Thu, 1 Dec 2005 20:56:10 -0700 Subject: [PATCH] Added available disk space check & new backupeveryXdays config var. --- scripts/config.sh | 1 + scripts/cron-pack.sh | 3 +-- scripts/pack-image.sh | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/config.sh b/scripts/config.sh index ff58479..c676f09 100755 --- a/scripts/config.sh +++ b/scripts/config.sh @@ -11,6 +11,7 @@ lastbackupfile="$imagedir/lastbackup" dev="/dev/dvdrw" sdev="ATA:1,0,0" noburnfile="$imagedir/noburn" +backupeveryXdays=15 # These are exported so lsbackups can have access to them export backupdbin="$datadir/backups.db" diff --git a/scripts/cron-pack.sh b/scripts/cron-pack.sh index 906b010..f34489a 100755 --- a/scripts/cron-pack.sh +++ b/scripts/cron-pack.sh @@ -8,8 +8,7 @@ export PATH=$(dirname $0):/bin:/usr/bin:/sbin # source the system specific configuration [ -f /etc/lsbackups.conf ] && . /etc/lsbackups.conf -days=15 -minutes=$(($days * 1440 - 60)) +minutes=$(($backupeveryXdays * 1440 - 60)) if [ -n "$(find $lastbackupfile -mmin +$minutes)" -o -n "$(cat $statusfile | grep -i incomplete)" ]; then echo "Running backups from cron..." diff --git a/scripts/pack-image.sh b/scripts/pack-image.sh index 2bdb75e..ce985fa 100755 --- a/scripts/pack-image.sh +++ b/scripts/pack-image.sh @@ -22,6 +22,11 @@ isoimage="$imagedir/$today.iso" isomountdir="$isoimage.mnt" restorescript="$scriptsdir/restore.sh" +echo "-> Checking for available disk space on $imagedir" +available=$(df $imagedir | awk '{print$4}' | grep -E "[0-9]+") +required=$((imagesizemb*1024)) +[ $required -gt $available ] && err "Not enough space for the backup image on $imagedir" + echo "-> Creating directories" mkdir --mode=700 -p $datadir $imagedir $isomountdir $tmpdir if [ $? != 0 ]; then -- 2.34.1