Created
October 6, 2014 14:12
-
-
Save nurtext/9807b37bff748badf19c to your computer and use it in GitHub Desktop.
Migrate Wordpress using wp-cli
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
#!/bin/bash | |
# Check if wp-cli is installed | |
command -v wp >/dev/null 2>&1 || { echo >&2 "wp-cli not found. Visit http://wp-cli.org for more details."; exit 1; } | |
# Show usage info if wrong argument count | |
if [ $# -ne 2 ]; then | |
printf "WordPress migration script\n\n" | |
printf "Usage:\n" | |
printf " migrate.sh <from url> <to url>\n\n" | |
printf "Example:\n" | |
printf " migrate.sh http://www.example.com http://www.example.org\n\n" | |
exit 1 | |
fi | |
# Migrate using wp-cli | |
wp search-replace $1 $2 | |
wp option update home $2 | |
wp option update siteurl $2 | |
# All is well | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment