Skip to content

Instantly share code, notes, and snippets.

@necronet
Created October 5, 2009 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save necronet/202606 to your computer and use it in GitHub Desktop.
Save necronet/202606 to your computer and use it in GitHub Desktop.
<?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