简体   繁体   中英

How to restore a postgres database

我在系统上执行了pg_dumpall -c -f <BACKUP_FILE>.sql ,我想在另一个系统上进行还原,并让postgres为我创建所有角色/数据库/表空间,这可能吗?

This is clearly outlined in the PostgreSQL docs.

https://www.postgresql.org/docs/9.5/static/backup-dump.html

24.1.1. Restoring the Dump

Text files created by pg_dump are intended to be read in by the psql program. The general command form to restore a dump is

psql dbname < infile

where infile is the file output by the pg_dump command. The database dbname will not be created by this command, so you must create it yourself from template0 before executing psql (eg, with createdb -T template0 dbname). psql supports options similar to pg_dump for specifying the database server to connect to and the user name to use. See the psql reference page for more information. Non-text file dumps are restored using the pg_restore utility.

The issue was that the most recent PE uses postgres 9.4, I could without errors restore to a postgres server running postgres 9.5. My bad, should have checked the rpm's on the PE puppetDB server first.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM