How to Back Up a WordPress Site Before Migration

Short answer: To back up a WordPress site before migration, you need two components: the WordPress files (wp-content, core, and config files) and the database. You can use a plugin like UpdraftPlus, manually via cPanel’s phpMyAdmin and File Manager, or with WP-CLI. A plugin is easiest for most. Make sure to download the backup to your local machine.

Key takeaways

  • Always back up both files and database before migrating.
  • A plugin like UpdraftPlus is the simplest method for most users.
  • Manual backup via cPanel gives you full control.
  • WP-CLI is fast for developers comfortable with the command line.
  • Test your backup by restoring to a staging site first.
  • Store backups in a safe remote location, not just on your server.

Skipping a backup before migration is like moving houses without packing. It’s a disaster waiting to happen. I’ve seen sites vanish from a misclicked plugin or a faulty FTP transfer. A proper backup ensures you have a safety net. Here’s how to back up a WordPress site before migration, covering plugin, manual, and command-line methods.

Workspace with computer and coffee showing a backup in progress for WordPress migration
A clean backup process starts at your desk. — Photo: freephotocc / Pixabay

What Do You Need to Back Up?

A complete WordPress backup has two parts: files and the database. Files include your core WordPress installation, themes, plugins, uploads, and the wp-config.php file. The database holds your posts, pages, comments, user data, and settings. You need both to fully restore a site.

Missing either piece will break your migration. For example, uploading files without the database means you get a blank installation. Conversely, importing only the database to a fresh install loses your themes and media. So always grab both.

Method 1: Use a Backup Plugin

This is the easiest method for most site owners. Plugins handle the complexity. You don’t need SSH access or cPanel knowledge. Here’s the step-by-step process with a popular free plugin.

Step 1: Install and Activate UpdraftPlus

Go to Plugins > Add New in your WordPress admin. Search for UpdraftPlus. Install and activate it. The free version is sufficient for standard backups.

Step 2: Configure Backup Settings

Navigate to Settings > UpdraftPlus Backups. Under the Settings tab, you can choose what to back up: database, plugins, themes, uploads, other files. Select all components for a full backup. Choose a remote storage location like Google Drive or Dropbox. I recommend off-site storage – if your server crashes, a backup on the same server isn’t helpful.

Step 3: Run the Backup

Go to the Current Status tab and click the Backup Now button. A dialog will ask if you want to include the database and files. Check both and click Start Backup. Wait for completion. You’ll see a success message and a download option. Download the backup files to your computer. They are zip archives labelled with the date.

That’s it. Your full backup is now safely off-site and on your local machine.

Method 2: Manual Backup via cPanel

Manual backup gives you complete control. It’s ideal when you don’t trust plugins or need to inspect the files. It requires cPanel access from your hosting provider.

Backing Up the Files

  1. Log into cPanel and open File Manager.
  2. Navigate to public_html (or your site’s root folder).
  3. Select all files and folders (Ctrl+A or Cmd+A). Right-click and choose Compress. Select Zip Archive. Name it something like wp-backup-files.zip.
  4. Once compressed, right-click the zip and choose Download. Save it to your computer.

Backing Up the Database

  1. In cPanel, open phpMyAdmin.
  2. Select your WordPress database from the left sidebar. The name is usually something like youruser_wp.
  3. Click the Export tab. Choose the Quick export method and SQL format. Then click Go.
  4. A .sql file will download. Rename it to something like wordpress-db-backup.sql.

Now you have both files and database backed up manually. Keep them in a safe folder on your computer.

Method 3: Backup via WP-CLI

For developers and sysadmins comfortable with the command line, WP-CLI is fast and scriptable. It’s perfect for automation or headless servers.

Export the Database

SSH into your server, navigate to your WordPress root, then run:

wp db export backup.sql

This creates a backup.sql file in the current directory. You can specify a custom path.

Back Up the Files

Use a simple tar command to compress the entire directory:

tar -czf wordpress-backup.tar.gz .

This creates a single archive of all files. Download it to your local machine using SCP or a file transfer tool.

WP-CLI is efficient and doesn’t require a browser. You can script both commands to run simultaneously. It’s my go-to for bulk migrations.

Server rack in a data center illustrating where WordPress backups can be stored
Off-site storage keeps your backups safe. — Photo: valaymtw / Pixabay

Comparing Backup Methods

Here’s a quick comparison to help you decide which approach fits your situation.

MethodDifficultySpeedBest For
Plugin (UpdraftPlus)EasyModerateMost users, beginners
Manual (cPanel)MediumSlowWhen plugin fails, full control
WP-CLIAdvancedFastDevelopers, automation

Common Backup Mistakes and How to Avoid Them

Even experienced developers slip up. Here are pitfalls I’ve encountered and how to dodge them.

  • Forgetting the database. Files alone won’t restore a site. Always back up the database separately if you’re doing it manually.
  • Storing backup on the same server. If the server fails, your backup goes with it. Use remote storage.
  • Not verifying the backup. A backup file that’s 0 KB is useless. Test by restoring to a staging environment.
  • Using an outdated backup. Before migration, make a fresh backup just before the move. Weeks-old backups miss recent changes.
  • Ignoring file permissions. When restoring via manual methods, improper file ownership can break the site. Ensure permissions match the original.

After you back up, consider testing the migration on a staging site first. This catches any issues before touching the live site.

What to Do After the Backup

You have your backup. Now what? First, ensure you can restore it. Create a staging environment – many hosts offer a one-click staging feature. Upload your backup files and database there. If the site works, your backup is solid.

For a step-by-step walkthrough on restoring and migrating, see our guide How to Back Up a WordPress Site Before Migration – Step by Step. It covers the full process from backup to live migration.

Next, plan your migration. Move the backup to the destination server. Then import the database and files. After migration, run through a checklist: check permalinks, test forms, scan for broken links. And don’t delete the old site until you’re sure the new one is stable.

Backup isn’t just for migration. Make it a routine. Weekly backups with off-site storage save you from many disasters. Automate it with a plugin or a cron job using WP-CLI. Set it and forget it – but occasionally verify the backup works.

You’re now prepared to migrate safely. The only thing worse than no backup is a backup you can’t restore. So test, test, test.

Frequently asked questions

Do I need to back up both files and database for a WordPress migration?

Yes, absolutely. The files contain your theme, plugins, uploads, and configuration. The database holds all your content, settings, and user data. If you skip either one, the site will not work after migration. A complete restore requires both components.

Can I use a backup from a different WordPress version?

Generally yes, but it’s not recommended. The database may be compatible with newer versions, but files from an old version could have security issues or compatibility problems. Always use a backup made just before migration. If you must restore an older backup, update WordPress afterward.

Is it safe to leave backups on my server?

It is not safe as a sole backup. If your server crashes or gets hacked, the backup is lost. Always download a copy to your local machine or store it in a remote location like cloud storage. Server-based backups should be considered a convenience, not a reliable backup strategy.

How long does a typical WordPress backup take?

It depends on the method and site size. A plugin backup for a small blog (under 500 MB) might take 2–5 minutes. Larger sites with many images can take 10–20 minutes. Manual cPanel backups are slower due to compression. WP-CLI is fastest and can complete the same task in under a minute.

What if my backup plugin fails during the backup?

First, check your server’s error logs. Common causes are low memory limits, file permission issues, or a timeout. Increase PHP memory limit and max execution time. Alternatively, try a manual backup via cPanel or WP-CLI. If the issue persists, contact your host for support.

Leave a Comment