Beginner’s Guide to Database Backups for Website Migration

Short answer: To backup your database for migration, you can use phpMyAdmin to export a SQL file, a plugin like UpdraftPlus, or the command line mysqldump. Always export a complete copy and verify the file before proceeding.

Key takeaways

  • Database backup is essential to avoid data loss during migration.
  • You can back up manually via phpMyAdmin or use plugins.
  • Command-line mysqldump is fast for large databases.
  • Always verify your backup file is complete and uncorrupted.
  • Test the backup on a staging site before migrating production.
  • Keep multiple backup copies in different locations.

Moving your website to a new host, new domain, or new platform is a big step. The scariest part? Losing your data. Your database holds posts, pages, users, comments, settings, and more. If that gets corrupted or goes missing, your site is gone. A reliable database backup is your safety net. This guide walks you through everything you need to know about database backups for website migration—from what a database is to testing your backup. You’ll learn three practical methods: phpMyAdmin, plugins, and the command line. No fluff, just the steps.

What Is a Website Database and Why Do You Need to Back It Up?

A website database stores all your content in structured tables. For WordPress, that means your posts, pages, user data, comments, options, and plugin settings. Without it, you’d have an empty shell. During migration, you move that database from one server to another. If something breaks—wrong export settings, interrupted transfer, server timeout—you can lose data permanently. A backup lets you restore if things go wrong.

Backing up your database also protects you from other disasters: server crashes, hacked sites, botched updates. Even if you’re just migrating, treat the backup as your insurance policy. Many beginners skip this step and regret it later. Don’t be that person.

Manual Database Backup Using phpMyAdmin

phpMyAdmin is a web-based tool included in most hosting control panels (cPanel, Plesk, DirectAdmin). It’s free and works for any MySQL database. Here’s how to export your database:

  1. Log into your hosting control panel.
  2. Open phpMyAdmin (look for the icon under Databases).
  3. Select your database from the left sidebar. You’ll see a list of tables.
  4. Click the “Export” tab at the top.
  5. Choose “Custom” export method for more control.
  6. In “Tables”, select all tables. Keep default options: structure and data.
  7. Scroll down and under “Output”, select “Save output to a file”.
  8. Compression: choose “gzipped” or “zipped” to save space.
  9. Click “Go”. A .sql.gz file downloads to your computer.

That file is your database backup. Store it safely. On macOS, you can verify the file by opening it with a text editor—it should start with “SQL dump” and contain readable SQL statements. On Windows, use Notepad or any editor.

Common phpMyAdmin Mistakes

  • Exporting the wrong database: Double-check the database name. If your site uses multiple databases, back up all of them.
  • Choosing “Quick” export: The quick export skips some settings and might not include triggers or events. Use “Custom” for reliability.
  • Interrupted download: Large databases can time out. If yours is over 50 MB, consider using mysqldump instead.
Screenshot of phpMyAdmin export tab for database backups
Exporting a database using phpMyAdmin — Photo: MICHOFF / Pixabay

Using a Plugin to Backup Your Database (WordPress)

If you’re not comfortable with phpMyAdmin, plugins simplify the process. Many backup plugins let you create database-only backups or full site backups. For migration-focused backups, plugins can export just the database without media files. For a full walkthrough, check out How to Backup Your WordPress Site Before Migration.

Popular free options include UpdraftPlus, BackWPup, and Duplicator. These plugins offer scheduled backups and cloud storage integration. Here’s a generic workflow:

  1. Install and activate the backup plugin.
  2. Go to the plugin’s settings page.
  3. Choose to create a new backup.
  4. Select “Database only” if you’ve already backed up your files.
  5. Choose a destination (download to computer, Dropbox, Google Drive).
  6. Start the backup. The plugin will export the database and store it.

After the backup, verify the file size and name. Most plugins include the date in the filename. You can also restore the backup on a test site to confirm it works.

Plugins are convenient but add dependency. If you ever lose access to your WordPress admin, you can’t use a plugin to restore. That’s why knowing manual methods is valuable. For a comparison of manual vs plugin approaches, read Manual vs Plugin Backups: Which Is Better for Migrations?.

Command Line Backup Using mysqldump

If you have SSH access to your server, mysqldump is the fastest method. It’s a command-line utility that comes with MySQL. This method is ideal for large databases or automated backups. Here’s the basic command:

