I mount a few shares using sshfs and I like to make sure they are synced with my local raid 1 array for backup. So how can I run rsync making sure the share is mounted already?

What I do below is, using the mount command, check to see if the sshfs share is mounted to /mnt/login and if it is, it syncs with a directory on my local machine and puts the date into a file so I know when the last sync was run.

!/bin/bash #If the remote share is mounted to /mnt/login via the stdout of the mount command, then go ahead and run the sync. mount | grep /mnt/login && rsync -a --progress --stats --delete -l -z -v -r -p /mnt/login/* /b/backstor/login.home && date > DATE.txt

Keep in mind this syncs the remote share with the local one. Switch the directories around in the command to do it the other way (sync the local directory with the remote one).

Blog Logo

Mario Loria


Published

Image

./scriptthe.net

Because 127.0.0.1 gets old after a while.

Back to Overview