README.md in ops_backups-0.1.0 vs README.md in ops_backups-0.1.1

- old
+ new

@@ -1,132 +1,28 @@ -# Ops +# OpsBackups +Short description and motivation. -## Description -Ops is a Ruby gem designed to enhance and to backup your PostgreSQL database. - ## Usage +How to use my plugin. -### Configuration - -To configure the Ops gem, you need to set up the following environment variables: -- `DATABASE_URL`: The URL of the PostgreSQL database to backup. - -Set up Active Storage for backups (e.g., Amazon S3 for production). We expect a service named `:backup_storage` to be configured. - -```yaml -backup_storage: - service: S3 - access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %> - secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %> - region: <%= ENV['AWS_REGION'] %> - bucket: backups -``` -### Backup Method - -The `Ops::Backup` class provides a method to perform a PostgreSQL database backup: - -- `db_pg_backup(exclude_tables: [], tag: nil)`: This method performs a full backup of the database, optionally excluding specified tables. The backup is tagged and saved as an attachment. - -example: - -```ruby -Ops::Backup.new.db_pg_backup(exclude_tables: ["versions"], tag: "db_pg_unveresioned") -``` - -### Backup Retention Strategies - -Ops gem provides two backup retention strategies: - -1. **Tiered Cleanup Policy**: - - Keeps all backups from the last day. - - Keeps the last backup of each day from the last week (except the last day). - - Keeps the last backup of each week from the last month (except the last week). - - Keeps the last backup of each month before the last month. - - example: - ```ruby - Ops::CleanupTiered.new.cleanup("db_pg_unversioned") - ``` - - This policy can be applied using the `Ops::CleanupTieredJob`. - -2. **Limit Cleanup Policy**: - - Keeps the last N backups, where N is specified by the `limit` parameter. - - example: - ```ruby - Ops::CleanupLimit.new.cleanup("db_pg_unversioned", limit: 14) - ``` - - This policy can be applied using the `Ops::CleanupLimitJob`. - -### Using SolidQueue Schedule - -1. Schedule the backup job using SolidQueue: - ```ruby - SolidQueue.schedule(Ops::BackupDbJob.new, cron: '0 0 * * *', args: { tag: "db_pg_full", exclude_tables: [], cleanup: "retain_last_limit" }) # This schedules the backup job to run daily at midnight - ``` - -2. Schedule the cleanup job with a tiered policy: - ```ruby - SolidQueue.schedule(Ops::CleanupTieredJob.new, cron: '0 1 * * *', args: { tag: "db_pg_full" }) # This schedules the tiered cleanup job to run daily at 1 AM - ``` - -3. Schedule the cleanup job with a limit policy: - ```ruby - SolidQueue.schedule(Ops::CleanupLimitJob.new, cron: '0 2 * * *', args: { tag: "db_pg_full", limit: 14 }) # This schedules the limit cleanup job to run daily at 2 AM - ``` - -### Using `recurring.yml` from SolidQueue - -Alternatively, you can configure recurring tasks using `recurring.yml` in your SolidQueue configuration: - -1. Create or update the `recurring.yml` file in your application's config directory: - ```yaml - # filepath: config/recurring.yml - backup_db_job: - cron: "0 0 * * *" - class: "Ops::BackupDbJob" - args: - tag: "db_pg_full" - exclude_tables: [] - cleanup: "retain_last_limit" - - cleanup_tiered_job: - cron: "0 1 * * *" - class: "Ops::CleanupTieredJob" - args: - tag: "db_pg_full" - - cleanup_limit_job: - cron: "0 2 * * *" - class: "Ops::CleanupLimitJob" - args: - tag: "db_pg_full" - limit: 14 - ``` - - - ## Installation Add this line to your application's Gemfile: ```ruby -gem "ops" +gem "ops_backups" ``` And then execute: ```bash $ bundle ``` Or install it yourself as: ```bash -$ gem install ops +$ gem install ops_backups ``` ## Contributing - -Bug reports and pull requests are welcome on GitHub at https://github.com/koenhandekyn/ops. +Contribution directions go here. ## License The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).