{
"require": {
"codexshaper/database-backup-restore": "^1.1"
}
}
<?php
$options = [
'host' => 'HOST',
'port' => 'PORT',
'dbName' => 'DATABASE_NAME',
'username' => 'DATABASE_USERNAME',
'password' => 'DATABASE_PASSWORD',
'destinationPath' => 'STORAGE_PATH_WITH_FILE_NAME', // /path/to/backups/mysql/dump
];
$dumper = new \CodexShaper\Dumper\Drivers\MysqlDumper($options);
$dumper->dump();
\CodexShaper\Dumper\Drivers\MysqlDumper::create($options)->dump();
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->setHost('localhost')
->setPort('3306')
->setDbName('dbName')
->setUserName('userName')
->setPassword('password')
->setDestinationPath('destination_path')
->dump();
\CodexShaper\Dumper\Drivers\MysqlDumper::create($options)
->useCompress("gzip") // This command apply gzip to zip
->dump();
$dumper = new \CodexShaper\Dumper\Drivers\MysqlDumper($options);
$dumper->setRestorePath($restorePath); // /path/to/backups/mysql/dump.sql
$dumper->restore();
\CodexShaper\Dumper\Drivers\MysqlDumper::create($options)
->useCompress("gunzip") // this command unzip the file
->setRestorePath($restorePath) // /path/to/backups/mysql/dump.sql.gz
->restore();
<?php
$options = [
'host' => 'HOST',
'port' => 'PORT',
'dbName' => 'DATABASE_NAME',
'username' => 'DATABASE_USERNAME',
'password' => 'DATABASE_PASSWORD',
'destinationPath' => 'STORAGE_PATH_WITH_FILE_NAME', // /path/to/backups/pgsql/dump
];
$dumper = new \CodexShaper\Dumper\Drivers\PgsqlDumper($options);
$dumper->dump();
\CodexShaper\Dumper\Drivers\PgsqlDumper::create($options)->dump();
\CodexShaper\Dumper\Drivers\PgsqlDumper::create()
->setHost('localhost')
->setPort('3306')
->setDbName('dbName')
->setUserName('userName')
->setPassword('password')
->setDestinationPath('destination_path')
->dump();
\CodexShaper\Dumper\Drivers\PgsqlDumper::create($options)
->useCompress("gzip") // This command apply gzip to zip
->dump();
$dumper = new \CodexShaper\Dumper\Drivers\PgsqlDumper($options);
$dumper->setRestorePath($restorePath); // /path/to/backups/pgsql/dump.sql
$dumper->restore();
\CodexShaper\Dumper\Drivers\PgsqlDumper::create($options)
->useCompress("gunzip") // this command unzip the file
->setRestorePath($restorePath) // /path/to/backups/pgsql/dump.sql.gz
->restore();
$options = [
'dbName' => 'DATABASE_PATH', // /path/to/database.sqlite
'destinationPath' => 'STORAGE_PATH_WITH_FILE_NAME', // /path/to/backups/sqlite/dump.sql
];
$dumper = new \CodexShaper\Dumper\Drivers\SqliteDumper($options);
$dumper->dump();
\CodexShaper\Dumper\Drivers\SqliteDumper::create($options)->dump();
\CodexShaper\Dumper\Drivers\SqliteDumper::create()
->setDbName($database)
->setDestinationPath($destinationPath)
->dump();
\CodexShaper\Dumper\Drivers\SqliteDumper::create()
->setDbName($database)
->setDestinationPath($destinationPath)
->useCompress("gzip") // This command apply gzip to zip
->dump();
$options = [
'dbName' => 'DATABASE_PATH', // /path/to/database.sqlite
'restorePath' => 'RESTORE_PATH_WITH_FILE_NAME', // /path/to/backups/sqlite/dump.sql
];
$dumper = new \CodexShaper\Dumper\Drivers\SqliteDumper($options);
$dumper->restore();
$dumper = new \CodexShaper\Dumper\Drivers\SqliteDumper($options);
$dumper->restore();
\CodexShaper\Dumper\Drivers\SqliteDumper::create()
->setDbName($database)
->setRestorePath($restorePath)
->useCompress("gunzip") // This command apply gzip to zip
->restore();
$options = [
'host' => 'HOST',
'port' => 'PORT',
'dbName' => 'DATABASE_NAME',
'username' => 'DATABASE_USERNAME',
'password' => 'DATABASE_PASSWORD',
'destinationPath' => 'STORAGE_PATH_WITH_FILE_NAME', // /path/to/backups/mongodb/dump
];
$dumper = new \CodexShaper\Dumper\Drivers\MongoDumper($options);
$dumper->dump();
\CodexShaper\Dumper\Drivers\MongoDumper::create($options)->dump();
\CodexShaper\Dumper\Drivers\MongoDumper::create()
->setHost($host)
->setPort($port)
->setDbName($database)
->setUserName($username)
->setPassword($password)
->setDestinationPath($destinationPath)
->dump();
\CodexShaper\Dumper\Drivers\MongoDumper::create($options)
->useCompress("gzip") // This command will add --archive with --gzip
->dump();
$options = [
'uri' => $uri,
"destinationPath" => $destinationPath, // /path/to/backups/mongodb/dump
];
$dumper = new \CodexShaper\Dumper\Drivers\MongoDumper($options);
$dumper->dump();
\CodexShaper\Dumper\Drivers\MongoDumper::create(['uri' => $uri])
->setDestinationPath($destinationPath)
->dump()
\CodexShaper\Dumper\Drivers\MongoDumper::create()
->setUri($uri)
->setDestinationPath($destinationPath)
->dump()
\CodexShaper\Dumper\Drivers\MongoDumper::create(['uri' => $uri])
->useCompress("gzip")
->setDestinationPath($destinationPath)
->dump();
$dumper = new \CodexShaper\Dumper\Drivers\MongoDumper($options);
$dumper->setRestorePath($restorePath); // /path/to/backups/mongodb/dump
$dumper->restore();
\CodexShaper\Dumper\Drivers\MongoDumper::create($options)
->useCompress("gzip")
->setRestorePath($restorePath) // /path/to/backups/mongodb/dump.gz
->restore();
\CodexShaper\Dumper\Drivers\MongoDumper::create(['uri' => $uri])
->setRestorePath($restorePath)
->restore();
\CodexShaper\Dumper\Drivers\MongoDumper::create(['uri' => $uri])
->useCompress("gzip")
->setRestorePath($restorePath)
->restore();
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create($options)
->setCommandBinaryPath($binaryPath) // /path/to/mysql/bin
->dump();
useSingleTransaction - use single transaction
This method enable the single transaction and return the current object instance
This method doesn't support any parameter
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->useSingleTransaction();
useSkipLockTables - skip lock tables
This method enable the skip lock tables and return the current object instance
This method doesn't support any parameter
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->useSkipLockTables();
useQuick - use quick
This method enable the quick transaction and return the current object instance
This method doesn't support any parameter
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->useQuick();
doNotUseSkipComments - don not skip comments
This method disable the skip comments and return the current object instance
This method doesn't support any parameter
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->doNotUseSkipComments();
doNotCreateTables - don not create tables
This method disable the create table and return the current object instance
This method doesn't support any parameter
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->doNotCreateTables();
setDefaultCharacterSet - Set default charecter set
This method set the charecterSet and return the current object instance
Accept charecterSet as string
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->setDefaultCharacterSet("utf8");
getDumpCommand - get dump command for mysql
This method return the dump command for mysql
Optional. Accept credentialFile as string. The default value is empty string
Optional. Accept destinationPath as string. The default value is empty string
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->getDumpCommand('credentials.txt', '/path/to/destination/dump.sql');
getRestoreCommand - get restore command for mysql
This method return the restore command for mysql
Optional. Accept credentialFile as string. The default value is empty string
Optional. Accept filePath as string. The default value is empty string
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->getRestoreCommand('credentials.txt', '/path/to/rstore/dump.sql');
Pgsql methods
useInserts - use inserts
This method enble the inserts and return the current object instance
This method doesn't support any parameter
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\PgsqlDumper::create()
->useInserts();
MongoDB methods
setUri - set uri
This method set the database uri and return the current object instance
Uri as string
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MongoDumper::create()
->setUri("uri");
setCollection - set collection
This method set the database collection and return the current object instance
Collection as string
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MongoDumper::create()
->setCollection("test1");
setAuthenticationDatabase - set authentication database
This method set the authentication database name and return the current object instance
Authentication database name as string
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MongoDumper::create()
->setAuthenticationDatabase("admin");
setDbName - Set database name
This method set the database name and return the current object instance
Database as a string
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->setDbName("dbname");
setUserName - Set database username
This method set the database username and return the current object instance
Username for the selected database
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->setUserName("root");
setPassword - Set database password
This method set the database password and return the current object instance
Password for the selected database
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->setPassword("password");
setHost - Set database host
This method set the database host and return the current object instance
Host for the selected database
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->setHost("localhost");
setPort - Set database port
This method set the database port and return the current object instance
Port for the selected database
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->setPort("3306");
setSocket - Set database socket
This method set the database socket and return the current object instance
Socket for the selected database
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->setSocket("socket");
setTimeOut - Set timeout
This method set the database timeout and return the current object instance
Timeout in milliseconds
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->setTimeOut("milliseconds");
setTables - Set include tables
This method include tables to download only provided tables and return the current object instance
Accept tables string or array
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->setTables(['test1', 'test2', 'test3']);
setIgnoreTables - Set exclude tables
This method ignore provided tables to download and return the current object instance
Accept tables string or array
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->setIgnoreTables(['test1', 'test2', 'test3']);
setCommandBinaryPath - Set binary path to dump or restore
This method sets the binary path for dump or restore command and return the current object instance
Accept path as string
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->setCommandBinaryPath('/path/to/mysql/bin');
setDestinationPath - Set the destination path
This method set the destination path for dumper to store and return the current object instance
Accept path as string
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->setDestinationPath('/path/to/mysql/dump.sql');
setRestorePath - Set the retore path
This method set the retore path for dumper to restore and return the current object instance
Accept path as string
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->setRestorePath('/path/to/mysql/dump.sql');
setCompressBinaryPath - Set the compressor command binary path
This method set the compressor command binary path and return the current object instance
Accept path as string
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->setCompressBinaryPath('/path/to/bin');
setCompressCommand - Set the compress command
This method set the compress command and return the current object instance
Accept command as string
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->setCompressCommand('gzip');
setCompressExtension - Set the compress extension
This method set the compress extension and return the current object instance
Accept extension as string
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->setCompressExtension('.gz');
useCompress - Set the compress command, extension, binary path
This method set the compress command, extension, and binary path in single call and return the current object instance
Optional. Accept command as string. The default value is gzip
Optional. Accept extension as string. The default value is .gz
Optional. Accept binary_path as string. The default value is empty string.
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->useCompress('gzip', '.gz', '/path/to/bin');
enableDebug - Set the enable debug
This method set the compress extension and return the current object instance
This method doesn't support any parameter
This method return the current object
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->enableDebug();
dump - get dump command
This method dump sql data and return nothing
Optional. Accept destinationPath as string. Default is empty string
This method return nothing
// Same for other driver
\CodexShaper\Dumper\Drivers\SqliteDumper::create()
->dump('/path/to/destination/dump.sql');
restore - get restore command
This method restore sql data and return nothing
Optional. Accept restorePath as string. Default is empty string
This method return nothing
// Same for other driver
\CodexShaper\Dumper\Drivers\SqliteDumper::create()
->restore('/path/to/restore/dump.sql');
getDbName - get database name
This method return the database name
This method doesn't support any parameter
This method return the database name
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->getDbName();
getUserName - get database username
This method return the database username
This method doesn't support any parameter
This method return the database username
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->getUserName();
getPassword - get database password
This method return the database password
This method doesn't support any parameter
This method return the database password
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->getPassword();
getHost - get host name
This method return the host name
This method doesn't support any parameter
This method return the host name
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->getHost();
getPort - get port
This method return the port
This method doesn't support any parameter
This method return the port
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->getPort();
getSocket - get socket
This method return the socket
This method doesn't support any parameter
This method return the socket
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->getSocket();
getTimeOut - get timeout
This method return the timeout
This method doesn't support any parameter
This method return the timeout
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->getTimeOut();
getCommandBinaryPath - get command binary path
This method return the command binary path
This method doesn't support any parameter
This method return the command binary path
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->getCommandBinaryPath();
getDestinationPath - get destination path
This method return the destination path
This method doesn't support any parameter
This method return the destination path
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->getDestinationPath();
getRestorePath - get restore path
This method return the restore path
This method doesn't support any parameter
This method return the restore path
// Same for other driver
\CodexShaper\Dumper\Drivers\MysqlDumper::create()
->getRestorePath();
getDumpCommand - get dump command
This method return the dump command
Optional. Accept destinationPath as string. Default is empty string
This method return the dump command
// Same for other driver
\CodexShaper\Dumper\Drivers\SqliteDumper::create()
->getDumpCommand('/path/to/destination/dump.sql');
getRestoreCommand - get dump command
This method return the dump command
Optional. Accept filePath as string. Default is empty string
This method return the dump command
// Same for other driver
\CodexShaper\Dumper\Drivers\SqliteDumper::create()
->getRestoreCommand('/path/to/restore/dump.sql');