On Mon, May 19, 2025 at 3:22 PM Dan Purgert wrote: > > On May 19, 2025, Lee wrote: > > On Sun, May 18, 2025 at 8:03 PM Greg Wooledge wrote: > > > > > > On Sun, May 18, 2025 at 19:51:04 -0400, Lee wrote: > > > > On Sun, May 18, 2025 at 4:51 PM Andy Smith wrote: > > > > > > > > > > Hi, > > > > > > > > > > On Sun, May 18, 2025 at 12:47:25PM -0400, Default User wrote: > > > > > > Since I know almost no shell scripting, the rsync usb drive A > > > > > > to usb drive B copy is done with a simple bash script consisting > > > > > > only of the rsync backup command, with options and parameters, but > > > > > > without any code to verify that usb drive B is attached. > > > > > > > > > > If your backup script is a bash script then all you need do is put > > > > > something like: > > > > > > > > > > if ! findmnt /mnt/usb-drive-b; then > > > > > > > > just out of curiosity.. why "findmnt" instead of > > > > if [ ! -d /mnt/usb-drive-b ]; then > > > > > > It will always be a directory. The question is whether there's a file > > > system mounted on it. > > > > I have a script to do a quick rsync backup to usb and ran into the > > same problem.. oops! I forgot to insert the usb stick. > > After a bit of experimentation I found that checking for the existence > > of the directory was good enuf: > > > > ----------------- > > DEST="/media/lee/TravelDrive/deb-spot" > > > > if [ ! -d "$DEST" ]; then > > echo "$DEST does not exist!!" >&2 > > exit 1 > > fi > > <.. snip ..> > > ----------------- > > > > $ ./syncusb > > /media/lee/TravelDrive/deb-spot does not exist!! > > > > ----------------- > > > > Is "/media/USERID" magic or what? > > In other words, why will /mnt/usb-drive-b always be a directory but > > /media/USERID doesn't exist unless the usb drive is mounted? > > /media/$USER/filesystem-UUID (or Label, if available) is created and > removed dynamically by a udev rule for hotplug support. > > Creating /mnt/mountdir manually means that it'll always be there, > whether or not the filesystem that's supposed to be mounted there is > actually mounted.
I wouldn't know a udev rule if it bit me, so thanks for the info Lee