class BackupFoundation::Item::PostgreSQL
Public Class Methods
exist?(rails_env=nil)
click to toggle source
# File lib/backup_foundation/item/postgresql.rb, line 5 def exist?(rails_env=nil) defined?(ActiveRecord::Base) && ActiveRecord::Base.configurations && ActiveRecord::Base.configurations[rails_env] && ActiveRecord::Base.configurations[rails_env]['adapter'] == 'postgresql' end
get_config(rails_env=nil)
click to toggle source
# File lib/backup_foundation/item/postgresql.rb, line 12 def get_config(rails_env=nil) config = ActiveRecord::Base.configurations[rails_env] { host: config['host'] || config['socket'], port: config['port'], username: config['username'], password: config['password'], database: config['database'] } end
Public Instance Methods
command_params()
click to toggle source
# File lib/backup_foundation/item/postgresql.rb, line 28 def command_params [:host, :port, :username].map do |option| next if @options[option].blank? "--#{option}='#{@options[option]}'" end.compact.join ' ' end
command_password_variable()
click to toggle source
# File lib/backup_foundation/item/postgresql.rb, line 35 def command_password_variable @options[:password].blank? ? '' : "PGPASSWORD='#{@options[:password]}'" end
load_dump(infile_path)
click to toggle source
# File lib/backup_foundation/item/postgresql.rb, line 39 def load_dump(infile_path) decrypt_if_needed_and_restore "#{command_password_variable} psql #{command_params} #{@options[:database]}", infile_path end
save_dump(tmpdir)
click to toggle source
# File lib/backup_foundation/item/postgresql.rb, line 24 def save_dump(tmpdir) dump_and_encrypt_if_needed "#{command_password_variable} pg_dump #{command_params} #{@options[:database]}" end