Class: Belt::CLI::BackupConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/belt/cli/backup_config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBackupConfig

Returns a new instance of BackupConfig.



17
18
19
20
21
22
# File 'lib/belt/cli/backup_config.rb', line 17

def initialize
  @dynamodb_tables = nil # nil = not configured, :all = all tables, Array = specific tables
  @cognito_exports = []  # e.g. [:users, :pool_config]
  @s3_buckets = []       # e.g. [:legal_documents]
  @retention = { snapshots: 90, cognito: 10, s3: 10 }
end

Instance Attribute Details

#cognito_exportsObject (readonly)

Returns the value of attribute cognito_exports.



6
7
8
# File 'lib/belt/cli/backup_config.rb', line 6

def cognito_exports
  @cognito_exports
end

#dynamodb_tablesObject (readonly)

Returns the value of attribute dynamodb_tables.



6
7
8
# File 'lib/belt/cli/backup_config.rb', line 6

def dynamodb_tables
  @dynamodb_tables
end

#retentionObject (readonly)

Returns the value of attribute retention.



6
7
8
# File 'lib/belt/cli/backup_config.rb', line 6

def retention
  @retention
end

#s3_bucketsObject (readonly)

Returns the value of attribute s3_buckets.



6
7
8
# File 'lib/belt/cli/backup_config.rb', line 6

def s3_buckets
  @s3_buckets
end

Class Method Details

.load(env, infra_dir: nil) ⇒ Object

Load backup config from infrastructure//belt.rb Returns nil if no config file exists or backups aren't configured NOTE: Prefer EnvironmentConfig.load which loads the full config including backups. This method is kept for backward compatibility.



12
13
14
15
# File 'lib/belt/cli/backup_config.rb', line 12

def self.load(env, infra_dir: nil)
  env_config = EnvironmentConfig.load(env, infra_dir: infra_dir)
  env_config.backups? ? env_config.backup_config : nil
end

Instance Method Details

#any?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/belt/cli/backup_config.rb', line 32

def any?
  dynamodb? || cognito? || @s3_buckets.any?
end

#cognito?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/belt/cli/backup_config.rb', line 28

def cognito?
  @cognito_exports.any?
end

#dynamodb?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/belt/cli/backup_config.rb', line 24

def dynamodb?
  !@dynamodb_tables.nil?
end