Skip to content

Instantly share code, notes, and snippets.

@lukecav
Last active January 9, 2024 06:48
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukecav/f333618818b2be33bb8ff96a0d90faac to your computer and use it in GitHub Desktop.
Save lukecav/f333618818b2be33bb8ff96a0d90faac to your computer and use it in GitHub Desktop.
Speed up wp db export using WP-CLI
# Export site database using wp db export
wp db export /wp-content/wordpress-dump.sql --all-tablespaces --single-transaction --quick --lock-tables=false
# Gzip compress the recent database export
gzip wordpress-dump.sql
# Export sites database using wp db export and gzip compress
wp db export --all-tablespaces --single-transaction --quick --lock-tables=false - | gzip -9 - > wordpress-dump.sql.gz
@dustinrue
Copy link

FWIW you can gzip it on the fly and save the last step

wp db export --all-tablespaces --single-transaction --quick --lock-tables=false - | gzip -9 - > wordpress-dump.sql.gz

The - in the command will output the stream to stdout which is piped to gzip. gzip -9 will apply max compression and then stream that to stdout, which is redirected to the final file

@michael-sumner
Copy link

Thanks @dustinrue it worked like a charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment