[sourcecode language="php"]
<?php
$dbName = "db_name";
$dbhost="localhost";
$dbuser="root";
$dbpass="";
$backupFile = $dbName . date("Y-m-d-H-i-s") . '.gz';
$command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbName | gzip > $backupFile";
system($command);
header('Content-disposition: attachment; filename='.$backupFile);
header('Content-type: application/x-gzip');
readfile($backupFile);
?>
[/sourcecode]
No comments:
Post a Comment