Ensuring that rsync doesn't try to write to an unmounted drive

Kevin Korb kmk at sanitarium.net
Tue Sep 11 16:56:34 UTC 2018

--timeout is about network connection timeouts.  You aren't using the
network so it doesn't apply at all.  Even if you were networking an
unmounted filesystem is an empty directory as far as rsync is concerned
and rsync would treat it that way with no idea that you intended to have
something mounted there.

Now, I see at the top of your script you check for the existence of the
target directory.  If that isn't the root of a filesystem then you are
good because you are already checking for that.  If it is the root of
the filesystem then it will exist either as an empty directory or a
mount point and you need to check for those possibilities.

On 09/11/2018 12:28 PM, Chris via rsync wrote:
> I have a script that runs nightly as a cronjob to backup my drive to a
> USB drive https://pastebin.com/yivqrGUC On the command line I use the
> --timeout option. Is this sufficient to ensure that if the external
> drive somehow becomes unmounted that rsync will gracefully fail without
> trying to write to the hard drive instead of the USB drive?
> rsync -vaWSHpl --timeout=15 --delete-excluded --filter "merge
> ${EXC_FILE}" / "${BACKUP_DIR}" > /home/chris/rsyncbackup.log 2>
> /home/chris/rsyncbackup.errors.log 
> If this is sufficient or would it be better if I lowered the 'timeout'
> to 5 seconds?
> Thanks for any suggestions/advice.
> Chris

	Kevin Korb			Phone:    (407) 252-6853
	Systems Administrator		Internet:
	FutureQuest, Inc.		Kevin at FutureQuest.net  (work)
	Orlando, Florida		kmk at sanitarium.net (personal)
	Web page:			https://sanitarium.net/
	PGP public key available on web site.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/rsync/attachments/20180911/86579776/signature.sig>

More information about the rsync mailing list