Class: Decidim::Voca::AppBackup

Inherits:
Object
  • Object
show all
Defined in:
lib/decidim/voca/backup/app_backup.rb

Instance Method Summary collapse

Constructor Details

#initializeAppBackup

Returns a new instance of AppBackup.



6
7
8
# File 'lib/decidim/voca/backup/app_backup.rb', line 6

def initialize
  logger.info "⚙️ starts backup (##{now})"
end

Instance Method Details

#run!String

Run a backup of :

public/uploads
current database

And store it in a .tar.gz file.

Returns:

  • (String)

    the absolute path of the backuped file



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/decidim/voca/backup/app_backup.rb', line 16

def run!
  Dir.mktmpdir do |dir|
    logger.debug "Prepare backup in tmp dir '#{dir}'"
    dump_database(dir)
    compress_source_path(uploads_path, dir)
    compress_source_path(logs_path, dir)
    generate_metadatas(dir)
    with_backup_dir do |backup_dir|
      backup_file = "#{backup_dir}/#{now}-backup.tar.gz"
      compress_tar!("#{dir}/", backup_file)
      backup_file
    end
  end
end