2016-07-06 132 views
0

我有我們的數據庫的一個小子集作爲轉儲做集成測試。我恢復使用此命令它:Codeship恢復PostgreSQL數據庫?

pg_restore --no-acl --no-owner --verbose --create -h localhost -p 5435 -j 4 -U $PG_USER -d test latest.dump 

的問題是,在日誌中我看到:

pg_restore: connecting to database for restore 
pg_restore: processing item 5308 ENCODING ENCODING 
pg_restore: processing item 5309 STDSTRINGS STDSTRINGS 
pg_restore: processing item 5310 DATABASE dlq8aimf0q2pf 
pg_restore: creating DATABASE dlq8aimf0q2pf 
pg_restore: connecting to new database "dlq8aimf0q2pf" 
pg_restore: connecting to database "dlq8aimf0q2pf" as user "postgres" 

正如你可以看到它試圖爲我指定了打造「dlq8aimf0q2pf」而不是「測試」。 我可以獲得數據庫名稱嗎?什麼ENV var使用這個名字?

回答

0

正如pg_restore doc說一下--create選項:

當使用這個選項,和-d在一起的數據庫名只是用於發出 初始DROP DATABASE和CREATE DATABASE命令。 所有數據都將恢復到存檔中顯示的 數據庫名稱。

如果你有一個現有的數據庫test,並希望恢復到它,不要使用--create