Skip to content

run-after-fail inside backup block triggered even if backup doesn't run #647

Description

@ruvilonix

I'm not sure if this is a bug or if I'm just not understanding the run- options.

I would like to backup my laptop to an external USB hard drive daily. I don't always have the drive plugged into the laptop, so if it's not plugged in, it should just skip it that day.

If the drive is plugged in and restic attempts to backup but fails, it should ping a server which emails me about the failure. The ping shouldn't happen if the drive is not plugged in.

Here is a minimal example of my config, where I replaced the ping with an echo.

version: "2"

profiles:
  edrive:
    password-file: "password.txt"

    repository: "/media/drive/backup/"

    run-before: "mountpoint -q /media/drive || exit 1"

    backup:
      source: 
        - "/home"

      run-after-fail: 'echo "BACKUP FAIL, SEND PING TO SERVER"'

This is the terminal input/output if the drive is not plugged in.

$ resticprofile edrive.backup
2026/06/17 16:14:48 using configuration file: /home/user/.config/resticprofile/profiles.yaml
BACKUP FAIL, SEND PING TO SERVER
2026/06/17 16:08:58 run-before on profile 'edrive': exit status 1

My expectation would be that if the run-before in the profile fails, then the backup block, including the run-after-fail within it, should not run at all.

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