1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-07-05 18:15:24 +02:00
tldr/pages/common/pg_restore.md

29 lines
943 B
Markdown
Raw Normal View History

2016-01-07 14:45:17 +08:00
# pg_restore
> Restore a PostgreSQL database from an archive file created by pg_dump.
2019-05-29 14:53:44 +01:00
> More information: <https://www.postgresql.org/docs/current/app-pgrestore.html>.
2016-01-07 14:45:17 +08:00
- Restore an archive into an existing database:
`pg_restore {{[-d|--dbname]}} {{db_name}} {{archive_file.dump}}`
2016-01-07 14:45:17 +08:00
- Same as above, customize username:
`pg_restore {{[-U|--username]}} {{username}} {{[-d|--dbname]}} {{db_name}} {{archive_file.dump}}`
2016-01-07 14:45:17 +08:00
- Same as above, customize host and port:
`pg_restore {{[-h|--host]}} {{host}} {{[-p|--port]}} {{port}} {{[-d|--dbname]}} {{db_name}} {{archive_file.dump}}`
2016-01-07 14:45:17 +08:00
- List database objects included in the archive:
`pg_restore {{[-l|--list]}} {{archive_file.dump}}`
2016-01-07 14:45:17 +08:00
- Clean database objects before creating them:
`pg_restore {{[-c|--clean]}} {{[-d|--dbname]}} {{db_name}} {{archive_file.dump}}`
2016-01-07 14:45:17 +08:00
- Use multiple jobs to do the restoring:
`pg_restore {{[-j|--jobs]}} {{2}} {{[-d|--dbname]}} {{db_name}} {{archive_file.dump}}`