BUGFIX: backup/restore rake tasks weren't working

This commit is contained in:
Régis Hanol
2014-02-19 15:25:31 +01:00
parent 7f6b2e5563
commit 438f97d8b0
6 changed files with 107 additions and 80 deletions

View File

@ -152,14 +152,10 @@ module Export
end
def build_pg_dump_command
db_conf = Rails.configuration.database_configuration[Rails.env]
host = db_conf["host"]
password = db_conf["password"]
username = db_conf["username"] || ENV["USER"] || "postgres"
database = db_conf["database"]
db_conf = BackupRestore.database_configuration
password_argument = "PGPASSWORD=#{password}" if password.present?
host_argument = "--host=#{host}" if host.present?
password_argument = "PGPASSWORD=#{password}" if db_conf.password.present?
host_argument = "--host=#{host}" if db_conf.host.present?
[ password_argument, # pass the password to pg_dump
"pg_dump", # the pg_dump command
@ -169,8 +165,8 @@ module Export
"--no-privileges", # prevent dumping of access privileges
"--verbose", # specifies verbose mode
host_argument, # the hostname to connect to
"--username=#{username}", # the username to connect as
database # the name of the database to dump
"--username=#{db_conf.username}", # the username to connect as
db_conf.database # the name of the database to dump
].join(" ")
end