]> git.sesse.net Git - backup.sh/commitdiff
Make it possible to have the script use other directories than /home/backup and ...
authorSteinar H. Gunderson <sesse@samfundet.no>
Tue, 7 Oct 2014 21:36:31 +0000 (23:36 +0200)
committerSteinar H. Gunderson <sesse@samfundet.no>
Tue, 7 Oct 2014 21:36:31 +0000 (23:36 +0200)
backup.sh

index 55bad7caf4826e21a5787b0611763848afa84e01..29ffa1fc17938a65831f90079d551323defd60ee 100755 (executable)
--- a/backup.sh
+++ b/backup.sh
 # 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."