Skip to content

Commit f4aebf6

Browse files
committed
pg_restore/pg_dump: add page
1 parent 9206f19 commit f4aebf6

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

pages/common/pg_dump.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# pg_dump
2+
3+
> Extract a PostgreSQL database into a script file or other archive file
4+
5+
- Dump database into a SQL-script file:
6+
7+
`pg_dump {{db_name}} > {{output_file.sql}}`
8+
9+
- Same as above, customize username:
10+
11+
`pg_dump -U {{username}} {{db_name}} > {{output_file.sql}}`
12+
13+
- Same as above, customize host and port:
14+
15+
`pg_dump -h {{host}} -p {{port}} {{db_name}} > {{output_file.sql}}`
16+
17+
- Dump a database into a custom-format archive file:
18+
19+
`pg_dump -Fc {{db_name}} > {{output_file.dump}}`

pages/common/pg_restore.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# pg_restore
2+
3+
> Restore a PostgreSQL database from an archive file created by pg_dump.
4+
5+
- Restore an archive into an existing database:
6+
7+
`pg_restore -d {{db_name}} {{archive_file.dump}}`
8+
9+
- Same as above, customize username:
10+
11+
`pg_restore -U {{username}} -d {{db_name}} {{archive_file.dump}}`
12+
13+
- Same as above, customize host and port:
14+
15+
`pg_restore -h {{host}} -p {{port}} -d {{db_name}} {{archive_file.dump}}`
16+
17+
- Clean database objects before creating them:
18+
19+
`pg_restore --clean -d {{db_name}} {{archive_file.dump}}`
20+
21+
- Use multiple jobs to do the restoring:
22+
23+
`pg_restore -j {{2}} -d {{db_name}} {{archive_file.dump}}`

0 commit comments

Comments
 (0)