How to keep 2 Wordpress sites synced



Thanks: 95
Messages: 2,337

I want to be able to keep an Internet Wordpress site synced up with a local site.

Is anyone aware of any guides on how to do this?

Both sites will be running on FreeBSD.


Aspiring Daemon

Thanks: 453
Messages: 798

I maintain a synched copy of my BLog on my web development machine -- like I do with other web applications as well. Usually I set up the database backend of a web application to be a slave which would be replicated automatically by the master once there are any changes. Unfortunately master/slave replication does not work as intended with WP sites, because the internal links of a WP site are stored by their full URL into the database, and therefore a straight copy of a WP database would work only on a WP site which got exactly the same URL.

My solution is that I run a mysqldump(1) on the master site from a cron job which I fetch by scp(1) to my local development machine when needed -- I could do this with a cron job as well.

mysqldump --user=root --password=uLtRaSeCrEt12345 --default-character-set=utf8 --tz-utc --set-gtid-purged=OFF wpdbname > wpdbname.sql

Since the MySQL dump is simply a text file of MySQL commands and the contents are in plain text, I utilize sed(1) to substitute in the SQL dump the URL of the master site - in my case - by the URL of the local site - in my case https://localhost/ I wrote a shell script for doing this:
/usr/bin/sed -e "s/https:\/\/\/\/localhost\/" -i "" /path/to/wpdbname.sql
/usr/bin/sed -e "s/" -i "" /path/to/wpdbname.sql
echo "drop database wpdbname; create database wpdbname;" | mysql --user=root --password=uLtRaSeCrEt12345 --default-character-set=utf8
mysql --user=root --password=uLtRaSeCrEt12345 --default-character-set=utf8 wpdbname < /path/to/wpdbname.sql
  • Of course you would need to adapt the script for your URL's respectively.
  • Of course you would need to set up a working WP installation on your local machine.
  • Image and media data you would need to transfer using e.g. scp(1) as well.


Aspiring Daemon

Thanks: 139
Messages: 884

Could net-p2p/btsync work for you? I have done some neat things with it, and for the most part it works really well. Sometimes syncing seems to get stuck, but that maybe also be caused by me messing around.


Well-Known Member

Thanks: 13
Messages: 373

Thanks for the advice, but I don't understand what you mean.
Have 1 wordpress and point both DNS names to it.
Problem solved!
A cname is a DNS record that point fo example to
occamz razor n all that