Skip to main content

Site Migration via Command Line (SSH & WP-CLI)

Migrating a site via command line (SSH & WP-CLI) is the fastest and most reliable way to move a WordPress site to Seravo with no file size limits. Follow our step-by-step guide.

Migrating a WordPress site from the command line using an SSH connection and the WP-CLI tool is the most reliable, efficient, and controllable migration method available. Because the transfer does not rely on a web browser, it is entirely free from HTTP timeout limits and file size restrictions, making it ideal for sites of any size—even databases and media libraries spanning tens of gigabytes.

This guide walks you through migrating a site from your previous host to Seravo using wp db, rsync, and wp search-replace commands.

Prerequisites

  • SSH access to both your old server and your new Seravo environment.

  • WP-CLI installed in both environments (WP-CLI is always pre-installed and maintained in all Seravo environments).

  • A new, empty site provisioned at Seravo with a temporary address (e.g., example.fi-c.seravo.com).

Example Environment Configurations

The examples below reference the following placeholder configurations:

  • Old server:

    • Host / IP address: 123.123.123.123 (or oldserver.com)

    • SSH port: 22

    • SSH username: wp-user

    • WordPress installation path: /var/www/htdocs

  • New Seravo server:

    • Host: example.fi-c.seravo.com

    • SSH port: Dedicated SSH port (provided in your welcome email, e.g., 10350)

    • SSH username: Site identifier (e.g., example)

    • WordPress installation path: /data/wordpress/htdocs

Step-by-Step Migration Process

1. Log in to the Old Server and Export the Database

Connect to your old server over SSH:

Export the WordPress database to your home directory using WP-CLI:

wp db export --path=/var/www/htdocs/ ~/database.sql

(Optional: Clean up storage engine definitions)

If the SQL dump contains hard-coded storage engine directives (such as ENGINE=MyISAM), we recommend stripping them out so that Seravo’s MariaDB engine uses its optimized InnoDB configuration by default:

sed -i 's/ENGINE=InnoDB//g' ~/database.sql
sed -i 's/ENGINE=MyISAM//g' ~/database.sql
sed -i 's/ENGINE=MEMORY//g' ~/database.sql

Once the export is complete, close the SSH connection by entering:

exit

2. Log in to the Seravo Server

Open an SSH connection to your Seravo site using the credentials received when ordering:

ssh [email protected] -p 10350

3. Copy Files and Database Dump from the Old Server (rsync)

Fetch the site data directly from the old server to Seravo by running rsync from the Seravo command line:

  1. Download the database dump into Seravo's database directory /data/db/:

    rsync -avz --stats [email protected]:~/database.sql /data/db/
  2. Synchronize the wp-content directory directly into your Seravo WordPress installation:

    rsync -avz --stats [email protected]:/var/www/htdocs/wp-content/ /data/wordpress/htdocs/wp-content/

Note on Directory Layouts:

The command above synchronizes the wp-content directory, which houses your themes, plugins, and media uploads. WordPress core files (wp-admin, wp-includes) do not need to be transferred because WordPress comes pre-installed in Seravo's managed environment. If the old site uses Bedrock or another custom directory architecture, consult our developer documentation.

4. Import the Database into the Seravo Environment

Clear the default placeholder database in your new Seravo installation, then import the SQL dump you just transferred:

wp db reset --yes wp db import /data/db/database.sql

Once the database import finishes successfully, delete the temporary SQL dump to free up disk space:

rm /data/db/database.sql

5. Update Paths and URLs (wp search-replace)

Because file system paths and domains typically change during a migration, update these values across the database:

  1. Update any hard-coded server directory paths:

    wp search-replace '/var/www/htdocs/wp-content' '/data/wordpress/htdocs/wp-content' --all-tables
  2. Enable the temporary development address for review:

    If you want to review and test the site before switching over DNS traffic, replace the live domain with Seravo’s temporary address:

    wp search-replace '//example.com' '//example.fi-c.seravo.com' --all-tables
  3. Purge server and object caches:

    wp-purge-cache

6. Verify Site Integrity and Security

To conclude the migration, run an integrity and security check on your site and review the Seravo Plugin settings in the WordPress admin under Tools > Security.

Finally, test the site’s functionality, layout, and forms in your browser using the temporary address. Once you have confirmed that everything functions properly, you can point your domain traffic to the Seravo server.

Troubleshooting and Edge Cases

  • Non-default database table prefix:

    Seravo's default wp-config.php expects the standard wp_ table prefix. If your previous site used a different prefix (e.g., site_), you can update the $table_prefix variable in /data/wordpress/htdocs/wp-config.php or modify it via the command line before browsing the site.

  • Serialized PHP data in the database:

    Never replace site URLs using raw SQL queries or by editing the SQL dump file with a text editor. The wp search-replace command automatically calculates string length offsets in serialized PHP arrays, preventing widget and plugin settings from corrupting.

  • Server firewall blocking direct rsync connections:

    If your previous server restricts outbound SSH connections to external hosts, you can download database.sql and the wp-content directory to your local device first, then upload them to Seravo over SFTP.

See Also

Using command-line tools provides complete control and precision when migrating even the largest WordPress installations and WooCommerce stores. If you need assistance during your migration or would prefer our team to handle the entire transfer as a service, Seravo's WordPress experts are always available at [email protected].

Did this answer your question?