Skip to content

Instantly share code, notes, and snippets.

@rafalosinski
Last active June 22, 2017 21:09
Show Gist options
  • Select an option

  • Save rafalosinski/295bfd921da22102c3f605f95031d53f to your computer and use it in GitHub Desktop.

Select an option

Save rafalosinski/295bfd921da22102c3f605f95031d53f to your computer and use it in GitHub Desktop.
DUMP WordPress SQL DB
<?php
include 'wp-config.php';
$DBUSER = DB_USER;
$DBPASSWD = DB_PASSWORD;
$DATABASE = DB_NAME;
$filename = "backup-" . date("d-m-Y") . ".sql.gz";
$mime = "application/x-gzip";
header( "Content-Type: " . $mime );
header( "Content-Disposition: attachment; filename='" . $filename . "'" );
$cmd = "mysqldump -u $DBUSER --password=$DBPASSWD $DATABASE | gzip --best";
passthru( $cmd );
exit(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment