implement an environment variable to exclude stuff

This commit is contained in:
Marc Koch 2023-09-06 17:52:22 +02:00
parent bf220fb4bc
commit 9092922440
2 changed files with 14 additions and 11 deletions

View File

@ -14,6 +14,9 @@ export BORG_PASSPHRASE="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# This array must containing everything you want to include in the backup
export BORG_TARGETS=("$HOME")
# Exclude directories and files
export BORG_EXCLUDE=("$HOME/.config/borg" "$HOME/.cache" "'*.db'")
# [optional] Use a ntfy service to publish backup results
# export NTFY=true

View File

@ -47,20 +47,20 @@ trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM
info "Starting backup"
exclude() {
for entry in "${BORG_EXCLUDE[@]}"; do
echo "--exclude $entry"
done
}
# Backup the most important directories into an archive named after
# the machine this script is currently running on:
/usr/local/bin/borg create \
--verbose \
--filter AME \
--list \
--stats \
--show-rc \
--compression lz4 \
--exclude-caches \
\
::"${mode}-{hostname}-{now}" \
"${BORG_TARGETS[@]}" \
borg_command=("/usr/local/bin/borg create" "--verbose" "--filter AME" "--list" "--stats" "--show-rc" "--compression lz4" "--exclude-caches")
borg_command+=($(exclude))
borg_command+=("::backup-{hostname}-{now}" "${BORG_TARGETS[@]}")
"${borg_command[@]}"
backup_exit=$?