Reputation: 3130
I'm usually using git as the version control system to my WordPress code. But there's something missing from git. I can sync my project's files easily, but syncing databases is always a huge pain.
Is there a "correct" way to sync databases between live and dev servers?
I could include a database dump to the version control and update it every time, but that doesn't seem intuitive. Especially when in some cases WordPress tends to save information concerning the live server to the database.
P.S. I'm not talking about database structure, since there are ORM techniques for that, but the actual content of the pages.
Upvotes: 2
Views: 3287
Reputation: 4469
you can try my script: https://github.com/jplew/SyncDB
SyncDB is bash deploy script meant to take the tedium out of synchronizing local and remote versions of a Wordpress site. It allows developers working in a local environment (eg. MAMP) to rapidly "push" or "pull" changes to or from their production server with a single terminal command.
I migrate content back and forth between live and dev constantly, so I reduced the process down to a single shell command:
./syncdb
Upvotes: 2
Reputation: 73031
Due to WordPress being a production-ready system, most data is stored environment specific. Fortunately, migrating the database is rarely required (i.e. only when launching the site).
You can do so with the following steps:
wp_posts
tablewp_posts
tableSince most runtime configurations are in wp_config.php
there's rarely a problem with the wp_options
table. However, you can export it if you wish.
Note: This was taken from my article on Configuring WordPress for Multiple Environments.
There are also plugins that help with this process.
Upvotes: 0
Reputation: 11181
You can have a master-slave replication or master-master replication in MySQL.
Master-slave replication
Master-master replication
Upvotes: 1