Skip to content

Instantly share code, notes, and snippets.

@NurdinDev
Last active November 19, 2020 08:25
Show Gist options
  • Save NurdinDev/cf947a379a15dd98b0d20e1b930cf228 to your computer and use it in GitHub Desktop.
Save NurdinDev/cf947a379a15dd98b0d20e1b930cf228 to your computer and use it in GitHub Desktop.
Moving WordPress from place to place using WP-CLI

First Place

  • Go inside your wordpress directory and do:
    1. zip -r wp-content.zip wp-content/
    2. wp db export wp.sql

Move your backups

cp wp.sql wp-content.zip second

Second Place

  • Note: Make sure you have installed wordpress and add your config if not follow this:

    1. wp core download
    2. wp core config --dbname=YOUR_DATABASE_NAME --dbuser=YOUR_DATABASE_USER --dbpass=YOUR_DATABASE_PASSWORD
  • Go inside your wordpress directory and do:

    1. wp-cli --quiet db import wp.sql
    2. wp-cli search-replace 'https://first.com' 'https://second.com'
    3. unzip -o wp-content.zip
    4. rm -rf wp.sql wp-content.zip
    5. if you want to change the admin password wp-cli user update admin --user_pass="new_password"

enjoy 👋

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment