Linux command
pg_restore 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Restore from custom format
pg_restore -d [database] [backup.dump]
Restore specific table
pg_restore -d [database] -t [tablename] [backup.dump]
List contents of backup
pg_restore -l [backup.dump]
Restore with parallelism
pg_restore -d [database] -j [4] [backup.dump]
Clean before restore
pg_restore -d [database] -c [backup.dump]
说明
pg_restore restores PostgreSQL databases from archives created by pg_dump in custom, directory, or tar format. It cannot restore plain SQL dumps (use psql for those). The tool can selectively restore objects using a table-of-contents file, run multiple parallel jobs (directory format only), and optionally create the target database before restoring.
参数
- -d, --dbname _name_
- Database to restore to.
- -t, --table _name_
- Restore specific table.
- -n, --schema _name_
- Restore specific schema.
- -j, --jobs _num_
- Parallel jobs.
- -c, --clean
- Drop objects before creating.
- -C, --create
- Create the database.
- -l, --list
- List archive contents.
- -L _file_
- Use table of contents file.
FAQ
What is the pg_restore command used for?
pg_restore restores PostgreSQL databases from archives created by pg_dump in custom, directory, or tar format. It cannot restore plain SQL dumps (use psql for those). The tool can selectively restore objects using a table-of-contents file, run multiple parallel jobs (directory format only), and optionally create the target database before restoring.
How do I run a basic pg_restore example?
Run `pg_restore -d [database] [backup.dump]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -d, --dbname _name_ do in pg_restore?
Database to restore to.