pg_dump <dbname>

Dumps a database as a text file or to other formats

Arguments

NameDescription
dbnameName of the database to dump

Options

NameDescription
--help, -?Show help for pg_dump
--file, -f <filename>Output file or directory name
--format, -F <format>Output file format
--jobs, -j <num>Number of parallel job to dump
--verbose, -vVerbose mode
--version, -VOutput version information
--compress, -Z <level>Compression level for compressed formats
--lock-wait-timeout <timeout>Fail after waiting <timeout> for a table lock
--no-syncDo not wait for changes to be written safely to disk
--data-only, -aDump only the data, not the schema
--blobs, -bInclude large objects in dump
--no-blobs, -BExclude large objects in dump
--clean, -cClean (drop) database objects before recreating
--create, -CInclude commands to create database in dump
--extension, -e <pattern>
  • Repeatable ♾
--encoding, -E <encoding>Dump the data in encoding <encoding>
--schema, -n <pattern>
  • Repeatable ♾
--exclude-schema, -N <pattern>
  • Repeatable ♾
--no-owner, -OSkip restoration of object ownership in plain-text format
--schema-only, -sDump only the schema, no data
--superuser, -S <name>Superuser user name to use in plain-text format
--table, -t <table>
  • Repeatable ♾
--exclude-table, -T <table>
  • Repeatable ♾
--no-privileges, -x, --no-aclDo not dump privileges (grant/revoke)
--binary-upgradeFor use by upgrade utilities only
--column-inserts, --attribute-insertsDump data as INSERT commands with column names
--disable-dollar-quotingDisable dollar quoting, use SQL standard quoting
--disable-triggersDisable triggers during data-only restore
--enable-row-securityEnable row security (dump only content user has access to)
--exclude-table-data <table>
  • Repeatable ♾
--extra-float-digits <num>Override default setting for extra_float_digits
--if-existsUse IF EXISTS when dropping objects
--include-foreign-data <pattern>Include data of foreign tables on foreign servers matching PATTERN
--insertsDump data as INSERT commands, rather than COPY
--load-via-partition-rootLoad partitions via the root table
--no-commentsDo not dump comments
--no-publicationsDo not dump publications
--no-security-labelsDo not dump security label assignments
--no-subscriptionsDo not dump subscriptions
--no-synchronized-snapshotsDo not use synchronized snapshots in parallel jobs
--no-tablespacesDo not dump tablespace assignments
--no-toast-compressionDo not dump TOAST compression methods
--no-unlogged-table-dataDo not dump unlogged table data
--on-conflict-do-nothingAdd ON CONFLICT DO NOTHING to INSERT commands
--quote-all-identifiersQuote all identifiers, even if not key words
--rows-per-insert <numbers>Number of rows per INSERT; implies --inserts
--section <section>Dump named section (pre-data, data, or post-data)
--serializable-deferrableWait until the dump can run without anomalies
--snapshot <snapshot>Use given snapshot for the dump
--strict-namesRequire table and/or schema include patterns to match at least one entity each
--use-set-session-authorizationUse SET SESSION AUTHORIZATION commands instead of ALTER OWNER commands to set ownership
--dbname, -d <database>Database to dump
--host, -h <host>Database server host or socket directory
--port, -p <number>Database server port number
--username, -U <name>Connect as specified database user
--no-password, -wNever prompt for password
--password, -WForce password prompt (should happen automatically)
--role <name>Do SET ROLE before dump