使用pg_restore恢复数据库时遇到问题。我在运行High Sierra(10.13.6(的Mac上安装了Postgres 12.2。它是用Brew安装的。
我用表"foo"创建了一个简单的数据库"foo"来测试这一点:
Nates-MacBook-Pro:k8s natereed$ psql -d foo
psql (12.2, server 12.1)
Type "help" for help.
foo=# SELECT table_schema,table_name
FROM information_schema.tables
WHERE table_schema='public' ORDER BY table_schema,table_name;
table_schema | table_name
--------------+------------
public | foo
(1 row)
生成转储:
pg_dump -Fc foo -f foo.backup
当我尝试恢复时,什么也没发生。pg_restore刚刚挂起:
pg_restore -h localhost -p 5432 -U postgres -v -Fc -f foo.backup
我尝试过这个命令的各种排列,但每次都挂起。在活动监视器中,我看到了进程,但它没有使用任何CPU。
在线帮助说:
pg_restore restores a PostgreSQL database from an archive created by pg_dump.
Usage:
pg_restore [OPTION]... [FILE]
General options:
-d, --dbname=NAME connect to database name
-f, --file=FILENAME output file name
-F, --format=c|d|t backup file format (should be automatic)
-l, --list print summarized TOC of the archive
-v, --verbose verbose mode
-V, --version output version information, then exit
-?, --help show this help, then exit
对于pg_restore,f是输出文件的参数:它不是输入文件。删除示例中的-f:
pg_restore -h localhost -p 5432 -U postgres -v -Fc foo.backup