Class: DevArchive::Stores::Mysql::Backup

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(names, dir) ⇒ Backup

Returns a new instance of Backup.



31
32
33
34
# File 'lib/dev_archive/stores.rb', line 31

def initialize(names, dir)
  @names = names
  @dir = dir
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



30
31
32
# File 'lib/dev_archive/stores.rb', line 30

def dir
  @dir
end

#namesObject (readonly)

Returns the value of attribute names.



30
31
32
# File 'lib/dev_archive/stores.rb', line 30

def names
  @names
end

Class Method Details

.call(names, dir) ⇒ Object



26
27
28
# File 'lib/dev_archive/stores.rb', line 26

def self.call(names, dir)
  new(names, dir).call
end

Instance Method Details

#callObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/dev_archive/stores.rb', line 36

def call
  Cfg.shell.puts("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