The answer is - Do not start rsync until your NAS is mounted and working. Simple if statement in your backup script should take care of it. You can do it number of ways - here is one - checking that there is any content in the directory before starting rsync (in bash):
#!/bin/bash backupTargetDir=/media/jjj/Synology cd $backupTargetDir # wait 30 seconds for the directory to mount sleep 30 filesInDir=$(ls | wc -l) if (( $filesInDir > 0 )); then echo "INFO: Backing up files to $backupTargetDir" rsync .... else echo "WARNING: No files in $backupTargetDir" fi Another way would be to use mount to verify that your NAS is mounted .... Tomas On Sat, 2018-10-06 at 11:37 -0700, John Jason Jordan wrote: > On Sat, 6 Oct 2018 10:17:05 -0700 > John Jason Jordan <[email protected]> dijo: > > I need some advice with respect to the following command, which makes > my Synology NAS device a mirror of my external USB storage enclosure: > > rsync -rptog --progress --stats --delete > --exclude-from=/media/jjj/Movies/rsync_exclusions > /media/jjj/Movies/ /media/jjj/Synology > > The first problem is that sometimes I get an error message that it > can't find /media/jjj/Movies. I found that a simple 'cd ..' followed > by > 'cd /media/jjj/Movies' solves the problem. I plan to convert the > rsync > command above to a simple script, adding the cd commands in front of > the rsync command. > > But there is a second, even worse problem: It sometimes can't find > the > Synology NAS device. And if it can't find the device it dumps > everything into the local hard drive where /media/jjj/Synology is > (supposed to be) mounted. The hard drive has a couple hundred GB of > free > space, but since the external USB device has over 7TB of data on it > the > local disk is quickly filled up, and then the rsync command fails > with > 'the device is full.' > > The Synology is mounted with this line in fstab: > > 192.168.1.115:/volume1/Synology /media/jjj/Synology nfs > auto,user 0 0 > > I need to add another command before the rsync command that checks to > be sure the Synology is mounted where it's supposed to be and mount > it > there if it is not already mounted. > > And finally, I need to add something after the rsync command that > checks to be sure the command executed as it is supposed to and give > me > a popup that it did, or that it did not. I have gxmessage installed > and > I could probably figure out how to make it pop up the messages, but I > don't know how to check that the rsync command executed properly. > Could > I just check the two filesystems to see if they are equal in all > respects? > > Suggestions? > _______________________________________________ > PLUG mailing list > [email protected] > http://lists.pdxlinux.org/mailman/listinfo/plug _______________________________________________ PLUG mailing list [email protected] http://lists.pdxlinux.org/mailman/listinfo/plug
