• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Computing / WP-CLI move site locally

WP-CLI move site locally

Last updated on April 30, 2020 by Sal Ferrarello

These are the steps I follow when I move (a.k.a. migrate) the database for a website to my local computer using WP CLI.

Backup Local Database

wp db export local-retire.sql

Pull Remote Database Locally

wp @prod db export - > prod.sql

Replace Local Database with Remote

wp db import prod.sql

Change URL to development URL

wp search-replace 'https://example.com' 'https://example.dev' --skip-columns=guid --dry-run

Note: If you’re dealing with multisite you might need to add --url=https://example.com

Update Multisite Tables

This is only necessary when working with multisite

wp search-replace 'example.com' 'example.dev' wp_site wp_blogs --dry-run

Create a new admin/password user

wp user create admin admin@example.com --role=administrator --user_pass=password
Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on EmailShare on Reddit
Warning! This is a draft, not a finalized post. See full draft disclosure.

Filed Under: Computing, Dev Tips, Draft Tagged With: wp-cli

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in