To be honest, there is not any handy way to sync a site between two servers automatically. This requires advanced ssh knowledge and server management skills. Still I managed to find a way to sync secondary server using a single click. That means every time you make changes to your site version on primary server, you can push all changes to website version on secondary server using a single click.
With BackupBuddy plugin you can do it. BackupBuddy has a feature names “Site Deployment”. With the help of this feature you can connect two WordPress installations and sync them using a “Push” button. Though this feature is to sync sites with different root URL, but it works if you want to push changes in one way (primary server to secondary)
So, making use of this plugin, I discover a new way to sync site from primary to secondary server. Syncing is currently manual and one way. However, it is a little bit tricky but it works.
Don’t try to push changes from secondary to primary server (it will push changes successfully but then you will not be able to push changes from primary server to secondary as deployment key of primary server will be overwritten by that of secondary server.
So you need to follow this step by step guide to setup secondary server that can be synced with primary one.
Do the following steps on the secondary web hosting server;
- Add your WordPress site domain as addon domain (on secondary server)
in cPanel, an addon domain can be accessed in a subfolder of primary domain. For instance if your hosting primary domain is hostingprimarydomain.com, then you can access your addon domain is this way;
- So your domain directory can be accessed something like hostingprimarydomain.com/yourdomain.com (blue text represents your WordPress site domain that is currently running on primary web hosting)
Note – Hosting Primary domain is the domain name that you add while buying the web hosting account. or the domain that is pointed to the root folder of web hosting.
- Now that your WordPress site domain (yourdomain.com in this tutorial) is not pointed to secondry server, you need to use hostingprimarydomain.com/yourdomain.com URL to clone WordPress on secondary server
- Use BackupBuddy migrate option to easily clone your WordPress from primary server (yourdomain.com) to secondry server (hostingprimarydomain.com/yourdomain.com)
- After successful cloning, login to cloned website (hostingprimarydomain.com/yourdomain.com/wp-admin) and go to WordPress settings > reading > Discourage search engines to prevent indexing of cloned version
- Opne wp-config.php file and add the following line just before define(‘WP_DEBUG', false);)
define( ‘BACKUPBUDDY_API_ENABLE', true );
(you need to add this line to the wp-config.php file on primary server too)
- In the clone site, get to BackupBuddy menu > Remote Destinations
- Here you will see a button “Show Development Key”. Click on this button
- Then click on “Generate New Key” and copy the key (better to save it to the notepad)
- Now get to your main WordPress and logged-in (which is hosted on primary server: yourdomain.com/wp-admin)
- Got to BackBuddy > Remote Destinations and click on Add New button
- Among all available remote destinations, choose “BackupBuddy Deployment”
- Now paste the deployment key that you have copied from the cloned site’s WordPress panel
- On adding the key and saving the Deployment destination, you will see a panel with two buttons – PUSH TO and PULL FROM (this way Cloned site will be connected to your main site and you can send changes to cloned site using PUSH TO button
After that get back to clone site (hostingprimarydomain.com/yourdomain.com/wp-admin) hosted on secondary server
Go to BackupBuddy > Server Tools > Database and locate the option Advanced: Database Mass Text Replacement
Using this option your cloned site gets its URLs replaced with main domain
Now get back to main WordPress site (on primary server) and go to BackupBuddy > Remote Destinations
Click on the BackupBuddy Deployment destination you have added and click on “Push to” button
On the next page choose all files and database tables (or choose only database if you have not changed any file on primary server)
Note – Don’t forget to click on confirm changes button otherwise backup database tables (created by BackupBuddy) on secondary server will not be deleted.
This way you can update database and files on secondary server using 2-3 clicks and point your site to secondary server wherever you want either manually or by using DNS Failover.
If you are running a high traffic website with over 10k+ visitors per day, it is highly recommended to use DNS Failover service so that you could minimize visitors lose due to primary server failure. One minute downtime may result in a lose of 100 to thousands of visitors depending on traffic volume of a website. DNS Failover prevents this condition. If your primary server goes down, DNS Failover automatically point your domain to secondary server. DNS Failover bot checks the website every minute and it switch the server IP when found the site down.
Is there any free alternative to BackupBuddy?
There is not a complete free alternative to BackupBuddy to send site changes (database and files) from one to another server. However, a plugin that can sync database is available for free. Just like BackupBuddy it connects two WordPress installations via a security token. But the real issue with this plugin is that it is not compatible to most of the shared hosting. I tried it to sync database but the PHP process was time out.