pg_restore
TLDR
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]
SYNOPSIS
pg_restore [options] [file]
DESCRIPTION
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).
PARAMETERS
-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.
EXAMPLES
$ # Basic restore
pg_restore -d mydb backup.dump
# Create database and restore
pg_restore -C -d postgres backup.dump
# Selective restore
pg_restore -l backup.dump > toc.txt
# Edit toc.txt to comment out unwanted items
pg_restore -d mydb -L toc.txt backup.dump
# Parallel restore
pg_restore -d mydb -j 4 backup.dump
pg_restore -d mydb backup.dump
# Create database and restore
pg_restore -C -d postgres backup.dump
# Selective restore
pg_restore -l backup.dump > toc.txt
# Edit toc.txt to comment out unwanted items
pg_restore -d mydb -L toc.txt backup.dump
# Parallel restore
pg_restore -d mydb -j 4 backup.dump
CAVEATS
Cannot restore plain SQL dumps. Parallel restore requires directory format. May need superuser for some objects.
HISTORY
pgrestore is part of **PostgreSQL**, complementing pgdump for custom format backup restoration.
SEE ALSO
pg_dump(1), pg_dumpall(1), psql(1)


