Last active
February 21, 2022 21:43
-
-
Save ethanpil/94195cc149f9e00504972dbb18994ac8 to your computer and use it in GitHub Desktop.
Use WP CLI to migrate a WordPress database with search-replace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #On the source WP site: | |
| wp db export wp-export.sql --all-tables | |
| #On the destination site | |
| #First import the new DB | |
| wp db import wp-export.sql | |
| ## Replace basic URLs | |
| wp search-replace oldsite.com newsite.com --skip-columns=guid --all-tables | |
| ## Replace URL escaped strings | |
| wp search-replace "https:\/\/oldsite.com\/" "https:\/\/newsite.com\/" --skip-columns=guid --all-tables | |
| ## Replace URL encoded strings | |
| wp search-replace 'http%3A%2F%2Foldsite.com' 'http%3A%2F%2Fnewsite.com' --skip-columns=guid --all-tables |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment