floor12/yii2-module-backup
Composer 安装命令:
composer require floor12/yii2-module-backup
包简介
Yii2 backup module
README 文档
README
Этот файл доступен на русском языке.
This module helps to create and restore backups of databases and files stored on disk. It has web-interface, console commands, and REST-API for remote control. It also supports io-priority settings and has flexible configuration options. To work independently of the application database, this module uses its sqlite database in the backup folder.
Creating and restoring database backups is possible for MySQL and [PostgreSQL] (https://www.postgresql.org/). To do this, you must have the console client installed on the system for your database type. After a series of experiments, it became clear that creating and restoring databases best using their native clients.
i18n
Now, this module supports English and Russian languages.
Installation
To add this module to your app, just run:
$ composer require floor12/yii2-module-backup
or add this to the require section of your composer.json.
"floor12/yii2-module-backup": "dev-master"
After that, include minimal module configuration in modules section of application config:
'modules' => [ 'backup' => [ 'class' => 'floor12\backup\Module', 'backupFolder' => '/mnt/raid10/backups', 'administratorRoleName' => '@', 'configs' => [ 'mysql_db' => [ 'type' => BackupType::DB, 'title' => 'Mysql Database', 'connection' => 'db', // component from app config, usually 'db' 'limit' => 0 ], 'postgres_db' => [ 'type' => BackupType::DB, 'title' => 'PostgresQL database', 'connection' => 'example_connection_name', // component from app config, usually 'db' 'io' => IOPriority::REALTIME, 'limit' => 0 ], 'user_files_backup' => [ 'type' => BackupType::FILES, 'title' => 'User uploaded files', 'path' => '@app/user_files', 'io' => IOPriority::IDLE, 'limit' => 0 ] ] ] ] ...
These parameters is possible to set up:
administratorRoleName- role to access web controllerbackupFolder- path or alias to the place where the backups are stored (default is @app/backups)chmod- if this param has value, the new backup file will change mode after creationauthTokens- array of auth tokens to use REST-API of the moduleadminLayout- it will change defaultmainlayout to something you need (if your admin panel has different base layout)
And the main and required param is configs - it`s an associative array of your backup configurations (folders and databases).
Each backup item mast have these elements to set:
- a backup identifier as an array key, contains only letters and numbers without space;
type- type backup: disk or database;title- human-readable backup item title to show in the admin interface;limit- how many backup copies keep before delete (0- never delete old copies);io- input/output hdd priority, usefloor12\backup\models\IOPriorityconstants to keep it confabulated. Default value isIOPriority::IDLE;connection- in case of database backup, connection name in Yii2 config;path- in case of disk backup, the path to store backup files;
Usage
WEB interface
This module has a web controller to work with backups. Go to backup/admin or backup/admin/index to create, delete, restore and download
backups.
Console interface
To list all existing backups run
$ ./yii backup/console/index
To create config run
$ ./yii backup/console/create <backup_config_id>
backup_config_id is backup item identifier from module configuration.
To restore config run
$ ./yii backup/console/restore <backup_id>
backup_id is identifier of backup stored in sqlite database
REST-api
By default, rest controller takes place on the route /backup/api.
To get access to it, add header Backup-Auth-Token to request with one of the tokens stored in application config in the module section
(param authTokens);
Get list of backups
GET /backup/api/index
This is useful to remote backup checks from some dashboard with a few projects.
Response example:
[
{
"id": 8,
"date": "2019-11-11 07:02:23",
"status": 1,
"type": 1,
"config_id": "main_storage",
"config_name": "TMP folder",
"filename": "main_storage_2019-11-11_07-02-23.zip",
"size": 4183
},
{
"id": 7,
"date": "2019-11-11 06:56:36",
"status": 1,
"type": 0,
"config_id": "main_db",
"config_name": "Main database",
"filename": "main_db_2019-11-11_06-56-36.gz",
"size": 753
},
]
Create new backup
POST /backup/api/backup?config_id=<backup_config_id>
Succes respons example:
{"result":"success"}
Restore from backup
POST /backup/api/restore?id=<backup_id>
Succes respons example:
{"result":"success"}
Delete backup
DELETE /backup/api/delete?id=<backup_id>
Succes respons example:
{"result":"success"}
Get backup file
GET /backup/api/get?id=<backup_id>
This request will return backup archive with requested ID.
floor12/yii2-module-backup 适用场景与选型建议
floor12/yii2-module-backup 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 429 次下载、GitHub Stars 达 6, 最近一次更新时间为 2019 年 11 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「module」 「extension」 「backup」 「zip」 「yii2」 「gzip」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 floor12/yii2-module-backup 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 floor12/yii2-module-backup 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 floor12/yii2-module-backup 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A SDK for working with B2 cloud storage.
A custom URL rule class for Yii 2 which allows to create translated URL rules
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
A sleek PHP wrapper around rclone with Laravel-style fluent API syntax
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
UI Kit 3 Extension for Yii2
统计信息
- 总下载量: 429
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 10
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-11-13