class PostgresqlBackupAdapter
Public Instance Methods
create_backup(file)
click to toggle source
# File lib/jefferies_tube/postgresql_backup_adapter.rb, line 4 def create_backup(file) `#{password_option} pg_dump --verbose -Fc \ #{host_option} #{username_option} --file #{file} \ #{database} ` end
restore(file)
click to toggle source
# File lib/jefferies_tube/postgresql_backup_adapter.rb, line 11 def restore(file) `#{password_option} pg_restore --verbose --clean --no-acl --no-owner \ #{host_option} #{username_option} -d #{database} \ #{file}` end
Private Instance Methods
database()
click to toggle source
# File lib/jefferies_tube/postgresql_backup_adapter.rb, line 45 def database db_config "database" end
db_config(key)
click to toggle source
# File lib/jefferies_tube/postgresql_backup_adapter.rb, line 49 def db_config(key) Rails.configuration.database_configuration[Rails.env][key] end
db_option(name)
click to toggle source
# File lib/jefferies_tube/postgresql_backup_adapter.rb, line 19 def db_option(name) value = db_config(name) if (value) "--#{name}=#{value}" else "" end end
host_option()
click to toggle source
# File lib/jefferies_tube/postgresql_backup_adapter.rb, line 41 def host_option db_option('host') end
password_option()
click to toggle source
# File lib/jefferies_tube/postgresql_backup_adapter.rb, line 32 def password_option password = db_config('password') if password password_option = "PGPASSWORD=\"#{password}\"" else password_option = "" end end
username_option()
click to toggle source
# File lib/jefferies_tube/postgresql_backup_adapter.rb, line 28 def username_option db_option('username') end