alisamii — 2012-10-31T07:16:03-04:00 — #1
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.
logic_earth — 2012-10-31T20:52:54-04:00 — #2
Every 30 seconds....why?! o.O
Also...do you have a question or just making a statement?
alisamii — 2012-11-01T04:06:56-04:00 — #3
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' firstname.lastname@example.org:/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?
doug_g — 2012-11-02T02:31:39-04:00 — #4
Add a trailing slash to the source path
wwb_99 — 2012-11-06T09:19:53-05:00 — #5
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.