9
The Custom Format
;
; Archive created at 2017-
; dbname: demo
; TOC Entries: 146
; Compression: -1
; Dump Version: 1.12-0
; Format: CUSTOM
;
; Selected TOC Entries:
;
2297; 1262 475453 DATABASE
5; 2615 475454 SCHEMA - bo
2298; 0 0 COMMENT - SCHEMA
$ pg_dump -d base -F c -f file
$ pg_restore -d base -j N file
an internal format with a table of contents
database objects to be restored can be selected at the time of recovery
recovery can be performed in parallel mode
The pg_dump utility supports several backup formats. By default, the plain
format is used; it provides pure psql commands.
The custom (-F c, --format = custom) format creates a backup
in a special format containing not only objects, but also a table of contents.
Having a TOC allows you to choose the objects to be restored right at the
time of recovery, not while making the dump. By default, the the custom
format output is compressed.
To restore the database, you need to run another utility: pg_restore.
It reads the file and converts it to psql commands. If you do not explicitly
provide the database name (in the -d option), all commands will be output
to the standard output stream. If you do specify a database name, the utility
will connect to that database and execute the commands directly, without
using psql.
To restore only some of the objects, you can use one of the following
approaches. The first one is to filter the objects to be restored, just like it is
done in pg_dump. pg_restore actually supports many of the same options
as pg_dump.
The second option is to use the TOC to retrieve the list of objects included
into the backup (via the --list option). Then you can edit this list manually:
delete the objects you do not need and pass the modified list to pg_restore
(via the --use-list option).
Uploading can be performed in parallel by specifying the number of threads
with the -j switch – this is another advantage of the custom format.