From: Steinar H. Gunderson Date: Tue, 7 Oct 2014 21:36:31 +0000 (+0200) Subject: Make it possible to have the script use other directories than /home/backup and ... X-Git-Url: https://git.sesse.net/?p=backup.sh;a=commitdiff_plain;h=96d828931f444f6548a54fb379ebb64fe1830c1b Make it possible to have the script use other directories than /home/backup and /backup. --- diff --git a/backup.sh b/backup.sh index 55bad7c..29ffa1f 100755 --- a/backup.sh +++ b/backup.sh @@ -18,30 +18,35 @@ # The script is halfway Norwegian and halfway English. Newer modifications are # in English, we should probably stick to that. -# The computer to backup. -computer=$1 - -# Configuration -LOCKFILE=/home/backup/backuprun.lockfile.$computer -confdir=/home/backup/conf/ # Configuration files -storagedir=/backup # Where we keep backups -maxnumfull=3 # Number of full backups -daysbetweenfull=30 # Days between full backups -daysbetweenfullforfixed=32 # Days between full backups for machines with fixed - # full-backup date (in case the fixed day gets missed) -DAY_OF_MONTH=`date "+%d" | sed s/^0//` # from 1 to 31 -DATE=`date "+%Y%m%d%H%M"` #format: touch -DATEs=`date "+%Y-%m-%d %H:%M"` #format: tar - -# Exclude-pattern -exclude=$confdir/exclude -[ ! -f $exclude ] && printf "tmp\ncore\n" > $exclude +SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" # Absolute directory the script lives in +confdir=$SCRIPTPATH/conf/ # Directory configuration files +[ -r $confdir/env ] && . $confdir/env + +# Default configuration; used unless $confdir/env has set something different. +storagedir=${storagedir:-/backup} # Where we keep backups +exclude=${exclude:-$confdir/exclude} # List of exclude patterns +maxnumfull=${maxnumfull:-3} # Number of full backups +daysbetweenfull=${daysbetweenfull:-30} # Days between full backups + +# Days between full backups for machines with fixed full-backup date +# (in case the fixed day gets missed). +daysbetweenfullforfixed=${daysbetweenfullforfixed:-32} + +# End of configuration. + +computer=$1 # The computer to backup. +LOCKFILE=$SCRIPTPATH/backuprun.lockfile.$computer +DAY_OF_MONTH=`date "+%d" | sed s/^0//` # from 1 to 31 +DATE=`date "+%Y%m%d%H%M"` # format: touch +DATEs=`date "+%Y-%m-%d %H:%M"` # format: tar if [ -z "$computer" ]; then echo "Usage: $0 COMPUTER" exit 1 fi +[ ! -f $exclude ] && printf "tmp\ncore\n" > $exclude + # Die more or less gracefully (at least notify user) die() { warnmsg "Aborting."