Migrating a Site Quickly with SSH and WP-CLI (It's not as scary as you think!)

67 %
33 %
Information about Migrating a Site Quickly with SSH and WP-CLI (It's not as scary as you...
Technology

Published on February 19, 2014

Author: Japho

Source: slideshare.net

Hi, I’m Japh WordPress guy at

Migrating a Site Quickly with SSH and WP-CLI (It's not as scary as you think!)

Let’s talk about scary things!

• Migrations • Command-Line • SSH

Let’s make them not scary anymore!

What is SSH? • Connecting to the command-line on a remote computer • Secure

How do I “SSH”? • Terminal (Mac OS X) - If you don’t have it, you’re not on a Mac… • PuTTY (Windows) - http://enva.to/puttywin • Prompt (iOS) - http://enva.to/promptios

• Why even use the command-line? • WP-CLI helps too!

Command-Line 101 (Cheatsheet) • <command> --help - many programs have a built-in “help” to show you basic usage information • man <command> - “manual” program to show information on how to use a command • cd - change directory • ~ - special shortcut to indicate my home directory • ls - list contents of the current directory • pwd - show the current (working) directory’s path • cp - copy • scp - secure copy • cat - output file contents • gzip - a compression program • gunzip - a decompression program • find - search for files • mysql - connect to a MySQL server • mysqldump - “dump” from a MySQL server • | - “pipe” output to another program • > - output to a file • < - input from a file • grep - regular expressions • rm - remove / delete (be careful on this one) • Tab completion!

Let’s do this…

SSH Connecting from your computer, to the server you’re migrating from

Install WP-CLI http://wp-cli.org/ This will differ from host to host, but there are good instructions on the site

wp db export - | gzip > ~/migration/moredemo.sql.gz • Firstly, gesundheit! • wp - WP-CLI FTW! • db - subset of WP-CLI commands to do database things • export - this is the particular database thing we want to do • - - don’t put the export data in a file, just output it • | - pass the output to another program… • gzip - compress the passed output • > - send the output (now compressed) to a file • ~/migration/moredemo.sql.gz - the file, named appropriately so that we know what it is! (SQL, gzipped)

tar czvf ~/migration/moredemo.tar.gz ./wp-content/ • tar - an archiver program for creating and extracting files from archives • c - create an archive • z - do compression • v - show output (so we know something is happening!) • f - create this archive as a file • ~/migration/moredemo.tar.gz - the file to create as an archive • ./wp-content/ - the files to put into the archive

scp ~/migration/* japheth@lessdevelopment.com:~/webapps/lessdemo/ • scp - secure copy (can copy to a remote server through SSH) • ~/migration/* - the files to copy, the * indicates all files in the directory • japheth@lessdevelopment.com: - my username and the remote server’s address • • The format for this is <username>@<domain name or IP address>: ~/webapps/lessdemo/ - the directory on the remote server to copy to, must come after the :

scp wp-config.php japheth@lessdevelopment.com:~/webapps/lessdemo/ • scp - secure copy (can copy to a remote server through SSH) • wp-config.php - the WordPress config file to copy • japheth@lessdevelopment.com: - my username and the remote server’s address • • The format for this is <username>@<domain name or IP address>: ~/webapps/lessdemo/ - the directory on the remote server to copy to, must come after the :

scp .htaccess japheth@lessdevelopment.com:~/webapps/lessdemo/ • scp - secure copy (can copy to a remote server through SSH) • .htaccess - the WordPress .htaccess file to copy, important for permalinks and WordPress Multisite installations • japheth@lessdevelopment.com: - my username and the remote server’s address • • The format for this is <username>@<domain name or IP address>: ~/webapps/lessdemo/ - the directory on the remote server to copy to, must come after the :

SSH Connecting from the server you’re migrating from, to the server you’re migrating to

Install WP-CLI http://wp-cli.org/ This will differ from host to host, but there are good instructions on the site

ls -l • ls - program for listing file information • -l - show the information in a long list (goes vertically instead of horizontally, I find it easier to read)

wp core download • wp - WP-CLI FTW! • core - subset of WP-CLI commands to do core things • download - download the latest version of WordPress

tar xzvf moredemo.tar.gz • tar - an archiver program for creating and extracting files from archives • x - extract an archive • z - do compression • v - show output (so we know something is happening!) • f - create this archive as a file • moredemo.tar.gz - the archive file to extract from • Automatically re-creates the directory structure that is in the archive

Update your config! Database name, username, password, and (if your web provider requires) host

gunzip < moredemo.sql.gz | wp db import • gunzip - uncompress the passed output • < - pass the contents of file to be uncompressed • moredemo.sql.gz - the file • | - pass the output to another program… • wp - WP-CLI FTW! • db - subset of WP-CLI commands to do database things • import - this is the particular database thing we want to do • - - don’t get the import data from a file, just use the output being passed

wp search-replace moredevelopment.com lessdevelopment.com • wp - WP-CLI FTW! • search-replace - a WP-CLI command to do a find and replace on the database (properly handles serialisation!) • moredevelopment.com - this is the string we want to replace • lessdevelopment.com - this is the string we want to replace it with

Dance Party!

Other Resources • WP Migrate DB (Pro) • Coupon code 20% off: WPMELBOURNE20 • Free Developer license for one lucky person! • Find / Replace - InterconnectIT’s “Search Replace DB” ( http:// envat.to/srdb2 ) • 7 Simple and Useful Command-Line Tips ( http://enva.to/cli-tips ) from 2010 and still (mostly) useful!

Thank you! Questions? I’m @Japh on Twitter ! Slides - http://enva.to/migratewp

Add a comment

Related presentations

Related pages

Unix Command Cheatsheet - Kirsten Cassidy

Basic Unix command cheatsheet. Just a quick ... Quickly with SSH and WP-CLI (It's not as scary as you think!) ... WP-CLI Cheatsheet for site ...
Read more

Interviews: Not As Scary as You Think - Technology

... Not as Scary as You Think Angelique Torres Employer ... Migrating a Site Quickly with SSH and WP-CLI ... it’s not as taxing as you might think!!
Read more

Migrating WordPress Websites - Bill Erickson

... if something goes wrong you can quickly switch back to the old site. ... I think, if you have ssh access ... The host says it’s not their problem ...
Read more

Ssh | LinkedIn

SSH. It's more robust and responsive, ... Once you login via SSH, ... Migrating a Site Quickly with SSH and WP-CLI ...
Read more

Get Your Site Moving With 9 of the Best ... - Elegant Themes

WP Migrate DB is very useful if you are not concerned with migrating ... for your site and not the files. If you want a ... it’s not and there is a ...
Read more

A Quick Guide to the Terminal and Command Line Prompt for ...

... is one of those things that seems scary for the uninitiated. It's all ... Terminal and Command Line Prompt ... hosts who do not give you SSH ...
Read more

Migrating WordPress Sites - IvyCat Web Services

Migrating WordPress sites using ... The important thing to remember about serialized data when migrating sites is that you can’t simply ... if it’s not ...
Read more

A Quick Guide to the Terminal and Command Line Prompt for ...

A Quick Guide to the ... The terminal is one of those things that seems scary for the uninitiated. It’s all text based and spits out ... I kid you not.
Read more