# How to only write to external USB drive on Linux when it's attached?

**URL:** <https://forum.duplicati.com/t/how-to-only-write-to-external-usb-drive-on-linux-when-its-attached/10414>\
**Category:** Support\
**Created:** [August 3, 2020, 4:39pm UTC](https://forum.duplicati.com/t/how-to-only-write-to-external-usb-drive-on-linux-when-its-attached/10414 "2020-08-03T16:39:04Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![drwtsn32](https://forum.duplicati.com/user_avatar/forum.duplicati.com/drwtsn32/32/2591_2.png) [@drwtsn32](https://forum.duplicati.com/u/drwtsn32)\
**Post date:** [August 4, 2020, 4:57pm UTC](https://forum.duplicati.com/t/how-to-only-write-to-external-usb-drive-on-linux-when-its-attached/10414/3 "2020-08-04T16:57:55Z")

</div>

You could use --run-script-before, have it check for the presence of the drive, and then exit the script with a certain errorlevel to prevent the backup from running.

The different error levels are shown here:

> [@Improvements for --run-script-before/after options](https://forum.duplicati.com/t/improvements-for-run-script-before-after-options/519):
>
> from the runscript helptext of --run-script-before-required: If the script returns a non-zero error code or times out, the operation will be aborted. The ParsedResult will always be Failed if the script returns an errorlevel other than 0. There is no way to just skip the backup when a specific condition has met. This can be improved by allowing multiple error levels: Errorlevel 0: Everything is OK, start backup task Errorlevel 1: Everything is OK, but don't run the backup Errorlevel 2: The…

---

_[View the full topic](https://forum.duplicati.com/t/how-to-only-write-to-external-usb-drive-on-linux-when-its-attached/10414)._
