Created
May 24, 2018 10:01
-
-
Save gdevlugt/aeda700063f2229020594dc3d30d22af to your computer and use it in GitHub Desktop.
MySQL database dump script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$DBUSER="user"; | |
$DBPASSWD="password"; | |
$DATABASE="user_db"; | |
$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