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

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:

1 Like