Jump to content
silentz

How To Synchronise Folders Automatically

Recommended Posts

I would love to see a tutorial on how to keep folders synchronised automatically (possibly using a chron job?). I have a testing server and a secure server folder that I'm repeatedly having to synchronise manually by going into file manager, copying folder A to a temp folder, deleting folder B, renaming folder A to folder B it in temp, and then copying folder B back to folder A's original directory... It gets pretty messy and repetitive doing this EVERY TIME I make a change to folder A when all I need is for folder B's to always mirror it's contents.

 

I'm sure that a tutorial on this would help just about anyone who has an SSL certificate with you guys and many people who just need their data backed up.

 

Cheers!

 

 

Piers

 

PS Knowing how to synch the contents barring a couple of files would be AWESOME! Thanks!

Share this post


Link to post
Share on other sites

I don't know that a full tutorial is required. I think the easiest way would be to use a 'cp' command in a cron job, configured with the "-a" archive option (don't follow symbolic links, preserve file attributes, and recurse subdirectories), and suppress any prompts that might appear:

>cp -a --reply=yes /home/cpanelName/public_html/dirA /home/cpanelName/public_html/dirB

 

PS Knowing how to synch the contents barring a couple of files would be AWESOME!

Excluding files means you aren't performing a true synchronization any more - it's more like a "selective copy". I think you'd need a CGI script to perform the copy from one directory to another - then the script could allow you to specify files not to be copied. The reason you'd need a CGI script (perl or PHP) is to preserve ownership of the copied files - files copied by a CGI script will be owned by "you" instead of "nobody". You'd then run the CGI script as a cron job instead of the 'cp' command I described above.

 

Hope this helps...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×