Skip to content

Instantly share code, notes, and snippets.

@nurtext
Created October 6, 2014 14:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nurtext/9807b37bff748badf19c to your computer and use it in GitHub Desktop.
Save nurtext/9807b37bff748badf19c to your computer and use it in GitHub Desktop.
Migrate Wordpress using wp-cli
#!/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