Detecting If a Directory Is Mounted or Not (Useful for Backup Scripts)
In this video, we'll use the mountpoint command to check if a directory is mounted and improve a backup script to use it.
Quick Jump: Demo Video
A few years ago I wrote a blog post on how to do offline backups with Bash and rsync.
In this video, we’ll use the
mountpoint command to make this script better so you don’t accidentally backup your files to the wrong drive due to thinking your external drive is mounted when it’s really not.
- 0:59 – Getting a list of mounts on your system with
- 2:06 – Using the
mountpointcommand to check if a path is mounted
- 2:52 – Adjusting a backup script to check for a mounted backup target
What are you going to use this command for? Let me know below.