I have 100 databases in my cluster. I need to backup 30 databases (as single file or multiple file, anything is fine). I could do it for tables using pg_dump
with -t
.
Is there any way to do something like this (pseudocode):
pg_dump -d db1 -d db2 -d db3 -Fc > dbs_backup.backup
Best Answer
pg_dump
can only dump a single DB. The manual:pg_dumpall
, on the other hand can only dump all DBs in the cluster, even if you provide a specific DB name in the connection string. The manual:To dump some DBs but not all, use a shell script, like has been advised. You may want to include commands to create each DB in the dump: