backup.sh: håndter manglende eksluderingsliste

This commit is contained in:
2026-01-29 14:43:52 +09:00
parent 8f910ae595
commit 006dcf0875

View File

@@ -268,27 +268,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"