From ae3715928888045d19458bb00d0ce2da7fccdc44 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Wed, 29 Jul 2015 10:35:30 +0200 Subject: [PATCH] Add compatibility layer for backup-pull(1) config files The following (now deprecated!) configurations variables used by the backup-pull(1) script in job definition files are automatically mapped to the new backup-script variables: - host -> system - source -> source_root - pre_exec -> job_pre_exec - post_exec -> job_post_exec --- README.md | 10 ++++++++++ bin/backup-script | 24 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/README.md b/README.md index bfbd725..8120136 100644 --- a/README.md +++ b/README.md @@ -128,3 +128,13 @@ run is skipped! ### [default_]job_post_exec 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: + +* host -> system +* source -> source_root +* pre_exec -> job_pre_exec +* post_exec -> job_post_exec diff --git a/bin/backup-script b/bin/backup-script index 457a5e7..b3a3bd8 100755 --- a/bin/backup-script +++ b/bin/backup-script @@ -277,9 +277,33 @@ for f in $sys; do job_pre_exec="$default_job_pre_exec" job_post_exec="$default_job_post_exec" + # Compatibility with backup-pull(1) script: Save global values ... + pre_exec_saved="$pre_exec" + post_exec_saved="$post_exec" + + # Compatibility with backup-pull(1) script: Set defaults + unset host + unset source + unset pre_exec + unset post_exec + # Read in system configuration file source "$f" + # Compatibility with backup-pull(1) script: Fix up configuration + [ "$system" = "$fname" -a -n "$host" ] \ + && system="$host" + [ "$source_root" = "$default_source_root" -a -n "$source" ] \ + && source_root="$source" + [ -z "$job_pre_exec" -a -n "$pre_exec" ] \ + && job_pre_exec="$pre_exec" + [ -z "$job_post_exec" -a -n "$post_exec" ] \ + && job_post_exec="$post_exec" + + # Compatibility with backup-pull(1) script: Restore global values ... + pre_exec="$pre_exec_saved" + post_exec="$post_exec_saved" + # Validate configuration [ "$system" = "localhost" -o "$system" = "127.0.0.1" ] && local=1 -- 2.39.2