Class: KamalBackup::Databases::Sqlite

Inherits:
Base
  • Object
show all
Defined in:
lib/kamal_backup/databases/sqlite.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #redactor

Instance Method Summary collapse

Methods inherited from Base

#backup_tags, #database_filename, #initialize

Constructor Details

This class inherits a constructor from KamalBackup::Databases::Base

Instance Method Details

#adapter_nameObject



8
9
10
# File 'lib/kamal_backup/databases/sqlite.rb', line 8

def adapter_name
  "sqlite"
end

#backup(restic, timestamp) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/kamal_backup/databases/sqlite.rb', line 16

def backup(restic, timestamp)
  source = sqlite_source
  Tempfile.create(["kamal-backup-", ".sqlite3"]) do |tempfile|
    tempfile.close
    Command.capture(
      CommandSpec.new(argv: ["sqlite3", source, ".backup #{sqlite_literal(tempfile.path)}"]),
      redactor: redactor
    )
    restic.backup_file_content(
      tempfile.path,
      filename: database_filename(timestamp),
      tags: backup_tags(timestamp)
    )
  end
end

#dump_commandObject

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/kamal_backup/databases/sqlite.rb', line 37

def dump_command
  raise NotImplementedError, "SQLite backup uses .backup into a temporary file"
end

#dump_extensionObject



12
13
14
# File 'lib/kamal_backup/databases/sqlite.rb', line 12

def dump_extension
  "sqlite3"
end

#restore(restic, snapshot, filename) ⇒ Object



32
33
34
35
# File 'lib/kamal_backup/databases/sqlite.rb', line 32

def restore(restic, snapshot, filename)
  validate_restore_target!
  restic.dump_file_to_path(snapshot, filename, restore_target)
end

#restore_commandObject

Raises:

  • (NotImplementedError)


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

def restore_command
  raise NotImplementedError, "SQLite restore writes the database file directly"
end

#restore_target_identifierObject



45
46
47
# File 'lib/kamal_backup/databases/sqlite.rb', line 45

def restore_target_identifier
  restore_target
end