I'm trying to dump a mysql database (back-up). I have the following script. The passthru works and it downloads the file to the client, but I also want it to save a copy of the back-up .gz file on the server, in the /backup/ folder. I can't get it to work. The .gz file downloads to the user, but doesn't get put into the /backup folder.
$filename = $thismoment . "_" . $_GET["t"] . ".gz";
$mime = "application/x-gzip";
system('mysqldump -u $DBUSER --password=$DBPASSWD $DATABASE | gzip > /backup/' . $filename);
header( "Content-Type: " . $mime );
header( 'Content-Disposition: attachment; filename="' . $filename . '"' );
$cmd = "mysqldump -u $DBUSER --password=$DBPASSWD $DATABASE | gzip --best";
passthru( $cmd );
exit(0);