]> arthur.barton.de Git - backup-script.git/commitdiff
Implement global "setup_exec" configuration option
authorAlexander Barton <alex@barton.de>
Wed, 6 Jul 2016 14:17:58 +0000 (16:17 +0200)
committerAlexander Barton <alex@barton.de>
Wed, 6 Jul 2016 14:17:58 +0000 (16:17 +0200)
README.md
bin/backup-script

index db48806cbbfc2979a5882c97b1253b5f2043f7e0..6aa60264aadb33a77796ebdbf8781f93ff825ab8 100644 (file)
--- a/README.md
+++ b/README.md
@@ -76,6 +76,19 @@ For example:
 - `/etc/backups-script.d/clientXY.example.com`: configuration for host 2
 
 
+### Global Settings
+
+The following global configuration options exist:
+
+- `setup_exec`: Script to run _before_ creating the lock file etc.
+- `pre_exec`: Pre-execution script, run before all jobs.
+- `post_exec`: Post-execution script, run after all jobs.
+
+In Addition, all job configuration options (see below) that have a "default_XXX"
+variant can be used and define default values for all jobs that don't overwrite
+them individually.
+
+
 ## Configuration Variables
 
 ### system
@@ -210,8 +223,9 @@ Optional script to execute after `rsync` exited. Default: none.
 
 ### Compatibility Variables
 
-The following configurations variables used by the backup-pull(1) script in job
-definition files are automatically mapped to the new backup-script variables:
+The following job configurations variables used by the outdated backup-pull(1)
+script in job definition files are automatically mapped to the new backup-script
+variables:
 
 * host -> system
 * source -> source_root
index b2a9b033751984ddaaf8e7e48a7fd6902d665c4f..04572682d78832f7acde423f8b8013f41e7deedd 100755 (executable)
@@ -31,6 +31,7 @@ destinations=""
 [ -d "/usr/local/etc/backup-script.d" ] \
        && conf_d="/usr/local/etc/backup-script.d" \
        || conf_d="/etc/backup-script.d"
+setup_exec=""
 pre_exec=""
 post_exec=""
 default_backup_type="rsync"
@@ -343,6 +344,19 @@ else
        sys=("${conf_d}/"*)
 fi
 
+if [ -n "$setup_exec" ]; then
+       echo "Executing \"$setup_exec\" ..."
+       sh -c $setup_exec
+       if [ $? -ne 0 ]; then
+               echo "Error: setup command failed!"; echo
+               CleanUp
+               echo "Aborting backup."; echo
+               exit 5
+       fi
+       sleep 2
+       echo
+fi
+
 # check and create PID file
 if [ -e "$PIDFILE" ]; then
        echo "Lockfile \"$PIDFILE\" already exists."