Migration Method 2: SSH & WP-CLI
In order to move your site with the WordPress command line tool(WP-CLI), you will need a SSH connection on both computers as well as a working WP-CLI tool on the servers. Migration via the command line is the most certain migration method as you can control everything that is happening.
Information of old server (example)
WordPress installation directory: /var/www/htdocs
Seravo.com information (example)
WordPress installation directory: /data/wordpress/htdocs
1. Start by logging in to the old server
my-computer:~$ ssh email@example.com
2. Check that WP-CLI is installed
firstname.lastname@example.org:~$ wp --version WP-CLI 2.2.0
3. Create an export file of the WordPress database
NOTE! Remember to set WordPress’s installation directory with the –path parameters.
email@example.com:~$ wp db export --path=/var/www/htdocs/ ~/wordpress-database.sql
If the export file has table definitions (for example
ENGINE=MylSAM), they must be removed.
firstname.lastname@example.org:~$ sed -i 's/ENGINE=MyISAM//g' ~/wordpress-database.sql
In addition, if you would like the table prefix to be something other than
wp_, it has to be changed in both table names and e.g. in the field names of the
wp_options table (e.g.
email@example.com:~$ sed -i 's/old-prefix_/wp_/g' ~/wordpress-database.sql
4. Log in to Seravo.com with the SSH login details
firstname.lastname@example.org:~$ exit my-computer:~$ ssh email@example.com -p 10350
5. Copy WordPress’s wp-content directory from the old server
The migration may take tens of minutes depending on the size and quantity of the exported files.
example@example-wordpress:~$ rsync -avz --stats firstname.lastname@example.org:~/wordpress-database.sql /data/db example@example-wordpress:~$ rsync -avz --stats email@example.com:/var/www/htdocs/wp-content /data/wordpress/htdocs
NOTE! The command above assumes that the only things that needs to be moved are the contents of the
wp-content folder. In case the old site uses Bedrock or some other custom directory layout you might need to add symbolic links to the site for it to work correctly.
More information about directory layouts can be found here: https://seravo.com/docs/get-started/data-locations/.
6. Import the database with the WP-CLI tool
example@example-wordpress:~$ wp db import /data/db/wordpress-database.sql
7. Ready! Finally, make any necessary search-replace database changes
example@example-wordpress:~$ wp search-replace "/var/www/htdocs/wp-content" "/data/wordpress/htdocs/wp-content"