#Linux #SysAdmin question

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.

@ThatOhGi @DopeGhoti

Thanx.

Bonus question.

Nightly overnight unmonitored "apt update && upgrade" script ... good idea or tempting the gods?

@nattiegoogie check out the unattended-upgrades package. It does basically this but for security updates only. @ThatOhGi @DopeGhoti

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.