Jump to content

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.







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

Link to comment
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...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...