Exporting Databases with WP-CLI
Last Updated -
If you have SSH access, WP-CLI is usually the fastest way to export a copy of your database. In case you're not already familiar with WP-CLI, it's a command line tool for managing WordPress and does a great job at simplifying many common tasks.
Since WP-CLI is an open source tool that's used on most WordPress hosting providers, it's a great host-agnostic solution to use. Whether you're exporting a copy of your WordPress database to move it to Pagely or just making an extra backup for safe keeping it'll work anywhere that WPCLI is installed.
- First, open a terminal window and access your site over SSH. If you need more information on how to do this, see one of the following articles:
- Next, navigate the the root directory of your site. On a VPS with Pagely, this would be something like:
- Next, you'll want to run the export command, being sure to set the export path. For example, to export your database to your sites directory, you would use the following command:
wp db export ~/my_export.sql
Once you run the export command, your database will be exported to the path you've defined. Depending on the size of your database, this can sometimes take a little while.
When your backup is finished, just download it using STFP!