class Postgres::Clone::Executable
Public Instance Methods
clone_database()
click to toggle source
# File lib/postgres/clone/executable.rb, line 16 def clone_database print_hosts_disk_space if options[:src_host] == options[:dst_host] create_database_using_template else create_database_using_restore end print_hosts_disk_space close_ssh_connections end
Private Instance Methods
create_database_using_restore()
click to toggle source
# File lib/postgres/clone/executable.rb, line 34 def create_database_using_restore file_path = options[:file_path] || "/tmp/#{file_name}" postgres_dump_database(options[:src_host], options[:src_db], file_path) copy_file(options[:src_host], options[:dst_host], file_path) postgres_restore_database( options[:dst_host], options[:dst_db] || file_name, file_path ) log_message('Finished restoring database!', header: '', color: :green) end
create_database_using_template()
click to toggle source
# File lib/postgres/clone/executable.rb, line 50 def create_database_using_template postgres_create_database( options[:src_host], options[:dst_db] || file_name, template: options[:src_db] ) log_message('Finished creating database!', header: '', color: :green) end
file_name()
click to toggle source
# File lib/postgres/clone/executable.rb, line 60 def file_name @file_name ||= begin if options[:file_path].nil? "#{options[:src_db]}_#{Time.now.strftime('%Y%m%d')}" else File.basename(options[:file_path]) end end end
print_hosts_disk_space()
click to toggle source
# File lib/postgres/clone/executable.rb, line 70 def print_hosts_disk_space [options[:src_host], options[:dst_host]].uniq.each do |host_name| print_host_disk_space(host_name) end end