]> arthur.barton.de Git - backup-script.git/commitdiff
Add compatibility layer for backup-pull(1) config files
authorAlexander Barton <alex@barton.de>
Wed, 29 Jul 2015 08:35:30 +0000 (10:35 +0200)
committerAlexander Barton <alex@barton.de>
Wed, 29 Jul 2015 08:35:30 +0000 (10:35 +0200)
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
bin/backup-script

index bfbd7250fa069017a55cfab74f0319ac051782b2..81201368630d718253fe0d65b28e83720e4d95d0 100644 (file)
--- 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
index 457a5e7be4a1bdbbc47702be179894da77ef0b03..b3a3bd8d6776d92c22b70486a32694eb56534e18 100755 (executable)
@@ -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