Pennf0lio
Pennf0lio

Reputation: 3894

What is the recommended best workflow syncing local and live wordpress database?

Exporting and importing database from my phpMyAdmin (live to local - and vice versa) is becoming a tedious task and prone to inconsistency. There are times the I imported a wrong database file that was on my downloads folder, overwriting my database with a wrong recored, lucky I still have a backup.

Is there a better workflow how to sync database from your local to live server? I need to sync my live-to-local and local-to-live because the changes are happening in both sides, the local changes is for the developer working on the site (which is me) and the live is for the publisher and administrator who's publishing content or doing some administration tasks with the live site.

I wish there solution like it has a version control option, so, that if I messed up I can still go back to an earlier stage.

Incase it's a software solution, I'm running on OS X (10.8.3). I use wordpress, coda and Mamp.

Upvotes: 5

Views: 3720

Answers (3)

Adam Erstelle
Adam Erstelle

Reputation: 2513

We develop wordpress sites and have many developers working in multiple environments. We've found this plugin that makes our life extremely simple. (We didn't make it, and we aren't paid by them to promote it)

http://deliciousbrains.com/wp-migrate-db-pro/

We've found that for the small amount paid ($99 for us) it has saved us TONS of time, making up for it in billable hours we can actually earn on.

Upvotes: 2

JP Lew
JP Lew

Reputation: 4439

My needs are nearly identical to yours, so I wrote a script to handle all my migration needs: 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.

My setup is similar too, so there's a good chance it will work for you: Mac OS X 10.8.4, MAMP, Wordpress, and MacVim.

While it doesn't subject the dump files to version control, it automatically names them 130830-0923-my_database.mssql.bz2 or whatever. Thus, you can restore previous versions easily. By scripting it, it takes a lot of the human error out the process too.

Upvotes: 2

Miguelo
Miguelo

Reputation: 1078

create a new database with the data you want to import then rename your active database to for example live_bck and you imported database to the name of the live data base:

rename database live_database to live_bck;
rename database imported_database to live_database;

now you have an backup of your database with the name live_bck you can rename it back to live_database when needed or drop it when everything is ok. http://dev.mysql.com/doc/refman/5.1/en/rename-database.html

you can also do this with phpmyadmin in the operations tab but that takes a little bit more time. so put the 2 queries in the sql textarea and execute it

Upvotes: 0

Related Questions