I use cron to schedule overnight backups with rsync to an external HDD.
That HDD is auto-mounted when I plug it in, at /media/me/nameOfHDD.
If that HDD happens to not be mounted at the time cron starts executing the rsync commands ... rsync creates a folder, same name, on my local system drive, and by the next morning, my system drive is completely hosed under an extra TB of backups.
How do I amend the rsync commands (or whatever) to prevent this happening?
@nattiegoogie Have your backup script first check to see if the drive is mounted- either by looking for it in /proc/mounts
or checking if a canary file you leave on the drive is there (e. g. if [[ -f /media/me/MyBackupDrive/canaryfile ]]; then [...]; fi
.
@nattiegoogie check out the unattended-upgrades package. It does basically this but for security updates only. @ThatOhGi @DopeGhoti