我正在尝试恢复使用此命令从另一台服务器获取的pg_dump。
sudo -u postgres pg_dump --verbose --format=custom --file=pg-backup.sql -U postgres salesDB在复制pg-backup.sql文件之后,我尝试使用以下命令进行恢复
sudo -u postgres pg_restore --verbose --jobs=`nproc` -f pg-backup.sqlpg-backup.sql文件大小为13 is。pg-restore已经运行了4个小时,一直在我的屏幕上滚动数据。没有错误。
但是当我在psql会话中执行这条语句时
SELECT pg_size_pretty(pg_database_size('salesDB'));我有5377个kB大小。什么?现在至少应该是1 1GB了。我完全迷路了。所有这些数据都在我的屏幕上滚动,我不能证明它会出现在任何地方。无磁盘使用率。
帮助
发布于 2013-07-11 08:56:26
在pg_restore命令中尝试不使用"-f“标志。此外,您可能希望尝试创建空的salesdb数据库,并传入"-d salesdb“。请注意,数据库名称将折叠为小写,除非它是在双引号内创建的。
添加了示例步骤,以显示数据库的大小随着恢复的运行而增加
-- sample pg_dump command
pg_dump -f testdb.out -Fc src_test_db
-- create the db to restore into
createdb sometestdb
-- restore with 4 parallel jobs, from the "testdb.out" file, into the db "sometestdb"
time pg_restore --dbname=sometestdb --jobs=4 testdb.out
-- In another window, every few seconds, you can see the db growing
psql -d postgres -c "select pg_size_pretty(pg_database_size('sometestdb'))"
pg_size_pretty
----------------
4920 MB
psql -d postgres -c "select pg_size_pretty(pg_database_size('sometestdb'))"
pg_size_pretty
----------------
4920 MB
psql -d postgres -c "select pg_size_pretty(pg_database_size('sometestdb'))"
pg_size_pretty
----------------
5028 MB
psql -d postgres -c "select pg_size_pretty(pg_database_size('sometestdb'))"
pg_size_pretty
----------------
5371 MB发布于 2013-07-12 03:48:40
已解决-语法错误据我所知,-f (输出文件)参数无用。我需要为pg_restore指定一个不带任何标志的文件,只作为命令行中的最后一个元素使用。需要-d salesdb参数。我有16个cpus,所以我设置了-j 15,这似乎很有帮助。我的最后一个命令行是
sudo -u postgres pg_restore -d salesdb --jobs=15 backup10.sql然后,我使用pg_database_size函数获得了非常快的大小增量。
它正在像它应该的那样增长。
发布于 2013-07-11 09:39:15
在我看来,您一直在告诉pg_restore将转储的内容打印到显示器上,而不是恢复到数据库中。您是否指定了--dbname
就我个人而言,我认为pg_restore的命令行语法不是特别直观,如果我有时间的话,这是我想在Pg中尝试改进的事情之一。
https://stackoverflow.com/questions/17582928
复制相似问题