Search code examples
osx-mavericksrsyncsmb

Bash Script for mounting share and starting rsync


There is a need to migrate data from one server to another as we begin decommissioning the first server; the first server is an OS X 10.9.5 machine. I would like to devise a script that, when launched, would auto-mount the appropriate share points and begin rsyncing the data over. Here's what I have, except it's not working

echo "Mounting Share..."
mkdir /tmp/Share
mount_smbfs //$USER:$PASSWORD@server.domain.com/Share /tmp/Share
rsync -vuhma --progress /Volumes/Path/SharedFolders/Share/ /tmp/DocShare

The script makes it's way to this point and all hell breaks loose. It makes the directory, starts the mount process but doesn't wait for the mount to actually take place before it starts rsync. This causes rsync to just dump files into a folder, not the actual share point.

How can I make sure that the script pauses while mounting the volume before starting rsync?


Solution

  • I forgot I even asked this one, but I did find a way to fix it and I ended up adding quotes around the SMB share path to make sure it was expanding properly into a string rather than trying to interpret the contents as more commands. This seems to have fixed the issue.

    The script now works beautifully!