定制 h2akim/backup 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

h2akim/backup

Composer 安装命令:

composer require h2akim/backup

包简介

An easy way backup and restore databases in Laravel.

README 文档

README

Fork from Cornford/Backup

  • Add Laravel 4.1 Support

Think of Backup as an easy way to backup and restore a database, with command line integration to Laravel's artisan. These include:

  • Backup::export
  • Backup::restore
  • Backup::setBackupEngineInstance
  • Backup::getBackupEngineInstance
  • Backup::setBackupFilesystemInstance
  • Backup::getBackupFilesystemInstance
  • Backup::setEnabled
  • Backup::getEnabled
  • Backup::setPath
  • Backup::getPath
  • Backup::setCompress
  • Backup::getCompress
  • Backup::setFilename
  • Backup::getFilename
  • Backup::getWorkingFilepath
  • Backup::getRestorationFiles
  • Backup::getProcessOutput

Installation

Begin by installing this package through Composer. Edit your project's composer.json file to require cornford/backup.

"require": {
	"h2akim/backup": "dev-master"
}

Next, update Composer from the Terminal:

composer update

Once this operation completes, the next step is to add the service provider. Open app/config/app.php, and add a new item to the providers array.

'H2akim\Backup\Providers\BackupServiceProvider',

The next step is to introduce the facade. Open app/config/app.php, and add a new item to the aliases array.

'Backup'         => 'H2akim\Backup\Facades\Backup',

Finally we need to introduce the configuration files into your application.

php artisan config:publish h2akim/backup

That's it! You're all set to go.

Usage

It's really as simple as using the Backup class in any Controller / Model / File you see fit with:

Backup::

This will give you access to

Export

The export method allows a database export file to be created in the defined backup location, with an optional filename option.

Backup::export();
Backup::export('database_backup');

Restore

The restore method allows a database export file to be restored to the database, specifying a full filepath to the file.

Backup::restore('./database_backup.sql');

Set Backup Engine Instance

The setBackupEngineInstance method allows a custom backup engine instance object to be utilised, implementing the BackupEngineInterface.

Backup::setBackupEngineInstance(new BackupEngineMysql(new BackupProcess(new Symfony\Component\Process\Process), 'database', 'localhost', 3306, 'root', '', []));

Get Backup Engine Instance

The getBackupEngineInstance method returns the current backup engine instance object.

Backup::getBackupEngineInstance();

Set Backup Filesystem Instance

The setBackupFilesystemInstance method allows a custom backup filesystem instance object to be utilised, implementing the BackupFilesystemInterface.

Backup::setBackupFilesystemInstance(new BackupFilesystemInstance);

Get Backup Filesystem Instance

The getBackupFilesystemInstance method returns the current backup filesystem instance object.

Backup::getBackupFilesystemInstance();

Set Enabled

The setEnabled method allows backup to be switched on or off, specifying a boolean for state.

Backup::setEnabled(true);
Backup::setEnabled(false);

Get Enabled

The getEnabled method returns the current backup enabled status, returning a boolean for its state.

Backup::getEnabled();

Set Path

The setPath method allows backup location path to be set, specifying a relative or absolute path as a string, a trailing slash is required.

Backup::setPath('/path/to/directory/');

Get Path

The getPath method returns the current absolute backup path in string format.

Backup::getPath();

Set Compress

The setCompress method allows backup file compression to be switched on or off, specifying a boolean for state.

Backup::setCompress(true);
Backup::setCompress(false);

Get Compress

The getCompress method returns the current compression backup status, returning a boolean for its state.

Backup::getCompress();

Set Filename

The setFilename method allows backup filename to be set, specified in a string format.

Backup::setFilename('database_backup');
Backup::setFilename('backup-' . date('Ymd-His'));

Get Filename

The getFilename method returns the current set backup filename in a string format.

Backup::getFilename();

Get Working Filepath

The getWorkingFilepath method returns the current set working filepath of the current item being processed in a string format.

Backup::getWorkingFilepath();

Get Restoration Files

The getRestorationFiles method returns an array containing all of the restoration file filepaths within a give path, an optional absolute path can be set as a string.

Backup::getRestorationFiles();
Backup::getRestorationFiles('/path/to/directory/');

License

Backup is open-sourced software licensed under the MIT license

h2akim/backup 适用场景与选型建议

h2akim/backup 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 29 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 07 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「database」 「dump」 「backup」 「laravel」 「restore」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 h2akim/backup 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 h2akim/backup 我们能提供哪些服务?
定制开发 / 二次开发

基于 h2akim/backup 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-02