Sometimes the unexpected happens when making changes to your WordPress website. That’s why it’s always important to make a backup before making big irreversible changes. Because making backups often takes up time we don’t anticipate using, many of us forgo on-demand backups, and that can lead to catastrophic results. Here are 2 quick ways to download a copy of your WordPress database so you can keep building!
Download your database using a plugin
When you’re deploying new features and want to grab a quick snapshot of the database, the All-in-One WP Migration plugin is a life saver.
In the export area of the plugin, it’s super easy to select the item’s you’d like to exclude from the export, and quickly download the database export file. Need to grab more? The plugin will also allow you to backup media, theme, and plugin files if you’re deploying changes spanning across the file system and database.
Download your database via command line
If you haven’t played around with WP CLI (command line interface), you’re missing out on a lightning fast way to complete WordPress-related tasks. To access WP CLI, you’ll need to login to your WordPress server using SSH. If you’re using Nexcess managed WordPress or WooCommerce, just head over to the ‘access’ tab within your control panel. Then, open Terminal (Mac) or CMD (Windows) and type the following:
You’ll be prompted for a password, and you’ll want to make sure you’re using the password for SSH from your host, not your WordPress admin password.
Finally, navigate to the directory that your WordPress installation is in (on Nexcess it’s, “public_html”) and execute the following command:
wp db export
That’s it! Within a few seconds you’ll have an exact copy of your WordPress database.
A quick note: While these are super quick ways to download a copy of your WordPress database, it’s also important to have a nightly backup of your entire environment. I recommend using your host’s nightly backup feature as well as a third party backup service like Backup Buddy or BlogVault. After-all, most people don’t often think about backups until they’re in a sticky situation!
Do you use another method to make DB snapshots? Let me know in the comments!