그래서 postgres 템플릿 파일을 확인해 보았습니다. 이 파일은 DB를 하나만 대상으로 하고 있습니다. 이건 말이 안 되는 일이죠. 존재하는 데이터베이스를 순회하면서 각각을 변경했어야 했습니다. 이 시나리오에서 해결책을 찾는 분들을 위해 여기에 남겨 둡니다.
DB_LIST=$(su postgres -c "/usr/lib/postgresql/${PG_MAJOR_OLD}/bin/psql -p 5432 -tAc \"select datname from pg_database where not datistemplate and datname != 'postgres'\"")
for DB in $DB_LIST; do
su postgres -c "/usr/lib/postgresql/${PG_MAJOR_OLD}/bin/pg_dump -Fd -j$(nproc --ignore=1) \"$DB\" -f /shared/postgres_dump/\"$DB\""
done