# Run-script-before-required: no email in case of error

**URL:** <https://forum.duplicati.com/t/run-script-before-required-no-email-in-case-of-error/18490>\
**Category:** Developer\
**Created:** [June 23, 2024, 4:21pm UTC](https://forum.duplicati.com/t/run-script-before-required-no-email-in-case-of-error/18490 "2024-06-23T16:21:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PDi](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/p/e36b37/32.png) [@PDi](https://forum.duplicati.com/u/PDi)\
**Post date:** [June 23, 2024, 4:21pm UTC](https://forum.duplicati.com/t/run-script-before-required-no-email-in-case-of-error/18490/1 "2024-06-23T16:21:29Z")

</div>

Set up:

1. docker container linuxserver/duplicati running on Debian GNU/Linux 12 (Raspberry Pi) as root (PUID 0, GUID 0)
2. Mount a host volume for scrips
3. Create a new tiny backup job
4. Add the option “run-script-before-required” pointing to a script on the host
5. Add email notification options (global section)

Test 1:  
Let the script return zero  
Result:  
Success, respective email sent

Test 2:  
Let the script return non-zero  
Result:  
Backup job fails as expected with respected notification in the logs  
No email sent

Expected result:  
Whenever a mandatory script fails, an appropriate email should be sent

---

<div class="post-metadata">

**Author:** ![Jojo-1000](https://forum.duplicati.com/user_avatar/forum.duplicati.com/jojo-1000/32/8262_2.png) [@Jojo-1000](https://forum.duplicati.com/u/Jojo-1000)\
**Post date:** [June 23, 2024, 4:33pm UTC](https://forum.duplicati.com/t/run-script-before-required-no-email-in-case-of-error/18490/2 "2024-06-23T16:33:03Z")

</div>

This looks like it is to do with the module loading order. The run script module throws a `OperationAbortException` to stop the backup from running. This is handled correctly and all the `OnFinish` methods are called, but because the mail module was not configured before, it does nothing. The proper way to fix this would probably be to configure all modules before calling `OnStart`.

> <https://github.com/duplicati/duplicati/blob/9ca5489ef0694973786adc7f42083b9ea5155e67/Duplicati/Library/Main/Controller.cs#L634-L655>

---

<div class="post-metadata">

**Author:** ![kenkendk](https://forum.duplicati.com/user_avatar/forum.duplicati.com/kenkendk/32/5305_2.png) [@kenkendk](https://forum.duplicati.com/u/kenkendk)\
**Post date:** [June 24, 2024, 8:29am UTC](https://forum.duplicati.com/t/run-script-before-required-no-email-in-case-of-error/18490/3 "2024-06-24T08:29:58Z")

</div>

> [@Jojo-1000](#):
>
> but because the mail module was not configured before, it does nothing. The proper way to fix this would probably be to configure all modules before calling `OnStart`.

I have made [a PR](https://github.com/duplicati/duplicati/pull/5245) that fixes this.

---

<div class="post-metadata">

**Author:** ![caco3](https://forum.duplicati.com/user_avatar/forum.duplicati.com/caco3/32/11906_2.png) [@caco3](https://forum.duplicati.com/u/caco3)\
**Post date:** [November 23, 2025, 3:22pm UTC](https://forum.duplicati.com/t/run-script-before-required-no-email-in-case-of-error/18490/4 "2025-11-23T15:22:55Z")

</div>

Sorry to warm this up again. It seems that [Changed logic so all modules are loaded before any are started by kenkendk · Pull Request #5245 · duplicati/duplicati · GitHub](https://github.com/duplicati/duplicati/pull/5245) did get closed **without** a solution.

I have the same issue:  
A script in “run-script-before-required“ checks if the preconditions are met. In case of an error, I see the error in Duplicati, so this works.

I also have setup notifications by HTTP:

```plaintext
send-http-form-urls=https://mydomain.com
send-http-level=Warning,Error,Fatal

```

But it does not get fired. Since the backup is aborted in case of a pre-script-error, this is kind of a fatal issue and I do not see a way to get notified!!
