3
我正在使用postgres編寫一個rails項目,並且服務器中有一些數據。我想從遠端轉儲數據到本地,所以我寫腳本來做到這一點,但一些錯誤出來了。psql錯誤:關係已存在
這是轉儲腳本:
run "PGPASSWORD='#{remote_settings['password']}'
pg_dump -U #{remote_settings["username"]} #{"-h '#{remote_settings["host"]}'"
if remote_settings["host"]}
'#{remote_settings["database"]}' > #{remote_sql_file_path}"
有一些代碼來運..
Transport codes
這是恢復腳本:
run_locally "PGPASSWORD='#{local_settings['password']}' psql -U
#{local_settings["username"]} -d #{local_settings["database"]}
-f #{local_sql_file_path}"
我順利拿到數據文件,但是當有一些錯誤*當**還原腳本正在運行:
psql:tmp/production-ib5k_production-2013-02-21_18:42:09.sql:46: ERROR: relation "refinery_images" already exists
psql:tmp/production-ib5k_production-2013-02-21_18:42:09.sql:49: ERROR: role "ib5k" does not exist
psql:tmp/production-ib5k_production-2013-02-21_18:42:09.sql:60: ERROR: relation "refinery_images_id_seq" already exists
psql:tmp/production-ib5k_production-2013-02-21_18:42:09.sql:63: ERROR: role "ib5k" does not exist
psql:tmp/production-ib5k_production-2013-02-21_18:42:09.sql:83: ERROR: relation "refinery_page_part_translations" already exists
psql:tmp/production-ib5k_production-2013-02-21_18:42:09.sql:86: ERROR: role "ib5k" does not exist
...
sql:tmp/production-ib5k_production-2013-02-21_18:42:09.sql:525: ERROR: duplicate key value violates unique constraint "refinery_images_pkey"
DETAIL: Key (id)=(1) already exists.
CONTEXT: COPY refinery_images, line 2: ""
psql:tmp/production-ib5k_production-2013-02-21_18:42:09.sql:547: ERROR: duplicate key value violates unique constraint "refinery_page_part_translations_pkey"
DETAIL: Key (id)=(1) already exists.
CONTEXT: COPY refinery_page_part_translations, line 8: ""
psql:tmp/production-ib5k_production-2013-02-21_18:42:09.sql:569: ERROR: duplicate key value violates unique constraint "refinery_page_parts_pkey"
DETAIL: Key (id)=(1) already exists.
CONTEXT: COPY refinery_page_parts, line 8: ""
...
而且本地數據庫不會被更新。 我想知道如何解決它?添加一些參數?先謝謝你。