Class: PostgreBackup

Inherits:
DbBackup show all
Defined in:
lib/backup/postgre_backup.rb

Constant Summary

Constants inherited from Backup

Backup::DATE_FORMAT

Instance Attribute Summary

Attributes inherited from DbBackup

#database, #host, #password, #user

Attributes inherited from Backup

#dry_run, #quiet

Instance Method Summary collapse

Methods inherited from DbBackup

#filename, #initialize, #path, #restore_path

Methods inherited from Backup

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

Constructor Details

This class inherits a constructor from DbBackup

Instance Method Details

#backup_commandObject



8
9
10
# File 'lib/backup/postgre_backup.rb', line 8

def backup_command
  "#{"PGPASSWORD=#{password}" if password} pg_dump --clean --if-exists --no-owner #{"--host=#{host}" if host} #{"--username=#{user}" if user} #{database}"
end

#db_listObject



12
13
14
# File 'lib/backup/postgre_backup.rb', line 12

def db_list
  @db_list ||= (`#{"PGPASSWORD=#{password}" if password} psql #{"--host=#{host}" if host} #{"--username=#{user}" if user} -t -c 'SELECT datname FROM pg_database WHERE datistemplate = false;'`.split.compact - ['root'])
end


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

def print_info
  puts "Run postgre backup on #{database} to #{filepath}..."
end