I need to set up a shell script on Mac OS X Mountain Lion to sync a local directory to a remote directory (web server) using either an SSH connection (tunnel) or SFTP and have it run continuously every 30 seconds.
I also need to exclude certain files or folders from being synced.
The syncing would be unidirectional (mac -> webserver).
The basic parameters I need to have implemented are as follows:
Local path: /Volumes/path/to/local/directory
Remote server: example.com
Remote path: /path/from/server/root/to/htdocs
Files to exclude: '.ht*', '*.sublime-*'
Folders to exclude: 'cache','administrator/cache'
I would also need help writing the crontask and adding it to my system to execute automatically.
Any help would be greatly appreciated.
Every 30 seconds....why?! o.O
Also...do you have a question or just making a statement?
Yes...my question was how do I set that up. I got the answer...but now I am facing a different issue.
The command I am issuing is:
rsync -avz -e ssh --exclude '*.ht*' --exclude '*.jpa*' --exclude '*.sublime-*' --exclude 'cache/' --exclude 'administrator/cache' email@example.com:/home/public_html/domains/clients/sosdivorce /Volumes/Clients/htdocs/sites/domains/clients/sosd2
It isn't doing exactly what I need.
What is happening is that the entire remote directory 'sosdivorce' is being synced into the local directory 'sosd2' as a subdirectory of the local.
What I need to have happen is that the contents of the remote directory 'sosdivorce' sync with the contents of the local directory 'sosd2'.
How do I modify the command above to do that?
Add a trailing slash to the source path
Also, you can use the --daemon switch to make rsync run as a daemon which is more suitable than running it every 30 seconds. Especially since cron can't handle every 30 seconds.
This topic is now closed. New replies are no longer allowed.