preparing admin route for db backup

This commit is contained in:
Torsten 2024-03-20 11:06:19 +01:00
parent 950fbe1755
commit 883897ec3c
3 changed files with 516 additions and 0 deletions

View file

@ -0,0 +1,23 @@
<?php
$DBUSER = $_GET["dbuser"];
$DBPASSWD = $_GET["dbpasswd"];
$DATABASE = $_GET["database"];
#echo("$DBUSER, $DBPASSWD, $DATABASE");
//http://localhost:8005/backup?dbuser=user&dbpasswd=passwd&database=db1
$filename = "backup-" . date("d-m-Y") . ".sql.gz";
echo($filename);
$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);
?>