visiblevc / wordpress-starter

A slightly less shitty wordpress development workflow
688 stars 167 forks source link

Script for exporting and importing production database #96

Closed andrewhavens closed 7 years ago

andrewhavens commented 7 years ago

I'm just getting started using this project, and am fairly new to both Docker and Wordpress development (though I am an experienced Ruby/JavaScript developer). I'm wondering if any of you are using some sort of script to export then import your production database in a way that is compatible with this docker setup. I came across wordmove but it doesn't seem compatible with wordpress-starter/Docker, but I could be wrong.

Anyway, if anyone has a script like this, I would appreciate if you could share it. Also, I think providing a configurable script like this out-of-the-box could be beneficial to others as well.

dsifford commented 7 years ago

@andrewhavens This project has wp-cli preinstalled. If you have it installed on your production server as well, all you need to do is wp db export db.sql to run a MySQL dump, then copy the file from your production server to your local ./data directory (I use rsync for this because it's the fastest), then if you build from scratch, the database will automatically be imported. If you're not building from scratch (and assuming your ./data directory is listed as a volume) all you would need to do is docker exec app_wordpress_1 /bin/bash -c 'wp db import /data/db.sql'.