I inherited a postgres DB (which I have very little experience with) and trying to figure out a way to dump/back it up. I've been reading docs about it and can get as far as dumping the DBs into separate files but wondering why I can't dump template0. As I understand this is a sort of "defaults" template which seems important to hang onto if modified. Why isn't this working?
test# export PGPASSWORD="xxxxxxx"; for database in `psql --username=postgres --command='\list' -h localhost | grep '^ [a-zA-Z0-9]' | awk '{print $1};'`; do pg_dump -U postgres ${database} > ${database}.sql; done
pg_dump: [archiver (db)] connection to database "template0" failed: FATAL: database "template0" is not currently accepting connections