Class: OpsBackups::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- OpsBackups::InstallGenerator
- Defined in:
- lib/generators/ops_backups/install/install_generator.rb
Instance Method Summary collapse
- #add_recurring_jobs ⇒ Object
-
#add_storage_service ⇒ Object
it seems the migrations already are available in the host app def copy_migrations rake “railties:install:migrations FROM=ops_backups” say “Migrations copied to your application.”, :green end.
Instance Method Details
#add_recurring_jobs ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/generators/ops_backups/install/install_generator.rb', line 35 def add_recurring_jobs recurring_file = Rails.root.join("config", "recurring.yml") if File.exist?(recurring_file) recurring_config = <<~YAML.lines.map { |line| " #{line}" }.join backup_db: class: OpsBackups::BackupDbJob args: [tag: "db_pg_backup", cleanup: "retain_tiered"] schedule: every hour YAML append_to_file recurring_file, recurring_config say "Added 'recurring' jobs to recurring.yml.", :green else say "config/recurring.yml not found. Please create it and re-run this generator.", :red end # # copy the admin/backup.rb file to app/admin/ops_backups/backup.rb # def copy_admin_backup # copy_file "admin/backup.rb", Rails.root.join("app", "admin", "ops_backups", "backup.rb") # say "Copied admin/backup.rb to app/admin/ops_backups/backup.rb.", :green # end end |
#add_storage_service ⇒ Object
it seems the migrations already are available in the host app def copy_migrations
rake "railties:install:migrations FROM=ops_backups"
say "Migrations copied to your application.", :green
end
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/generators/ops_backups/install/install_generator.rb', line 12 def add_storage_service storage_file = Rails.root.join("config", "storage.yml") if File.exist?(storage_file) service_config = <<~YAML backups: service: Disk root: <%= Rails.root.join("storage") %> # service: S3 # access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %> # secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %> # region: <%= ENV['AWS_REGION'] %> # bucket: allcrux-backups YAML append_to_file storage_file, service_config say "Added 'backups' service to storage.yml.", :green else say "config/storage.yml not found. Please create it and re-run this generator.", :red end end |