webiny/backup-service
Composer 安装命令:
composer require webiny/backup-service
包简介
Simple library to do backups and store them to AWS S3
关键字:
README 文档
README
This library is used to create an encrypted backup archive of one or more folders on your server and one or more MongoDb databases. Once the backup archive is created, it will be stored to the defined S3 bucket.
The library automatically manages the backups on the S3 bucket and it only uploads the backup archive once. If required to keep a weekly, monthly or yearly, using the S3 API backup copies are made, so we don't need to re-upload the same archive multiple times.
The backup is a tar gzip archive, which is then encrypted with either openssl or gpg with the defined passphrase and only then, in this encrypted state,
is transferred to the S3 bucket.
Installation
The best way to install the component is using Composer.
composer require webiny/backup-service
For additional versions of the package, visit the Packagist page.
Configuration
To run the backup script, just create a small PHP script and point it to your config file:
<?php require_once '../vendor/autoload.php'; $service = new \Webiny\BackupService\Service(__DIR__.'/SampleConfig.yaml'); $service->createBackup();
You can run the script via CLI or you can configure a cron job.
As for the configuration parameters, here is an example config.
BackupService: Folders: - /var/www/site1.com - /var/www/site2.com MongoDatabases: BackupTest1: Host: 127.0.0.1:27017 Database: BackupTest1 Username: Admin Password: password BackupTest2: Host: 127.0.0.1:27017 Database: BackupTest2 Frequency: # daily backup is always on - Week - Month TempPath: "/tmp/backups/" Encryption: Passphrase: "test-password" Type: openssl BackupStoragePath: "/mnt/gluster/backups/" S3: RemotePath: "Backups/" AccessId: # S3 access id AccessKey: # S3 access key Bucket: # bucket where to store the backups Region: # AWS region name where your bucket is located, eg eu-central-1
Folders: contain one or more folders that will be added to the backup archive.MongoDatabases: a list of mongo databases that should be exported (using mongodump) and they will also be included in the backup archive.Frequency: by default the script keeps a 24h backup snapshot and a 48h snapshot. You can additionally add aweekly,monthlyandyearlysnapshot.TempPath: this is a writable path on the local machine where the script will place some temporary files as well as some logs that you can later reference and see what the script has been doing.Encryption: this are the encryption settings that will be used to encrypt the archives. Note that encryption is optional, if you don't define the key, the backup won't be encrypted. Twotypesof encryption are supportedgpgoropenssl.BackupStoragePath: if you wish to store backups on the current filesystem, just set your path here. If the path is not set, the backups won't be stored locally.S3: this is your S3 configuration. Note: make sure you get the AWS region name correctly, otherwise the script will hang on the upload process (http://docs.aws.amazon.com/general/latest/gr/rande.html). If you don't set the S3 configuration, files won't be stored to S3.
Decrypting backups
Depending on the type of the decryption you used, you need to follow the following steps to decrypt your archive.
Openssl
openssl bf -d < backup-1day-old > backup.restored.tar.gz
This will prompt you for your passphrase. If the passphrase is correct, the archive will be decrypted and then you can extract it.
GPG
GPG has a bit more complex model. Before using this encryption make sure you have generated a gpg-key and that you have imported it you the machine where you which to decrypt your backups.
If you are not sure how to do that, have a look at this StackOverflow answer: http://serverfault.com/questions/489140/what-is-a-good-solution-to-encrypt-some-files-in-unix
Once you have your backup on your machine, together with your gpg key, enter the following command in your terminal do decrypt the archive:
gpg --output backup.restored.tar.gz --decrypt backup-1day-old
This will prompt you for your passphrase. If the passphrase is correct, the archive will be decrypted and then you can extract it.
Logs
The library, on each run, generates some logs in the {TempPath}/logs folder. You can reference those logs to see how the backup process went and was it successful or not.
License and Contributions
Contributing > Feel free to send PRs.
License > MIT
Bugs and improvements
Just report them under issues, or even better, send a pull request :)
webiny/backup-service 适用场景与选型建议
webiny/backup-service 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 99 次下载、GitHub Stars 达 2, 最近一次更新时间为 2016 年 04 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「backup」 「amazon S3」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 webiny/backup-service 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 webiny/backup-service 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 webiny/backup-service 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A SDK for working with B2 cloud storage.
This package includes a script and fail2ban configuration that allows you to use fail2ban when utilizing AWS elastic load balancer (ELB) and an apache webserver.
A sleek PHP wrapper around rclone with Laravel-style fluent API syntax
A simple database backup manager for Symfony2 with support for S3, Rackspace, Dropbox, FTP, SFTP.
Fix failed Craft backups and restores with full paths to psql, mysql, and mysqldump executables.
Magento 2 Social Login extension is designed for quick login to your Magento 2 store without procesing complex register steps
统计信息
- 总下载量: 99
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 9
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-04-03