Debug scripts with TRACE envvar
This commit is contained in:
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Added
|
### Added
|
||||||
- Support for extra args for all restic commands with `RESTIC_EXTRA_ARGS`. [115](https://github.com/erikw/restic-automatic-backup-scheduler/pull/115/)
|
- 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
|
### Changed
|
||||||
- Warn on certain unset envvars instead of error-exit.
|
- Warn on certain unset envvars instead of error-exit.
|
||||||
- Allow escaped spaces in EXTRA_ARGS.
|
- Allow escaped spaces in EXTRA_ARGS.
|
||||||
|
|||||||
@@ -8,8 +8,9 @@
|
|||||||
# $ source $PREFIX/etc/default.env.sh
|
# $ source $PREFIX/etc/default.env.sh
|
||||||
# $ restic_backup.sh
|
# $ restic_backup.sh
|
||||||
|
|
||||||
# Exit on error, unset var, pipe failure
|
set -o errexit
|
||||||
set -eo pipefail
|
set -o pipefail
|
||||||
|
[[ "${TRACE-0}" =~ ^1|t|y|true|yes$ ]] && set -o xtrace
|
||||||
|
|
||||||
# Clean up lock if we are killed.
|
# 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.
|
# If killed by systemd, like $(systemctl stop restic), then it kills the whole cgroup and all it's subprocesses.
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
# Check the backups made with restic to Backblaze B2 for errors.
|
# 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).
|
# 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 -o errexit
|
||||||
set -euo pipefail
|
set -o pipefail
|
||||||
|
[[ "${TRACE-0}" =~ ^1|t|y|true|yes$ ]] && set -o xtrace
|
||||||
|
|
||||||
# Clean up lock if we are killed.
|
# 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.
|
# 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")
|
unset_envs=("${unset_envs[@]}" "$varname")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ${#unset_envs[@]} -gt 0 ]; then
|
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
|
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
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user