2016-07-06 99 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