Class: BackupMysql

Inherits:
DeployKit show all
Defined in:
lib/deploy_kit/backup_mysql.rb

Instance Method Summary collapse

Methods inherited from DeployKit

#backup_path, #check_conf, #create_dirs, #ensure_directory_exists, #initialize, #timestamp

Constructor Details

This class inherits a constructor from DeployKit

Instance Method Details

#backup(store) ⇒ Object



14
15
16
17
18
# File 'lib/deploy_kit/backup_mysql.rb', line 14

def backup(store)
  puts cmd if @verbose
  `#{cmd}`
  S3storage.new.put(final_filename) if store == "s3"
end

#cmdObject



6
7
8
9
10
11
12
# File 'lib/deploy_kit/backup_mysql.rb', line 6

def cmd
  """mysqldump -u\"#{@db_conf[:username]}\" -p\"#{@db_conf[:password]}\" \
  --default-character-set=utf8 --opt --extended-insert=false \
  --triggers -R --hex-blob --single-transaction #{options} #{@db_conf[:database]} | gzip \
  > #{final_filename}
  """
end

#final_filenameObject



2
3
4
# File 'lib/deploy_kit/backup_mysql.rb', line 2

def final_filename
  File.join(backup_path, "#{@fu_conf[:app_name]}_backup_mysql_#{timestamp}.gz")
end

#optionsObject



20
21
22
23
24
25
26
27
28
# File 'lib/deploy_kit/backup_mysql.rb', line 20

def options
  options = []

  if !@db_conf[:socket].blank?
    options << "--socket=#{@db_conf[:socket]}"
  end

  options.join(" ")
end