Debug scripts with TRACE envvar

This commit is contained in:
Erik Westrup
2023-06-02 22:32:09 +02:00
parent 2406f078ef
commit a870259eb2
3 changed files with 8 additions and 5 deletions

View File

@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Support for extra args for all restic commands with `RESTIC_EXTRA_ARGS`. [115](https://github.com/erikw/restic-automatic-backup-scheduler/pull/115/)
- Debug scripts by setting `TRACE=1`.
### Changed
- Warn on certain unset envvars instead of error-exit.
- Allow escaped spaces in EXTRA_ARGS.

View File

@@ -8,8 +8,9 @@
# $ source $PREFIX/etc/default.env.sh
# $ restic_backup.sh
# Exit on error, unset var, pipe failure
set -eo pipefail
set -o errexit
set -o pipefail
[[ "${TRACE-0}" =~ ^1|t|y|true|yes$ ]] && set -o xtrace
# Clean up lock if we are killed.
# If killed by systemd, like $(systemctl stop restic), then it kills the whole cgroup and all it's subprocesses.

View File

@@ -2,8 +2,9 @@
# Check the backups made with restic to Backblaze B2 for errors.
# See restic_backup.sh on how this script is run (as it's analogous for this script).
# Exit on error, unset var, pipe failure
set -euo pipefail
set -o errexit
set -o pipefail
[[ "${TRACE-0}" =~ ^1|t|y|true|yes$ ]] && set -o xtrace
# Clean up lock if we are killed.
# If killed by systemd, like $(systemctl stop restic), then it kills the whole cgroup and all it's subprocesses.
@@ -34,7 +35,7 @@ warn_on_missing_envvars() {
unset_envs=("${unset_envs[@]}" "$varname")
fi
done
if [ ${#unset_envs[@]} -gt 0 ]; then
printf "The following env variables are recommended, but have not been set. This script may not work as expected: %s\n" "${unset_envs[*]}" >&2
fi