pg_dump has a great option, it allows you to select custom format for the output of the backup.
Output a custom-format archive suitable for input into pg_restore. Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default.
It can be specified with -Fc
argument. e.g.
pg_dump -Fc mydb > db.dump
I have a few databases and roles/users, so I want to back everything up in one file with one command.
There is a great command pg_dumpall
for that.
pg_dumpall is a utility for writing out ("dumping") all PostgreSQL databases of a cluster into one script file. The script file contains SQL commands that can be used as input to psql to restore the databases. It does this by calling pg_dump for each database in a cluster. pg_dumpall also dumps global objects that are common to all databases.
The output of pg_dumpall is an SQL-script, but I would like to have it as a custom-format archive.
Unfortunately, I can't provide -Fc
argument to pg_dumpall
.
Is there a way to back up all DBs and roles etc. using custom-format archive?