Created
October 5, 2009 23:45
-
-
Save necronet/202606 to your computer and use it in GitHub Desktop.
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 | |
$file_script="data.sql"; | |
//possible option: restore|backup | |
$action="restore"; | |
$user="root"; | |
$pwd="root"; | |
$bd="test"; | |
if($action=="restore"){ | |
//This is the command | |
$cmd="mysql -u $user -p$pwd $bd < $file_script"; | |
$output=shell_exec($cmd); | |
echo $cmd; | |
echo $output; | |
} else if($action=="backup"){ | |
$withprocedure=true; | |
$nodata=true; | |
$option=""; | |
if($withprocedure) | |
$option.="-R "; | |
if($nodata) | |
$option.="--no-data "; | |
$cmd="mysqldump -u $user -p$pwd $option $bd > $file_script"; | |
$output=shell_exec($cmd); | |
echo $cmd; | |
echo $output; | |
} | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment