微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

PostgreSQL 9.0.13执行pg_restore但没有证据表明正在使用磁盘空间

我正在尝试从另一台服务器恢复使用此命令获取的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.sql

pg-backup.sql文件是13GB.
pg-restore已经运行了4个小时,一直在我的屏幕上滚动数据.没有错误.

但是当我从psql会话中执行此语句时

SELECT pg_size_pretty(pg_database_size('salesDB'));

我的大小为5377 kB.什么?它现在至少应该是1GB.
我完全迷失了.所有这些数据都在我的屏幕上滚动,我无法证明它会在任何地方.没有磁盘使用.

救命

在pg_restore命令中没有“-f”标志的情况下尝试它.此外,您可能想尝试创建空的salesdb数据库并传入“-d salesdb”.请注意,除非在双引号内创建,否则db名称将折叠为小写.

添加了示例步骤,以显示在还原运行时数据库的大小增加

-- 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

原文地址:https://www.jb51.cc/postgresql/191941.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