From f38c82b02d03fd721f87c4876308e9f7ab789ca8 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Wed, 6 Jul 2016 16:17:58 +0200 Subject: [PATCH] Implement global "setup_exec" configuration option --- README.md | 18 ++++++++++++++++-- bin/backup-script | 14 ++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index db48806..6aa6026 100644 --- 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 diff --git a/bin/backup-script b/bin/backup-script index b2a9b03..0457268 100755 --- a/bin/backup-script +++ b/bin/backup-script @@ -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." -- 2.39.2