↑ ↓ select, Enter open, Esc close

Back up the WordPress database as a gzip file

Adjust the values, the command updates live
user@server
wp db export - --path=/var/www/vhosts/example.com/httpdocs | gzip > /var/www/vhosts/example.com/db-backup.sql.gz

Creates an SQL dump of the WordPress database via mysqldump and writes it to a compressed file. No credentials need to be entered because WP-CLI takes them from wp-config.php. Ideal before updates, search and replace runs or migrations.

Note: Never store the backup in the web root (httpdocs), otherwise it may be publicly accessible. An existing file with the same name is overwritten.

Also searched as

  • backup wordpress database command line
  • export wordpress db
  • dump database without password

Related one-liners

All in WP-CLI

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.