我担心我恢复的数据库与原始数据库有很大不同:
#check size of postgres database
postgres@db1:/tmp$ psql -c "select pg_size_pretty(pg_database_size('test_db'));"
pg_size_pretty
----------------
2105 MB
(1 row)
#backup database
postgres@db1:/tmp$ pg_dump -Fc test_db > test_db_Fc.dump
#rename postgres database (i.e. park it nearby)
postgres@db1:/tmp$ psql -c "alter database test_db rename to test_db_20130322;"
ALTER DATABASE
-------
(1 row)
#restore test_db
postgres@db1:/tmp$ pg_restore -Fc -C -d postgres test_db_Fc.dump
#check size of restored postgres database
postgres@db1:/tmp$ psql -c "select pg_size_pretty(pg_database_size('test_db'));"
pg_size_pretty
----------------
257 MB
(1 row)
Run Code Online (Sandbox Code Playgroud)
原始数据库比恢复的数据库大很多倍。这里发生了什么?据我所知,test_db 服务的网站在恢复后仍然运行良好,但在实时上下文中使用备份之前,我需要知道发生了什么。
仅供参考,如果我在每个数据库上运行vacuumdb,数据库大小似乎没有变化。
[附录,稍后添加] 在 RTFM 的传统中,我已经在 PostgreSQL …
postgresql ×1