Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

Detecting If a Directory Is Mounted or Not (Useful for Backup Scripts)

detecting-if-a-directory-is-mounted-or-not-useful-for-backup-scripts.jpg

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:

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.

# Demo Video

Timestamps

  • 0:59 – Getting a list of mounts on your system with mount -l
  • 2:06 – Using the mountpoint command to check if a path is mounted
  • 2:52 – Adjusting a backup script to check for a mounted backup target

Reference Links

What are you going to use this command for? Let me know below.

Never Miss a Tip, Trick or Tutorial

Like you, I'm super protective of my inbox, so don't worry about getting spammed. You can expect a few emails per year (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.



Comments