No longer maintained! Please use http://github.com/hglattergotz/dbcmd instead
Programmatically create dump files of an entire database or individual tables in a PHP application. Restore from dump files.
Using Composer:
{
"require": {
"hgg/dbbackup": "dev-master"
}
}
Download source and manually add to project:
- Get the zip file here
- MySql
Pull Requests for additional database engines welcome!
use HGG\DbBackup\CmdBuilder\MySql;
use HGG\DbBackup\DbBackup;
try
{
$output = '';
$backup = new DbBackup(new MySql());
$backup->backupDb('username', 'password', 'localhost', 'database',
'backupFile', array(), &$output);
// log $output
}
catch (\Exception $e)
{
// deal with failure
}
use HGG\DbBackup\CmdBuilder\MySql;
use HGG\DbBackup\DbBackup;
try
{
$output = '';
$backup = new DbBackup(new MySql());
$backup->backupTables('username', 'password', 'localhost', 'database',
array('table1', 'table2'), 'backupFile', array(), &$output);
// log $output
}
catch (\Exception $e)
{
// deal with failure
}
use HGG\DbBackup\CmdBuilder\MySql;
use HGG\DbBackup\DbRestore;
try
{
$output = '';
$restore = new DbRestore(new MySql());
$restore->restore('username', 'password', 'localhost', 'database',
'backupFile', array(), &$output);
// log $output
}
catch (\Exception $e)
{
// deal with failure
}