diff --git a/backup.sh b/backup.sh index 8fa2839..5fb1581 100755 --- a/backup.sh +++ b/backup.sh @@ -269,27 +269,31 @@ for host in "${hosts[@]}"; do "--log-file=${logdir}/${host}.log.$snapshot_date" ) - exclude_paths_var="${host}_excludes[@]" - exclude_paths=("${!exclude_paths_var}") - for exclude in "${exclude_paths[@]}"; do - command+=("--exclude=${exclude}") - done + exclude_array_name="${host}_excludes" + if declare -p "$exclude_array_name" >/dev/null 2>&1; then + exclude_paths_var="${host}_excludes[@]" + exclude_paths=( "${!exclude_paths_var}" ) + for exclude in "${exclude_paths[@]}"; do + command+=( "--exclude=${exclude}" ) + done + fi if [ -f "/backupz/${host}.exclude" ]; then command+=("--exclude-from=/backupz/${host}.exclude") fi - include_paths_var="${host}_includes[@]" - include_paths=("${!include_paths_var}") - if [ "${#include_paths[@]}" -eq 0 ]; then + include_array_name="${host}_includes" + if declare -p "$include_array_name" >/dev/null 2>&1; then + include_paths_var="${host}_includes[@]" + include_paths=( "${!include_paths_var}" ) + for include in "${include_paths[@]}"; do + command+=("${host_ssh_hostname[$host]:-$host}:$include") + done + else echo "Ingen inkluderingsstier for vert $host, hopper over." continue fi - for include in "${include_paths[@]}"; do - command+=("${host_ssh_hostname[$host]:-$host}:$include") - done - command+=("/backupz/${hosts_output_dir[$host]:-$host}/") echo "Starter backup for vert: $host"