Greetings fellow DP members, I am in need of a script that is a bit different then expected. I basically have a 2 servers. One server has the main site on it and the second server has the dev site on it. I need a script that will basically sync the dev site to be up to date with whats happening on the main site with a click of a button. I need this script to be a site based script with a login to keep it secure. Pretty basic, im just not sure how to actually do it.
Does your site use a database ? If its not using a database, the sync script can be written within php and can use rsync. Do you have ssh access on both servers ? If its using a database, does it need to be identical with the live database ? (I mean the dev site).
This should help you out. Thumbs up if I helped you out http://www.howtomonster.com/2007/08/08/how-to-sync-data-between-2-servers-automatically/
Its for a Linux box. Both ends have cPanel. I am a Linux Admin myself, but the script will be used by a web dev only. The site that needs to be synced is a Magento Cart website. I just need something easy for this web dev to use and thats all.
Then its pretty easy, i assume the dev site does not need the identical database from the live magento site so its just to create passwordless ssh between the two servers, lets say the user is magento and this user will have passwordless ssh to the dev server and have rights to execute rsync via sudo... Then using exec function within php you can create a little php file and setup a cron to sync it whenever you want... @KangBroke sent you the exactly the same method and it works well enough...
The thing is, it will need to have identical everything. The dev server is simply to test the new site fixes before being pushed to the main server, no work is actually done on the dev server. So it will need to sync everything in /public_html/ and the database itself. I just need a script, that is all. I know I can do all of this via ssh and what not but I need it to be stupid proof for the web dev to be able to work on.
The thing we told you involves ssh while you set it up afterwards its just simple as calling a php file from browser, to sync the database, you can just create master/slave replication or (Little weird but it`ll work), rsync the database directly from the /var/lib/mysql/databasename to the dev server, within the same php file where you sync the files. So one file, syncs both database and files.
Ok, let me put it like this, I don't want to deal with this haha. My job is to make sure all servers are up and running at all times, not to setup things like this. Who wants to do this for me? Let me know how much.