I
I
Igor_Petrovv2020-05-25 21:16:27
PostgreSQL
Igor_Petrovv, 2020-05-25 21:16:27

How to make a dump if we do not know the name of the base, but want to dump everything one by one?

Here is the almost finished code, how to modify it to solve the dump task, and the dump should be saved in the custom format:
#!/bin/bash

set -e
set -u
set -o pipefail

pathToConf="$dir/conf_${currentDate} ”
user=“postgres”
database=“db”

mkdir $pathToConf
cp /var/postgres/11/data/pg_hba.conf $pathToConf
cp /var/postgres/11/data/postgresql.conf $pathToConf

pg_dump -h 127.0.0.1 -d db -U ${user} -F c -f dump.tar.gz

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2020-05-25
@Igor_Petrovv

select datname from pg_database where datallowconn and datname != 'template0'

Like pg_dumpall

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question