THE SHORT
Export
sudo mysqldump -u root -pPASSWORD DBNAME > filename.sql
Import
wp db import filename.sql
THE LONG
So this turns out to be very painless. The server dump is exactly what WP-CLI needs to import.
REMOTE
sudo mkdir backup
- Make a directory for the file.
sudo chown -f -R ec2-user:group backup
- Set permissions to the directory for my SSH user.
cd backup
- Enter the directoy
- Run
sudo mysqldump -u root -pPASSWORD DBNAME > filename.sql
- Initially I was getting permission errors and that was because my EC2-USER needed control of the output directory.
LOCAL
- Download
filename.sql
to my Vagrant folder vagrant ssh
- into the box for WP-CLI access
wp db import /vagrant/filename.sql
wp search-replace old-site.com new-site.dev --test-run
- Test the operation first
wp search-replace old-site.com new-site.dev
NOTES
- Make sure plugins and themes are in the correct directories
- Any errors in your PHP code will break the WP-CLI since it loads WP
- WP Codex recommends to not change the GUID. You can skip the GUID in search and replace with
wp search-replace 'http://example.dev' 'http://example.com' --skip-columns=guid