Class: OpsBackups::BackupDbJob

Inherits:
ApplicationJob show all
Defined in:
app/jobs/ops_backups/backup_db_job.rb

Overview

typed: true frozen_string_literal: true

Instance Method Summary collapse

Instance Method Details

#perform(options = {}) ⇒ Object

perform a full backup of the database

Parameters:

  • tag (String)

    the tag to assign to the backup

  • exclude_tables (Array<String>)

    the list of tables to exclude from the backup

  • cleanup_policy (String)

    the cleanup policy to apply to the backup, one of “retain_tiered_cleanup_policy” or “retain_last_limit_cleanup_policy”



11
12
13
14
15
16
17
18
# File 'app/jobs/ops_backups/backup_db_job.rb', line 11

def perform(options = {})
  exclude_tables = options[:exclude_tables] || []
  tag = options[:tag] || (exclude_tables.empty? ? "db_pg_full" : "db_pg_partial")
  cleanup = options[:cleanup]
  Rails.logger.info "Performing backup with tag: #{tag} and exclude_tables: #{exclude_tables}"
  OpsBackups::Backup.new.db_pg_backup(exclude_tables:, tag:)
  OpsBackups::Backup.send("#{cleanup}_cleanup_policy", tag: tag) if cleanup.present?
end