Class: DbBackup

Inherits:
Backup show all
Defined in:
lib/backup/db_backup.rb

Direct Known Subclasses

MysqlBackup, PostgreBackup

Constant Summary

Constants inherited from Backup

Backup::DATE_FORMAT

Instance Attribute Summary collapse

Attributes inherited from Backup

#dry_run, #quiet

Instance Method Summary collapse

Methods inherited from Backup

#backup_command, #backup_type, #backup_type_filename, #clean_files, #compress?, #debug?, #encrypt?, #encrypt_compress_pipe_command, #ensure_path, #filename_extension, #filepath, #get_datetime_from_filename, #human_filesize, #mark_file_to_delete, #minimum_backup_size, #output_command, #print_info, #process_clean_files, #run, #show_statistics, #verify_backup

Constructor Details

#initialize(user: nil, database: nil, password: nil, compress: true, host: nil, encrypt: nil) ⇒ DbBackup

Returns a new instance of DbBackup.



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

def initialize user: nil, database: nil, password: nil, compress: true, host: nil, encrypt: nil
  super compress: compress, encrypt: encrypt
  user = ENV['DBUSER'] if user.nil?
  password = ENV['PASSWORD'] if password.nil?
  @password, @user, @database, @host = password, user, database, host
  ensure_path unless database.nil?
end

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



4
5
6
# File 'lib/backup/db_backup.rb', line 4

def database
  @database
end

#hostObject (readonly)

Returns the value of attribute host.



4
5
6
# File 'lib/backup/db_backup.rb', line 4

def host
  @host
end

#passwordObject (readonly)

Returns the value of attribute password.



4
5
6
# File 'lib/backup/db_backup.rb', line 4

def password
  @password
end

#userObject (readonly)

Returns the value of attribute user.



4
5
6
# File 'lib/backup/db_backup.rb', line 4

def user
  @user
end

Instance Method Details

#filenameObject



14
15
16
# File 'lib/backup/db_backup.rb', line 14

def filename
  "#{backup_type}-#{database}-#{DateTime.now.strftime(DATE_FORMAT)}.#{filename_extension('sql')}"
end

#pathObject



18
19
20
# File 'lib/backup/db_backup.rb', line 18

def path
  "#{Techinform::BACKUPS_LOCAL_PREFIX}/#{backup_type}/#{database}"
end

#restore_pathObject



22
23
24
# File 'lib/backup/db_backup.rb', line 22

def restore_path
  "#{Techinform::BACKUPS_ALL_PREFIX}/backups/#{backup_type}/#{database}"
end