The backup script uses run_commands function to execute user-supplied commands from PRE_COMMANDS and POST_COMMANDS_* environment variables. PRE_COMMANDS are run after the /run/lock/backup.lock lock file is created. Since set -e at the beginning of the script, if one of those commands fails, the script exits without doing any clean-up, such as removing /run/lock/backup.lock. This means that any further backup calls will exit without doing anything because "Backup already running ...":
~ $ docker run -e RUN_ON_STARTUP=false -e SKIP_INIT=true --rm -it --entrypoint bash mazzolino/restic:1.8.2
26beac72cf39:/# PRE_COMMANDS=false backup
false
26beac72cf39:/# backup
Backup already running, skipping backup at 2026-08-13 09:38:33
Same happends when any of the POST_COMMANDS_SUCCESS/POST_COMMANDS_FAILURE/POST_COMMANDS_INCOMPLETE fail before the lock file is removed...
It might be a good idea to add lock file clean-up to the the run_exit_commands trap. Additionally, it would be nice if failed pre-commands would constitute a failed backup (perhaps, functionality gated by some env-variable) and report accordingly via POST_COMMAND_FAILURE or some pre-commands specific set of commands.
The
backupscript usesrun_commandsfunction to execute user-supplied commands fromPRE_COMMANDSandPOST_COMMANDS_*environment variables.PRE_COMMANDSare run after the/run/lock/backup.locklock file is created. Sinceset -eat the beginning of the script, if one of those commands fails, the script exits without doing any clean-up, such as removing/run/lock/backup.lock. This means that any furtherbackupcalls will exit without doing anything because"Backup already running ...":Same happends when any of the
POST_COMMANDS_SUCCESS/POST_COMMANDS_FAILURE/POST_COMMANDS_INCOMPLETEfail before the lock file is removed...It might be a good idea to add lock file clean-up to the the
run_exit_commandstrap. Additionally, it would be nice if failed pre-commands would constitute a failed backup (perhaps, functionality gated by some env-variable) and report accordingly via POST_COMMAND_FAILURE or some pre-commands specific set of commands.