Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a usb drive setup on a customer Ubuntu server for backups. The backup drive also accepts rsync backups from another 2 servers on the same box.
The issue I have is that sometimes the users forget to plug the usb drive on the server. When this is done it backs up straight to the created mount point created for the usb drive and fills the hard drive up.
IS there anyway in my bash script I can stop the rsync happening if the usb drive is not actually attached rather than it using the mount point (if i have explained it correctly)
I usually use a local mount point and open a log file before I start the rsync. I track how long it takes to run my backups but it also gives me a way to confirm the mount point is there. If the mount point is remote you could test it like this
Sorry, but it does not work. Usually it is ok, but /mount/point/somefile may exist anyway (either device is mounted or not).
Much better would be to check if it is really mounted:
mount | grep <mount point pattern>
label the USB device as something like USB_BACKUP or some other easy to identify label, then just scan for the label before the backup script starts. if the label is not found, the backup fails, if it is found then it proceeds as normal.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.