Class: SnapshotArchive::Stores::Mysql::Backup

Inherits:
Object
  • Object
show all
Defined in:
lib/snapshot_archive/stores.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir:, id:, args:) ⇒ Backup

Returns a new instance of Backup.



42
43
44
45
46
# File 'lib/snapshot_archive/stores.rb', line 42

def initialize(dir:, id:, args:, **)
  @dir = dir
  @id = id
  @names = args
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



41
42
43
# File 'lib/snapshot_archive/stores.rb', line 41

def dir
  @dir
end

#idObject (readonly)

Returns the value of attribute id.



41
42
43
# File 'lib/snapshot_archive/stores.rb', line 41

def id
  @id
end

#namesObject (readonly)

Returns the value of attribute names.



41
42
43
# File 'lib/snapshot_archive/stores.rb', line 41

def names
  @names
end

Class Method Details

.callObject



37
38
39
# File 'lib/snapshot_archive/stores.rb', line 37

def self.call(...)
  new(...).call
end

Instance Method Details

#callObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/snapshot_archive/stores.rb', line 48

def call
  Cfg.shell.debug("backing up #{names} into #{dir}")

  path = File.join(dir, "mysql.sql.gz")

  Cfg.shell.run(<<~SH)
    mysqldump \
      --add-drop-database \
      --databases #{names.join(" ")} \
      | gzip > #{path}
  SH

  {
    type: "mysql",
    path: path,
    databases: names
  }
end