Class: Backups::Create

Inherits:
Object
  • Object
show all
Defined in:
lib/backups/create.rb

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Create

Returns a new instance of Create.



3
4
5
6
7
# File 'lib/backups/create.rb', line 3

def initialize(name)
  @name = name
  @path = Backups.databases[name.to_s]
  @key = SecureRandom.hex(16)
end

Instance Method Details

#runObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/backups/create.rb', line 9

def run
  execute_backup

  Backup.create(database: name).tap do
    it.file.attach(io: compressed_data, filename: key)
    File.delete(backup_path)
    File.delete("#{backup_path}.gz")
  end

  expire_old_backups
end