LochStudios  /  Help Centre  /  WordPress  /  Back Up and Migrate a WordPress Site

Back Up and Migrate a WordPress Site

Learn how to safely back up your WordPress installation and move it to a new host or domain.

Updated

Regular backups protect your WordPress site against loss of data. Migration—moving your site to a new host or domain—is a common task that requires a complete backup and careful reconfiguration. Both processes involve the same core steps: export your database, copy your files, and restore them at the new location.

Part 1: Back Up Your WordPress Site

Automatic Backups via Hosting Control Panel

Most hosting providers offer built-in automated backups. This is the easiest method.

1. Log in to your hosting control panel.
2. Look for "Backups," "Backup," or "Snapshots" (location varies by provider).
3. Enable automatic daily or weekly backups if not already enabled.
4. Download a backup to your computer periodically:
- Locate your most recent backup.
- Click "Download" (if available) and save it to your computer.
- Store it somewhere safe and offline (external drive, cloud storage).

Manual Backup Using a Plugin

For more control, use a WordPress backup plugin.

1. Install a backup plugin:
- Go to Plugins > Add New, search "BackWPup," "UpdraftPlus," or "Duplicator."
- Click Install and Activate.
2. Configure the plugin:
- Go to the plugin's settings page.
- Choose what to back up: database, plugins, themes, uploads, and other files.
- Set a destination: email, cloud storage (Google Drive, Dropbox, OneDrive), or your server.
3. Run a backup:
- Click "Backup Now" or set an automatic schedule (daily recommended).
- Download the backup file to your computer once complete.

Manual Backup Without a Plugin

You can also back up manually via FTP and the control panel.

1. Back up your database:
- In your control panel, find "phpMyAdmin" or "MySQL Databases."
- Click the database name to open it.
- Look for "Export" (top menu).
- Choose "Quick" export format and "SQL" type.
- Click Export and save the .sql file to your computer.
2. Back up your files:
- Via FTP or File Manager, download your entire public_html folder (or the folder where WordPress is installed).
- This includes wp-config.php, the wp-content folder, and all other WordPress files.
- Compress into a ZIP file and save to your computer.

Part 2: Migrate Your WordPress Site

Migration involves three steps: set up the destination, copy files and database, and reconfigure WordPress. The process varies slightly depending on whether you're moving to a new domain, a new host, or both.

Preparation: What You Need

  • Your current site's database export (.sql file).
  • Your current site's files (all WordPress folders and files).
  • Your new host's FTP or File Manager access.
  • Your new host's MySQL database credentials (name, username, password).
  • Your new domain name (already pointed to your new host via DNS).

Step 1: Set Up the New Site

1. Create a MySQL database on your new host:
- In your new host's control panel, go to "MySQL Databases."
- Create a new database (note the name).
- Create a new database user and password (note both).
2. Create a folder for WordPress:
- Via FTP or File Manager on your new host, navigate to public_html.
- Create a new folder or use the root—decide where your new WordPress will live (root for a full domain, or a subfolder).

Step 2: Upload Files to New Host

1. Via FTP or File Manager, upload all your WordPress files to the new folder:
- Upload everything from your backup: wp-admin, wp-content, wp-includes, *.php files, etc.
- This typically takes 10–30 minutes depending on file count and upload speed.
2. Edit wp-config.php for the new database:
- After uploading, edit wp-config.php in your new location.
- Update these lines with your new host's database credentials:
```php
define( 'DBNAME', 'newdatabase_name' );
define( 'DBUSER', 'newdatabase_user' );
define( 'DBPASSWORD', 'newdatabase_password' );
define( 'DB_HOST', 'localhost' );
```
- Save the file.

Step 3: Import Your Database

  1. In your new host's control panel, open phpMyAdmin (or similar database tool).
  2. Select the new, empty database you created in Step 1.
  3. Look for "Import" (usually top menu).
  4. Choose "Browse" and select your .sql backup file from your computer.
  5. Click "Go" or "Import" and wait for completion (may take several minutes for large databases).

Step 4: Update WordPress URLs

If you changed domains (e.g., oldsite.com → newsite.com), you must update all URLs stored in your database.

Option A: Use a Plugin (Easiest)

1. Install a migration plugin like "Better Search Replace":
- Go to Plugins > Add New, search "Better Search Replace."
- Click Install and Activate.
2. Go to Tools > Better Search Replace.
3. In the "Find" field, enter your old domain: http://oldsite.com or https://oldsite.com
4. In the "Replace" field, enter your new domain: http://newsite.com or https://newsite.com
5. Click "Replace All" (but first check "Dry Run" if you're nervous).

Option B: Database Directly

If you're comfortable with SQL:

1. Open phpMyAdmin on your new host.
2. Go to the SQL tab and run:
```sql
UPDATE wpoptions SET optionvalue = replace(optionvalue, 'http://oldsite.com', 'https://newsite.com') WHERE optionname = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://oldsite.com', 'https://newsite.com');
UPDATE wpposts SET postcontent = replace(post_content, 'http://oldsite.com', 'https://newsite.com');
```
3. Click "Go".

Step 5: Update WordPress Settings

  1. Log in to WordPress at your new domain/URL.
  2. Go to Settings > General.
  3. Verify "WordPress Address" and "Site Address" match your new domain and include https:// if using HTTPS.
  4. Click Save.

Step 6: Test Everything

  1. Visit your new site in a browser—pages, images, and links should work.
  2. Log in to the admin panel and verify all content is there.
  3. Check a few internal links to ensure they point to the new domain.
  4. Test contact forms or other interactive features.

Step 7: Update DNS and Finalize

1. If you're moving to a new domain:
- Update your domain's DNS records to point to your new host (your new host provides instructions).
- This may take up to 24 hours to propagate.
- Use an online DNS checker to verify the change.
2. Once DNS is updated and the new site is live, you can cancel your old hosting.

Troubleshooting

Site shows "Error establishing a database connection"
- Double-check your database name, username, and password in wp-config.php match what's in the control panel.

Images don't show / links are broken
- Your old domain is still in the database. Re-run the "Replace URLs" step above.

Admin login fails after migration
- Clear your browser cache and cookies (Ctrl+Shift+Delete). Try an incognito browser window.

Site is very slow after migration
- Contact your new host—you may have hit resource limits. Consider upgrading your plan.

Old domain still shows the old site
- DNS propagation hasn't completed. Wait up to 24 hours and try again. Or check that your DNS records actually updated.

Best Practices

  • Back up before major changes—don't rely on hosting backups alone.
  • Test migrations on a temporary domain first before pointing your real domain to the new host.
  • Keep your old hosting active for 48 hours after DNS switches so visitors on old caches can still reach your content.
  • Document your database and FTP credentials securely for future migrations.

Migration is straightforward once you understand the three core pieces: files, database, and URLs. Most migrations complete successfully in an afternoon.


Was this article helpful?

← Back to WordPress