Skip to content

Programmatically create dump files of entire databases or individual tables and restore from dump files

License

Notifications You must be signed in to change notification settings

hglattergotz/dbbackup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Build Status

Installation

Using Composer:

{
    "require": {
        "hgg/dbbackup": "dev-master"
    }
}

Download source and manually add to project:

  • Get the zip file here

Supported Databases:

  • MySql

Pull Requests for additional database engines welcome!

Usage

Backup entire database

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
}

Backup specific tables in a database

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
}

Restore form a dump file

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
}

About

Programmatically create dump files of entire databases or individual tables and restore from dump files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages