clevis/database-backup
Composer 安装命令:
composer require clevis/database-backup
包简介
README 文档
README
Tiny wrapper around Clevis/MySQLDump library which can limit the maximum number of kept backups. The kept backups are efficiently distributed over the whole period of time this tool is being used. The older the backups are the larger time gap is kept between them.
Visualisation of backups distribution in time
Installation
The recommended way to install this library is to use Composer.
composer require clevis/database-backup
Basic Usage
$mysqli = new mysqli('localhost', 'root', 'password', 'database'); $dumper = new MySQLDump($mysqli); // store backups to directory './backups' and keep at most 100 backups $backup = new Clevis\DatabaseBackup\DatabaseBackup($dumper, __DIR__ . '/backups', 100); $backup->backupDatabase();
If you use dibi, then you can get the $mysqli object this way:
$mysqli = $dibiConnection->getDriver()->getResource();
Advanced Usage
You can customize the created dumps by configuring the $dumper instance.
-
Do not dump table
foo:$dumper->tables['foo'] = $dumper::NONE;
-
Dump only structure, but not data of table
foo:// CREATE TABLE `foo` (...) $dumper->tables['foo'] = $dumper::CREATE; // DROP TABLE `foo` IF EXISTS + CREATE TABLE `foo` (...) $dumper->tables['foo'] = $dumper::CREATE | $dumper::DROP;
-
Dump only some rows in table
foo:$dumper->setCustomDataSelect('foo', 'SELECT * FROM `foo` WHERE `bar` = 1');
-
Do not lock tables while dumping tables:
$dumper->setUseLock(FALSE);
-
For more examples see documentation of Clevis/MySQLDump library.
统计信息
- 总下载量: 257
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-11-26
