Add support for excludes-file

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-02-05 14:28:37 +01:00
parent da333914f8
commit 60e2c1979e
Signed by: luzifer
GPG key ID: D91C3E91E4CAD6F5

View file

@ -2,6 +2,7 @@
set -euo pipefail set -euo pipefail
: ${BASE_DIR:=.} # Where to create the backup dir : ${BASE_DIR:=.} # Where to create the backup dir
: ${EXCLUDES_FILE:=} # File containing exclude globs
: ${EXIT_ON_ERROR:=false} # Exit on backup error (default keep running) : ${EXIT_ON_ERROR:=false} # Exit on backup error (default keep running)
: ${HETZNER_WORKAROUND:=false} # Hetzner StorageBox needs sftp for symlinks : ${HETZNER_WORKAROUND:=false} # Hetzner StorageBox needs sftp for symlinks
: ${INTERVAL:=3600} # When to backup (3600 = *:00, 1800 = *:00,30) : ${INTERVAL:=3600} # When to backup (3600 = *:00, 1800 = *:00,30)
@ -155,9 +156,14 @@ function run_backup() {
} }
info "Synchronizing backup..." info "Synchronizing backup..."
extra_params=()
[[ -z $EXCLUDES_FILE ]] || extra_params+=("--exclude-from=${EXCLUDES_FILE}")
rsync -av --delete \ rsync -av --delete \
"${LOCAL_DIR}/" \ "${LOCAL_DIR}/" \
--link-dest "../${LATEST_LINK}/" \ --link-dest "../${LATEST_LINK}/" \
"${extra_params[@]}" \
"${REMOTE_HOST}:${dest}/" || { "${REMOTE_HOST}:${dest}/" || {
error "Failed to sync backup-dir." error "Failed to sync backup-dir."
return 1 return 1