---
tags:
  - wordpress
  - migration
  - database
  - ssh
  - wp-cli
title: The Ultimate WordPress Migration Guide: Manual & Plugin Methods
---

# The Ultimate WordPress Migration Guide: Manual & Plugin Methods

Moving a WordPress site from one host to another (or from local to live) is a core skill for any developer. While plugins make it easy for small sites, manual migration is often necessary for large, complex installations.

## Phase 1: Preparation

Before touching anything, ensure you have:
1.  **Access:** FTP/SFTP and Database credentials for *both* the old and new hosts.
2.  **No Caching:** Turn off caching plugins (WP Rocket, W3TC) on the old site to prevent exporting cached files.
3.  **Backup:** Create a full backup of the old site.

## Method A: The Plugin Route (Best for Small Sites < 500MB)

For standard brochure sites, plugins save time and handle the database search-replace automatically.

### Recommended Plugins
*   **All-in-One WP Migration:** Easiest UI, but has upload limits on the free version.
*   **Duplicator:** More robust, creates a standalone installer package.

### The Process (Duplicator)
1.  **Install:** Install Duplicator on the *Old* site.
2.  **Build:** Go to **Duplicator > Packages > Create New**. Scan and Build.
3.  **Download:** Download the `Installer.php` and the `Archive.zip` files.
4.  **Upload:** Upload both files to the `public_html` (or `/var/www/html`) folder of the *New* server.
5.  **Install:** Navigate to `http://new-site.com/installer.php` in your browser.
6.  **Run:** Follow the wizard. It will extract files and update the database URLs automatically.

## Method B: The Manual Route (Best for Large Sites / Developers)

If your site is 5GB+, plugins will likely timeout. The manual method is faster, more reliable, and gives you full control.

### Step 1: Export the Database (Old Host)
Use **phpMyAdmin** or the command line (CLI).

```bash
# CLI Method (SSH)
mysqldump -u db_user -p db_name > data.sql
```

### Step 2: Download Files (Old Host)
Compress the `wp-content` folder. We generally do not need the core WP files (we will install fresh ones), just the content.

```bash
# SSH Method
tar -czf wp-content.tar.gz wp-content/
```
Download `wp-content.tar.gz` and `data.sql` to your local machine or transfer directly to the new server.

### Step 3: Prepare New Host
1.  Install a fresh WordPress instance on the new server.
2.  Delete the `wp-content` folder in the new installation.

### Step 4: Upload and Extract
Upload your `wp-content.tar.gz` and `data.sql` to the new server.

```bash
# Extract content
tar -xzf wp-content.tar.gz
```

### Step 5: Import Database
**Warning:** This overwrites the fresh install's database.

```bash
mysql -u new_db_user -p new_db_name < data.sql
```

### Step 6: Update wp-config.php
Ensure the `wp-config.php` file on the new server has the correct database credentials (`DB_NAME`, `DB_USER`, `DB_PASSWORD`) and table prefix.

## Phase 3: The Search & Replace (Crucial)

Your database still contains links to `http://old-site.com`. You must change them to `http://new-site.com`.

**Do NOT run a simple SQL query.** WordPress stores data in "Serialized Arrays" (PHP objects). A standard SQL replace will break widgets and theme settings because it changes the string length without updating the serialization length count.

### The Tool: WP-CLI (Recommended)
If you have SSH access, this is the safest method.

```bash
# Dry run first
wp search-replace 'http://old-site.com' 'http://new-site.com' --all-tables --dry-run

# Execute
wp search-replace 'http://old-site.com' 'http://new-site.com' --all-tables
```

## Phase 4: Final Checklist

1.  **Permalinks:** Go to **Settings > Permalinks** and click "Save Changes" to regenerate `.htaccess`. This fixes 404 errors.
2.  **SSL:** Ensure your SSL certificate is active.
3.  **Caching:** Re-enable your caching plugins and clear the cache.

## Related Guides
*   [[../linux/Ubuntu-WordPress-Migration-Troubleshooting|Troubleshooting WordPress Migrations]]
*   [[../linux/Ubuntu-WordPress-Backups|Automated WordPress Backups]]