mysqldump -u username -p database_name > backup.sql

Replace username with your database username, database_name with your database name. The -p flag prompts for the password. The output file is backup.sql. To compress it, pipe through gzip:

mysqldump -u username -p database_name | gzip > backup.sql.gz

For a full backup that includes triggers, routines, and events, add --routines --triggers --events:

mysqldump -u username -p --routines --triggers --events database_name | gzip > backup.sql.gz

Once the command finishes, download the file using SCP or SFTP. You can also set up a cron job to automate backups regularly.

When to Use mysqldump Over phpMyAdmin

  • Your database is over 500 MB.
  • You need to schedule backups.
  • You prefer working in the terminal.
  • Your phpMyAdmin times out on large exports.

How to Verify Your Database Backup Is Valid

A backup file is useless if it’s corrupt. Always verify before you migrate. Here are three ways to check:

  1. Check file size: Open your file manager. The backup should be roughly the same size as your database. A zero-byte file means failure.
  2. Inspect the contents: Open the .sql file in a text editor (use a large one like Sublime Text). Look at the beginning—it should show SQL statements like CREATE TABLE or INSERT INTO. If you see garbled text or the file is empty, the backup is bad.
  3. Import to a test database: Create a new database on your local machine or a staging server. Import the backup using phpMyAdmin or the command line. If the import completes without errors, the backup is valid.

Never rely on a single backup. Create at least two copies: one on your computer and one in cloud storage. If one fails, you have a fallback.

Server room with backup drives for website database migration
Server room infrastructure for data backups — Photo: Bru-nO / Pixabay

Common Database Backup Mistakes and How to Avoid Them

MistakeWhy It’s DangerousHow to Avoid
Skipping backup entirelyOne failure and your site is goneMake backup a mandatory step before any migration
Using outdated backupChanges made after backup are lostCreate a fresh backup right before migration
Not verifying the backupYou won’t know it’s corrupt until you need itAlways run a test import
Storing backup only on the serverServer failure wipes both site and backupDownload a local copy and store off-server
Exporting only some tablesMissing plugin or custom table dataExport all tables unless you know exactly what you need

How to Restore a Database Backup on Your New Host

Once you’ve backed up the old database, you need to import it on the new server. The process is similar to exporting, but in reverse:

  1. Create a new database on the new host. Note the database name, username, and password.
  2. In phpMyAdmin on the new host, select the new database.
  3. Click the “Import” tab.
  4. Choose your backup file (.sql or .sql.gz).
  5. Click “Go”. If the file is large, your host may time out. In that case, use the command line:
mysql -u username -p database_name < backup.sql

After importing, update your website’s configuration file (e.g., wp-config.php for WordPress) with the new database credentials. Then test your site thoroughly. Check pages, posts, users, and any dynamic content.

Final Tips for a Safe Migration

Database backups are just one piece of the migration puzzle. Don’t forget to backup your site files too. Always run your migration on a staging site first if possible. Test everything before pointing your domain to the new host. If something goes wrong, you have your backup ready to restore. Remember: a good backup is verified, stored in multiple places, and created moments before you start the migration. That’s how you sleep well during a website transfer.

Frequently asked questions

What is the easiest way to backup a WordPress database for migration?

For beginners, using a plugin like UpdraftPlus is the easiest. Install the plugin, create a database-only backup, and download the file. If you don’t have plugin access, phpMyAdmin in your hosting control panel is also straightforward.

Can I backup my database without using phpMyAdmin?

Yes. You can use a WordPress backup plugin, or if you have SSH access, use the command line tool mysqldump. Both methods create a complete SQL backup file you can download.

How do I know if my database backup is corrupted?

Check the file size—zero bytes means failure. Open the file in a text editor; it should contain SQL statements. The best test is importing the backup into a test database. If no errors occur, the backup is valid.

Should I backup both the database and files for a migration?

Yes. Your database contains dynamic content, but your files include themes, plugins, uploads, and configuration. Both are needed to recreate your site. Back them up separately or use a full-site backup plugin.

How often should I backup my database before migration?

You should create a fresh backup immediately before starting the migration. If your site changes frequently, make a backup just hours before you begin. Older backups may miss recent posts or settings changes.

2 thoughts on “Beginner’s Guide to Database Backups for Website Migration”

Leave a Comment