Skip to content

backup script leaves lock file if PRE_/POST_COMMANDS_* fail #247

Description

@arteme

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions