chronon/pawsback

此软件包已废弃,不再维护。未建议替代软件包。

使用S3的PHP备份解决方案

安装: 13

依赖项: 0

建议者: 0

安全性: 0

星级: 2

关注者: 2

分支: 0

开放问题: 3

类型:项目

1.0.2 2017-10-01 20:15 UTC

README

CircleCI

PawsBack

  • P as in PHP since that's what it's written in.
  • aws as in Amazon Web Services S3 since that is where it backs things up to.
  • Back as in backup since that is what it does.

PawsBack is a PHP CLI tool which allows you to configure multiple backup sources in a configuration file and sync them to S3. The AWS PHP SDK is used for bucket checking and creation, but not for uploading since it offers no intelligent syncing (everything is uploaded every time). PawsBack generates commands for the aws cli tool which does have an intelligent sync mode, allowing you to upload only changed files and delete ones that no longer exist.

要求

  • PHP - 开发和测试使用v7.0.x版本,但也应在v5.6版本上工作(查看PHP v5.6.22和PHPUnit v5.7.19的测试构建)。要使用PHP 5.6进行安装,请更改composer.json中的require版本,并可选地将PHPUnit版本设置为^5.0以运行测试。
  • aws cli工具,需要Python。捆绑安装程序非常简单。

安装

全局安装到~/.composer/vendor/bin

composer global require chronon/pawsback

然后您可以将~/.composer/vendor/bin符号链接到您的PATH中现有的目录(例如~/bin)或将其添加到您的PATH中。

配置

示例配置文件可以在tests/test_app/test.json中找到,类似于以下内容。

provider:S3

  • 必需的 bucket:备份到的存储桶
  • 可选的 region:S3区域,默认为"us-east-1"
  • 可选的 profile:aws cli工具配置文件,默认为"default"
  • 可选的 delete:是否在从源中删除时删除S3文件,默认为true
  • 可选的 options:要添加到全局的任何其他aws cli工具选项,默认为""

backups:sources

  • 必需的 name:S3中将创建并存储此源数据的目录
  • 必需的 root:备份根目录的绝对路径
  • 必需的 dirs:一个包含目录作为键和备份可选选项作为值的数组

有关--exclude--include等的S3命令文档提供了许多有用的示例,解释了这些选项。以下示例配置文件中,在prefixed子目录中仅备份以baz_开头的文件。

PawsBack 示例配置文件

{
    "provider": {
        "S3": {
            "bucket": "chronon-pawsback-test-1"
        }
    },
    "backups": {
        "sources": [
            {
                "name": "foo.com",
                "root": "/home/ubuntu/pawsback/tests/test_app/foo.com/",
                "dirs": {
                    "shared/img": "",
                    "shared/files": ""
                }
            },
            {
                "name": "bar.com",
                "root": "/home/ubuntu/pawsback/tests/test_app/bar.com/",
                "dirs": {
                    "shared/files": "",
                    "prefixed": "--exclude '*' --include 'baz_*'"
                }
            }
        ]
    }
}

用法

单入口点是 bin/pawsback,可以使用 -h 选项获取帮助

pawsback help:

  -p    The full path to the backup config file
  -v    Verbose output, can be used with dry run
  -d    Dry run, display what would happen without action
  -g    Generate mode, display a list of commands without validating anything
  -h    This help message

注意

  • -d 选项用于模拟运行 将检查和创建存储桶,如果它不存在,因为它使用 aws cli 工具的模拟运行模式。仅要查看将运行的命令,而不检查/创建存储桶或验证备份路径,请使用 -g 模式生成命令列表。
  • 所有选项都可以一起使用。

AWS CLI 配置

安装后,可以通过运行 aws configure 或在 ~/.aws 中创建简单的配置文件 configcredentials 来配置 aws 命令行工具。如果需要多个配置文件,请在 aws 配置中配置配置文件(参见 命名配置文件)并在您的 provider:S3:profile 配置中使用命名配置文件。

测试

可以使用 bin/run-tests 运行测试(PHP Codesniffer 和 PHPUnit)。代码覆盖率是 100%,任何拉取请求 必须 包含相关测试。

参考