承接 canary/roost 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

canary/roost

Composer 安装命令:

composer create-project canary/roost

包简介

Helper for working with DB on macOS or linux.

README 文档

README

Roost is a database backup manager designed to simplify the process of taking backups from one environment and moving them to another. It was developed for Magento 2, however can be used without it as well.

Main features:

  • create/drop databases
  • import databases
    • supported *.sql, *.dump, *.sql.gz and *.sql.zip dump files
    • db dumps can be filtered on DEFINERs (including procedures and functions) and ROW_FORMAT
  • export databases
    • supported *.sql and *.sql.gz dump files
    • db dumps always exports procedures and functions
    • db dumps can be filtered on DEFINERs (including procedures and functions) and ROW_FORMAT
    • db dumps can be stripped
  • local DB dump storage folder
    • DB is exported to the storage by default
    • DB dumps is searched in the storage by default
  • AWS S3 bucket as remote storage
    • DB dumps can be uploaded
    • DB dumps can be downloaded
    • DB dumps can be deleted
    • supported cleaning (keeping not more than some amount of dumps for one DB)
  • tag in DB dump naming

Requirements

  • PHP 8.0+ (with permission to run exec and passthru)
  • PHP extensions: posix, simplexml, zlib, fileinfo, json, pdo, pcre
  • mysql client on the $PATH
  • pv optional (run brew install pv on macOS)

Installation

Download the latest release into and make it executable:

curl -L https://github.com/findcanary/roost/releases/latest/download/roost.phar > /usr/local/bin/roost
chmod +x /usr/local/bin/roost

Since, currently, there is no system PHP in the latest macOS we need to install PHP via Brew. The latest version of the roost requires PHP >= 8.0. In order to be able to run it regardless of which version is linked PHP version, we can do the next:

  • rename ~/bin/roost to ~/bin/bin-roost
  • create a text executable bash file with the next content:
    #!/usr/bin/env bash
    /usr/local/opt/php@8.0/bin/php "$HOME/bin/bin-roost" "$@"
    

Optionally install autocomplete for all commands:

# BASH - Ubuntu / Debian
roost completion | sudo tee /etc/bash_completion.d/roost

# BASH - Mac OSX (with Homebrew "bash-completion")
roost completion > $(brew --prefix)/etc/bash_completion.d/roost

# ZSH - Config file
roost completion > ~/.roost_completion && echo "source ~/.roost_completion" >> ~/.zshrc

Configuration

The configuration can either be provided through configuration files (file name .roost.yml) or as options when executing a command.

aws-region: The region in which the S3 buckets are located
aws-bucket: The bucket to store the database backups
aws-access-key: AWS Access Key
aws-secret-key: AWS Secret Key
db-host: MySQL DB host
db-port: MySQL DB post
db-username: MySQL DB username
db-password: MySQL DB password
db-name: MySQL DB name
project: Project key
storage: Local path where DB dumps are located
magento-directory: Default magento root directory
table-groups: Table groups for stripping databases during exporting

The configuration is searched in various places then merged, if config keys found in more than one file they are overwritten. Here are places and priorities for the configuration (from lowest to highest):

  • Internal: config/config.yml the configuration contains the default table-groups for stripping M2 databases during export
  • Home directory: default configuration
  • Fallback: from the working directory to home (or root if the working directory is outside of the home), so configuration in the working directory has higher priority than their parent directories
  • Magento2 env.php: it tries to find app/etc/env.php file relatively to the working directory (with a fallback to home), if it is found then it has higher priority than all configuration except that one which is located in the working directory
  • cli options: any config value can be overwritten by command option, they have the highest priority

If a command is run outside of the magneto root folder, but there is needed to use its configuration then --magento-directory (or -m) option can be passed with full or relative to the current folder path.

Example of usage

General configuration can be defined in home directory (~/.roost.yml):

aws-region: The region in which the S3 buckets are located
aws-bucket: The bucket to store the database backups
aws-access-key: AWS Access Key
aws-secret-key: AWS Secret Key
db-host: MySQL DB host
db-port: MySQL DB post
db-username: MySQL DB username
db-password: MySQL DB password
storage: Local path where DB dumps are located

Project-specific configuration should be defined in each project folder (<project-folder>/.roost.yml):

project: Project key

If the project is not Magento 2 then DB configuration can be defined as well:

project: Project key
db-name: MySQL DB name

Having such configurations defined allows:

  • always have access to all DBs and dumps
  • no necessity to specify project key and/or DB credentials when a command is running from a project root folder
  • keep all DB dumps in one place (storage folder)

canary/roost 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-09-17