lily-labs/db-backup 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lily-labs/db-backup

Composer 安装命令:

composer require lily-labs/db-backup

包简介

DBBackup it's a library that provides classes to execute mysqldump to backup the given database, relocate the backup file in the local filesystem and compress the resulting backup file.

README 文档

README

Latest Version on Packagist Build Status Quality Score Total Downloads

DBBackup it's a library that provides classes to execute mysqldump to backup the given database, relocate the backup file in the local filesystem and compress the resulting backup file.

Requirements

  • PHP 7.1+
  • MySQL client/server version 5.6.x
  • Gzip on the server (only tested on unix)

Installation

You can install the package via composer:

composer require lily-labs/db-backup

For the backup process to work, it requires that you pre-configure a local login for mysql on your server using mysql_config_editor as follows:

mysql_config_editor set --login-path=local --host=localhost --user=username --password

Your database password will be asked after entering the command.

You can se more information here

Usage

First create a BackupFileNameGenerator, this will generate the desire filename for the backup file, the default implementation LilyLabs\DBBackup\BasicBackupFileNameGenerator will generate a file name in this format: "[database_name]_[year]-[month]-[day].sql"

use LilyLabs\DBBackup\BasicBackupFileNameGenerator;
use LilyLabs\DBBackup\MysqldumpBackupProcessor;

$db_name = "DBTest";
$date = new DateTime('now');
$filename_generator = new BasicBackupFileNameGenerator($db_name, $date);
$filename = $filename_generator->getName(); // DBTest_[year]-[month]-[day].sql

Now, create an instance of LilyLabs\DBBackup\MysqldumpBackupProcessor to execute the backup process

$backup_processor = new MysqldumpBackupProcessor(
    $db_name,
    $filename_generator
);
$backup_file = $backup_processor->execute();

The returned object is an instance of LilyLabs\DBBackup\DBBackupFile, all backups are generated on the temp folder obtained by sys_get_temp_dir(), you can now move the file to your desired storage location.

$moved_backup_file = $backup_file->move("/final/location/of/the/backup");

Finally, you can use the class LilyLabs\DBBackup\GzipCompressor to gzip the backupfile:

$compressor = new \LilyLabs\DBBackup\GzipCompressor;
$compressed_backup_file = $compressor->compress($moved_backup_file);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email mindacj@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 42
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-08-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固