Skript för att säkerhetskopiera med Php
<?php
define("BACKUP_PATH", "/home/abdul/");
$server_name = "localhost";
$username = "root";
$password = "root";
$database_name = "world_copy";
$date_string = date("Ymd");
$cmd = "mysqldump --routines -h {$server_name} -u {$username} -p{$password} {$database_name} > " . BACKUP_PATH . "{$date_string}_{$database_name}.sql";
exec($cmd);
?>
Skript att återställa
<?php
$restore_file = "/home/abdul/20140306_world_copy.sql";
$server_name = "localhost";
$username = "root";
$password = "root";
$database_name = "test_world_copy";
$cmd = "mysql -h {$server_name} -u {$username} -p{$password} {$database_name} < $restore_file";
exec($cmd);
?>