From fbfcfd98df6466da4c097670736a1d43cca0aea2 Mon Sep 17 00:00:00 2001 From: jljl1337 Date: Mon, 2 Jun 2025 22:55:13 -0600 Subject: [PATCH 1/2] feat: execute commands when skipping backup --- backup | 1 + 1 file changed, 1 insertion(+) diff --git a/backup b/backup index 278054b..7aa7745 100755 --- a/backup +++ b/backup @@ -35,6 +35,7 @@ function check_bool { # Check if another backup is running if [ -f /run/lock/backup.lock ]; then echo Backup already running, skipping backup at $(date +"%Y-%m-%d %H:%M:%S") + run_commands "${SKIP_COMMANDS:-}" exit 1 fi From e44064ca0700eae5b23c374c9a22800dac061662 Mon Sep 17 00:00:00 2001 From: jljl1337 Date: Mon, 2 Jun 2025 22:55:45 -0600 Subject: [PATCH 2/2] docs: execute commands when skipping backup --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 7524f75..4a32107 100644 --- a/README.md +++ b/README.md @@ -226,6 +226,22 @@ The commands specified are executed one by one. By default, when any file could not be backed up, the commands from `POST_COMMANDS_FAILURE` will be executed. When `SUCCESS_ON_INCOMPLETE_BACKUP` is set to `"true"`, the commands from `POST_COMMANDS_INCOMPLETE` will be executed instead. Unless those are not configured – then the commands from `POST_COMMANDS_SUCCESS` will be executed. +## Execute commands when skipping backup + +It's possible to optionally execute commands (like restarting a temporarily stopped container, send a mail...) if the backup is skipped. Like for pre-backup and post-backup commands, if you want to execute `docker` commands on the host, mount the Docker socket to the container. + +You can add one or multiple commands by specifying the following environment variable: + +```yaml +SKIP_COMMANDS: |- + /my/scripts/mail-skip.sh + docker start my_container +``` + +The commands specified in `SKIP_COMMANDS` are executed one by one. + +Note that the pre-backup and post-backup commands are executed only if the backup is not skipped. If the backup is skipped, the commands specified in `SKIP_COMMANDS` will be executed instead. + ### Example: Stopping & starting other containers To stop and start containers running on the host system before and after the backup, even if they are usually stopped and started using Docker Compose, set the following environment variables and mount the docker socket into the container as follows: