{"id":21124507,"url":"https://github.com/zauberware/capistrano-ops","last_synced_at":"2025-07-08T22:30:52.459Z","repository":{"id":64404993,"uuid":"575572359","full_name":"zauberware/capistrano-ops","owner":"zauberware","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-28T08:47:00.000Z","size":125,"stargazers_count":7,"open_issues_count":4,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-03T16:46:27.908Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zauberware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-07T20:19:01.000Z","updated_at":"2025-03-04T08:29:55.000Z","dependencies_parsed_at":"2025-06-14T11:00:48.611Z","dependency_job_id":null,"html_url":"https://github.com/zauberware/capistrano-ops","commit_stats":{"total_commits":35,"total_committers":2,"mean_commits":17.5,"dds":0.05714285714285716,"last_synced_commit":"ecc9bb2d4289170c214ad649860b49e1bee2bcea"},"previous_names":["zauberware/zauberware-devops"],"tags_count":40,"template":false,"template_full_name":null,"purl":"pkg:github/zauberware/capistrano-ops","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zauberware%2Fcapistrano-ops","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zauberware%2Fcapistrano-ops/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zauberware%2Fcapistrano-ops/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zauberware%2Fcapistrano-ops/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zauberware","download_url":"https://codeload.github.com/zauberware/capistrano-ops/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zauberware%2Fcapistrano-ops/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262242674,"owners_count":23280972,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T04:16:46.170Z","updated_at":"2025-07-08T22:30:52.090Z","avatar_url":"https://github.com/zauberware.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# capistrano-ops - Comprehensive DevOps Utility for Rails 🛠️\n\nThe capistrano-ops gem is a valuable library, tailor-made for Rails DevOps professionals, offering an array of beneficial scripts to streamline and enhance operations with Capistrano. The focus is on seamless integration with Capistrano version 3 and above.\n\n## Table of Contents\n\n\u003cdetails\u003e\n\u003csummary\u003eClick to expand\u003c/summary\u003e\n\n- [Main Features](#main-features)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Script overview](#script-overview)\n- [Usage](#usage)\n  - [Optional Settings for backup task](#optional-settings-for-backup-task)\n  - [use with whenever/capistrano](#use-with-whenevercapistrano)\n- [Configuration](#configuration)\n- [Slack integration](#slack-integration)\n- [Webhook integration](#webhook-integration)\n- [Notification level](#notification-level)\n- [Backups](#backups)\n  - [Backup provider](#backup-provider)\n- [Logrotate](#logrotate)\n  - [Configuration](#configuration-1)\n  - [Usage](#usage-1)\n- [Wkhtmltopdf Setup](#wkhtmltopdf-setup)\n- [Contributing](#contributing)\n- [License](#license)\n\n\u003c/details\u003e\n\n## Main Features:\n\n🗃️ **Database and Storage Backups:**\n\n- Create, pull, and manage backups of your Postgres database and server storage.\n- Delegation of old backup removal for both Postgres database and server storage.\n\n🛠️ **Configuration Management:**\n\n- Compare `application.yml` files between local and server environments using `figaro_yml:compare`.\n- Fetch server environment variables set via Figaro with `figaro_yml:get`.\n- Copy local `application.yml` to the server with `figaro_yml:setup`. This task automatically triggers `figaro_yml:backup` before proceeding.\n- Create a backup of the server's `application.yml` with `figaro_yml:backup`. This is automatically executed before `figaro_yml:setup` to ensure a recovery point is available.\n- Roll back to the previous `application.yml` on the server using `figaro_yml:rollback`. This can be used to quickly revert changes made by `figaro_yml:setup` if needed.\n\n📜 **Logging and Task Management:**\n\n- Real-time viewing of Rails server logs.\n- Real-time viewing of sidekiq logs.\n- Showcase the server app's crontab generated with the 'whenever' gem.\n- Ability to invoke server-specific rake tasks.\n\n🔔 **Notification Integrations:**\n\n- Set up notifications through Slack or generic Webhooks.\n- Customize notification levels (info/error).\n\n⚙️ **Backup Settings Customization:**\n\n- Define the number of backups retained, both locally and externally.\n- Toggle backup tasks and external backups.\n- S3 integration for backup storage, including customization of bucket, region, and endpoint details.\n\n📅 **Schedule Tasks:**\n\n- Couple with the 'whenever' gem to schedule daily backup creation and old backup removal.\n\n🔗 **Slack \u0026 Webhook Integrations:**\n\n- Integrate seamlessly with Slack or use webhooks for notifications, alerting you on essential operations or any potential issues.\n\n☁️ **Backup Providers:**\n\n- S3 and other S3-compatible services are supported to ensure your data remains secure and accessible.\n\n[↑](#)\n\n## Requirements\n\n```ruby\n'capistrano', '~\u003e 3.0'\n'whenever' # for scheduling tasks\n'figaro' # for environment variables if you use figaro_yml tasks\n\n# hint: if you use other aws-sdk gems, its possible that you have to update them too\n```\n\n[↑](#)\n\n## Installation\n\nAdd the gem to your `Gemfile` after setting up Capistrano\ngroup:\n\n```ruby\ngroup :development do\n  gem 'capistrano', require: false\nend\n\ngem 'capistrano-ops'\n```\n\nThen `bundle` and add it to your `Capfile`\n\n```ruby\n# Capfile\n\nrequire 'capistrano/ops'\n```\n\nor if you want to use only specific tasks one or more of the following:\n\n```ruby\n# Capfile\n\n\nrequire 'capistrano/ops/backup' # backup:database:create, backup:database:pull, backup:storage:create, backup:storage:pull\nrequire 'capistrano/ops/figaro_yml' # figaro_yml:compare, figaro_yml:get, figaro_yml:setup, figaro_yml:backup, figaro_yml:rollback\nrequire 'capistrano/ops/invoke' # invoke:rake\nrequire 'capistrano/ops/logrotate' # logrotate:enable, logrotate:disable, logrotate:check\nrequire 'capistrano/ops/logs' # logs:rails, logs:sidekiq, logs:sidekiq:info, logs:sidekiq:error\nrequire 'capistrano/ops/whenever' # whenever:show_crontab\n\n# optionally and not included in require 'capistrano/ops'\nrequire 'capistrano/ops/wkhtmltopdf' # setup wkhtmltopdf-binary on server\n```\n\nand `initializers`\n\n```ruby\n# initializers/capistrano_ops.rb\n\n# needed for the backup tasks\nrequire 'capistrano/ops'\n```\n\n[↑](#)\n\n## Script overview\n\n| Script                                           | Description                                                              |\n| ------------------------------------------------ | ------------------------------------------------------------------------ |\n| `cap \u003cenvironment\u003e backup:create`                | creates backup of postgres database on the server (removed since v1.0.0) |\n| `cap \u003cenvironment\u003e backup:pull`                  | download latest postgres backup from server (removed since v1.0.0)       |\n| `cap \u003cenvironment\u003e backup:database:create`       | creates backup of postgres database on the server                        |\n| `cap \u003cenvironment\u003e backup:database:pull`         | download latest postgres backup from server                              |\n| `cap \u003cenvironment\u003e backup:storage:create`        | creates backup of storage on the server                                  |\n| `cap \u003cenvironment\u003e backup:storage:pull`          | download latest storage backup from server                               |\n| `cap \u003cenvironment\u003e figaro_yml:setup`             | copy local application.yml to server application.yml                     |\n| `cap \u003cenvironment\u003e figaro_yml:compare`           | compare local application.yml with server application.yml                |\n| `cap \u003cenvironment\u003e figaro_yml:get`               | shows env vars from server application.yml configured thru figaro        |\n| `cap \u003cenvironment\u003e figaro_yml:backup`            | creates backup of server application.yml (keeps last 5 versions)         |\n| `cap \u003cenvironment\u003e figaro_yml:rollback`          | rollback server application.yml to previous version                      |\n| `cap \u003cenvironment\u003e logs:rails`                   | display server log live                                                  |\n| `cap \u003cenvironment\u003e logs:sidekiq`                 | display sidekiq log live                                                 |\n| `cap \u003cenvironment\u003e logs:sidekiq:info`            | display sidekiq info log live                                            |\n| `cap \u003cenvironment\u003e logs:sidekiq:error`           | display sidekiq error log live                                           |\n| `cap \u003cenvironment\u003e whenever:show_crontab`        | display server app crontab generated with whenever                       |\n| `cap \u003cenvironment\u003e invoke:rake TASK=\u003cyour:task\u003e` | invoke rake task on server                                               |\n| `cap \u003cenvironment\u003e logrotate:enable`             | enable logrotate for logfiles on server                                  |\n| `cap \u003cenvironment\u003e logrotate:disable`            | disable logrotate for logfiles on server                                 |\n| `cap \u003cenvironment\u003e logrotate:check`              | show logrotate status for logfiles on server                             |\n| `rake pg:dump`                                   | creates postgres database backup                                         |\n| `rake pg:remove_old_dumps`                       | remove old postgres backups                                              |\n| `rake storage:backup`                            | creates backup of storage                                                |\n| `rake storage:remove_old_backups`                | remove old storage backups                                               |\n\n[↑](#)\n\n## Usage\n\nfor all backup task you have to setup your database.yml properly:\n\n```\nproduction:\n\n  database: database_name\n  username: database_username\n  password: database_password\n  host: database_host\n  port: database_port\n```\n\n[↑](#)\n\n### Optional Settings for backup task\n\n| env                        | description                                                                                         |                            type/options                            |\n| -------------------------- | --------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------: |\n| NUMBER_OF_BACKUPS          | number of backups to keep (default: 7)                                                              |                              `number`                              |\n| NUMBER_OF_LOCAL_BACKUPS    | number of backups to keep locally (default: nil)                                                    |                              `number`                              |\n| NUMBER_OF_EXTERNAL_BACKUPS | number of backups to keep externally (default: nil)                                                 |                              `number`                              |\n| BACKUPS_ENABLED            | enable/disable backup task (default: Rails.env == 'production')                                     |                             `boolean`                              |\n| EXTERNAL_BACKUP_ENABLED    | enable/disable external backup (default: false) (only if 'BACKUPS_ENABLED', needs additional setup) |                             `boolean`                              |\n| KEEP_LOCAL_STORAGE_BACKUPS | keep local storage backups (default: true)                                                          |                             `boolean`                              |\n| DEFAULT_URL                | notification message title (default: \"#{database} Backup\")                                          |                              `string`                              |\n| NOTIFICATION_TYPE          | for notification (default: nil)                                                                     |                    `string` (`webhook`/`slack`)                    |\n| NOTIFICATION_LEVEL         | for notification (default: nil)                                                                     |                     `string` (`info`/`error`)                      |\n| SLACK_SECRET               | for slack integration                                                                               | `string` (e.g. `xoxb-1234567890-1234567890-1234567890-1234567890`) |\n| SLACK_CHANNEL              | for slack integration                                                                               |                    `string` (e.g. `C234567890`)                    |\n| WEBHOOK_URL                | Webhook server to send message                                                                      |                      e.g `http://example.com`                      |\n| WEBHOOK_SECRET             | Secret to send with uses md5-hmac hexdigest in header`x-hub-signature`                              |                                ---                                 |\n| BACKUP_PROVIDER            | Backup provider (default: nil)                                                                      |                          `string` (`s3`)                           |\n| S3_BACKUP_BUCKET           | S3 bucket name for backups                                                                          |                              `string`                              |\n| S3_BACKUP_REGION           | S3 region for backups                                                                               |                              `string`                              |\n| S3_BACKUP_KEY              | S3 access key for backups                                                                           |                              `string`                              |\n| S3_BACKUP_SECRET           | S3 secret key for backups                                                                           |                              `string`                              |\n| S3_BACKUP_ENDPOINT         | S3 endpoint for backups (optional, used for other S3 compatible services)                           |                              `string`                              |\n\n[↑](#)\n\n### use with whenever/capistrano\n\ninstall whenever gem and add this to your schedule.rb\n\n```ruby\n# config/schedule.rb\n# Use this file to easily define all of your cron jobs.\nenv :PATH, ENV['PATH']\nset :output, -\u003e { '2\u003e\u00261 | logger -t whenever_cron' }\n\nevery :day, at: '2:00 am' do\n  rake 'pg:dump'\n  rake 'storage:backup'\nend\n\nevery :day, at: '3:00 am' do\n  rake 'pg:remove_old_dumps'\n  rake 'storage:remove_old_backups'\nend\n```\n\nadd this to your capfile\n\n```ruby\n# Capfile\nrequire 'whenever/capistrano'\n```\n\n[↑](#)\n\n## Configuration\n\nYou can optionally specify the capistrano roles for the rake task (Defaults to `:app`):\n\n```ruby\n# Defaults to [:app]\nset :rake_roles, %i[db app]\n```\n\n[↑](#)\n\n## Slack integration\n\nif you want to use slack integration you have to add this to your `application.yml`\n\n```ruby\nNOTIFICATION_TYPE: 'slack'\nSLACK_SECRET: '\u003cyour-slack-secret\u003e'\nSLACK_CHANNEL: '\u003cyour-slack-channel\u003e'\n```\n\n[↑](#)\n\n## Webhook integration\n\nif you want to use webhook integration you have to add this to your `application.yml`\n\n```ruby\nNOTIFICATION_TYPE: 'webhook'\nWEBHOOK_URL: '\u003cyour-webhook-url\u003e'\nWEBHOOK_SECRET: '\u003cyour-webhook-secret\u003e'\n```\n\n[↑](#)\n\n## Notification level\n\nif you want to use notification level you have to add this to your `application.yml`\n\n```ruby\nNOTIFICATION_LEVEL: 'info' # default is 'error'\n```\n\n[↑](#)\n\n## Backups\n\nif you want to configure the number of backups you have to add this to your `application.yml`\n\n```ruby\nNUMBER_OF_BACKUPS: 7 # default is 7 (local + external)\n```\n\nto fine tune the number of local and external backups you can use this:\n\n```ruby\nNUMBER_OF_LOCAL_BACKUPS: 7 # default is nil (local)\nNUMBER_OF_EXTERNAL_BACKUPS: 7 # default is nil (local)\n```\n\n[↑](#)\n\n### Backup provider\n\nif you want to use an external backup provider you have to add this to your `application.yml`\n\n```ruby\nBACKUP_PROVIDER: 's3'\nS3_BACKUP_BUCKET: '\u003cyour-s3-bucket\u003e'\nS3_BACKUP_REGION: '\u003cyour-s3-region\u003e'\nS3_BACKUP_KEY: '\u003cyour-s3-key\u003e'\nS3_BACKUP_SECRET: '\u003cyour-s3-secret\u003e'\nS3_BACKUP_ENDPOINT: '\u003cyour-s3-endpoint\u003e' # optional, used for other S3 compatible services\n```\n\n[↑](#)\n\n## Logrotate\n\nLogrotate is a utility designed for administrators who manage servers producing a high volume of log files to help them save some disk space as well as to avoid a potential risk making a system unresponsive due to the lack of disk space.\n\nThe capistrano-ops gem provides a set of tasks to manage logrotate on your server:\n\n- `cap \u003cenvironment\u003e logrotate:enable` - This task enables logrotate for logfiles on the server.\n- `cap \u003cenvironment\u003e logrotate:disable` - This task disables logrotate for logfiles on the server.\n- `cap \u003cenvironment\u003e logrotate:check` - This task shows the logrotate status for logfiles on the server.\n  [↑](#)\n\n### Configuration\n\nYou can optionally specify the logrotate configuration file path (Defaults to `/etc/logrotate.conf`):\n\n```ruby\n# Defaults to '/etc/logrotate.conf'\nset :logrotate_path, '/path/to/your/logrotate.conf'\n```\n\n[↑](#)\n\n### Usage\n\nTo use logrotate, you need to have it installed on your server. If it's not installed, you can install it using the package manager of your system. For example, on Ubuntu, you can install it using apt:\n\n```bash\nsudo apt-get install logrotate\n```\n\nOnce logrotate is installed, you can use the capistrano-ops tasks to manage it.\n[↑](#)\n\n## Wkhtmltopdf Setup\n\nThis script is used to setup `wkhtmltopdf-binary` in your deployment environment for `WickedPdf`. It is designed to work with Capistrano.\n\nThe main task `setup` is hooked to run after the `deploy:symlink:release` task.\nIt performs the following operations:\n\n- unzip the necessary binary file\n\n- set the binary file permissions\n\nThe script assumes, that you have a intializer file for `wicked_pdf` gem, which sets the path to the binary file.\nfor example:\n\n```ruby\n# config/initializers/wicked_pdf.rb\nWickedPdf.config = {\n  exe_path: \"#{Bundler.bundle_path}/gems/wkhtmltopdf-binary-0.12.6.6/bin/wkhtmltopdf_ubuntu_18.04_amd64\",\n  # Attention: set the used binary file version also in the Gemfile\n}\n```\n\nTo use this script, include it in your Capistrano tasks and it will automatically run during deployment.\n\n```ruby\n# Capfile\nrequire 'capistrano/ops/wkhtmltopdf'\n```\n\n[↑](#)\n\n## Contributing\n\n1. Fork it ( https://github.com/zauberware/capistrano-ops/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n[↑](#)\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\nThis gem contains code/snippets from the following sources:\n\n- [capistrano-figaro-yml](https://github.com/ChouAndy/capistrano-figaro-yml) by Andy Chou under the [MIT License](https://github.com/chouandy/capistrano-figaro-yml/blob/master/LICENSE.md)\n- [capistranorb documentation](https://capistranorb.com/documentation/tasks/rails/)\n\nprops to the original authors 🎉\ncheck out their work too!\n\n[↑](#)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzauberware%2Fcapistrano-ops","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzauberware%2Fcapistrano-ops","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzauberware%2Fcapistrano-ops/lists"}