Chassis / Chassis

📦 Chassis is a virtual server for your WordPress site, built using Vagrant.
http://chassis.io/
GNU Lesser General Public License v3.0
621 stars 84 forks source link

Importing a production DB (with a diff local host name) #652

Closed colmtroy closed 5 years ago

colmtroy commented 5 years ago

Hey, I'm wondering is there a best practice for bringing a production DB into a Chasis environment? I spotted this issue re: migrating out. https://github.com/Chassis/Chassis/issues/47

Is there anything similar for brining a DB in? Thanks, Colm

dcneuts commented 5 years ago

I'm new to Chassis, but not WP development. I saw something regarding an extension for phpMyAdmin, I'm planning on trying this out later this afternoon to see if I can simply import that way and run a search/replace if needed. https://github.com/Chassis/phpMyAdmin

BronsonQuick commented 5 years ago

@colmtroy It'd be a very similar process to import. I'd do it all with WP-CLI. I think it would be something similar to the following:

  1. Provision a new Chassis instance.
  2. Export your production database with WP-CLI wp db export <filename.sql>
  3. Copy the export into content
  4. In a terminal run vagrant ssh to SSH into your Chassis box.
  5. cd /vagrant/content
  6. wp db import <filename.sql>
  7. wp search-replace '//www.yoursite.com/wp-content' '//vagrant.local/content'
  8. wp cache flush
  9. Down your the contents of your wp-content folder on production to your local content folder.

Alternatively you can do the export and import with phpMyAdmin as @dcneuts mentioned.

I might actually get around to adding some docs for #47 seeing I haven't got around to do that yet! 🙈

colmtroy commented 5 years ago

thanks @BronsonQuick and @dcneuts I managed to muddle through and pretty much do the steps you outlined @BronsonQuick - with the exception that I manually replaced the DB via SequelPro for Step 6.

I think a small guide might be useful for a ton of people looking to get up and running locally quick. Loving Chassis so far though - great work!!

rmccue commented 5 years ago

You could also look at using the db-export extension. Commit your SQL export as a file called chassis-backup.sql and it should automatically import on install.

colmtroy commented 5 years ago

Ooh - that's awesome @rmccue - nice one thanks!