Class: KamalBackup::Evidence

Inherits:
Object
  • Object
show all
Defined in:
lib/kamal_backup/evidence.rb

Instance Method Summary collapse

Constructor Details

#initialize(config, restic:, redactor:) ⇒ Evidence

Returns a new instance of Evidence.



11
12
13
14
15
# File 'lib/kamal_backup/evidence.rb', line 11

def initialize(config, restic:, redactor:)
  @config = config
  @restic = restic
  @redactor = redactor
end

Instance Method Details

#to_hObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/kamal_backup/evidence.rb', line 17

def to_h
  Schema.record(
    kind: 'evidence',
    app_name: @config.app_name,
    generated_at: Time.now.utc.iso8601,
    database_adapter: @config.database_adapter,
    databases: @config.databases.map do |database|
      { name: database.database_name, adapter: database.database_adapter }
    end,
    restic_repository: @redactor.redact_string(@config.restic_repository.to_s),
    backup_paths: @config.backup_paths,
    paths: @config.backup_paths,
    forget_after_backup: @config.forget_after_backup?,
    retention: @config.retention,
    latest_database_backup: latest_snapshot_summary(['type:database']),
    latest_database_backups: latest_database_backups,
    latest_file_backup: latest_snapshot_summary(['type:files']),
    last_restic_check: last_check,
    last_restore_drill: last_restore_drill,
    image_version: VERSION,
    tool_versions: tool_versions
  )
end

#to_json(*args) ⇒ Object



41
42
43
# File 'lib/kamal_backup/evidence.rb', line 41

def to_json(*args)
  JSON.pretty_generate(to_h, *args)
end