#!/bin/bash

for bdd in 'dbname01' 'dbname02' 'dbname03'
do
    `echo "Procesando $bdd" >> salida.log`
    `echo "Procesando $bdd" >> error.log`
    `pg_dump -C -Fp -h hostname -U postgres ${bdd}  | gzip -c > ${bdd}_dump.sql.gz `
    #`gunzip < ${bdd}_dump.sql.gz | psql -h hostname -U postgres postgres -f - > salida_restore.log`
done

For performing the restore, uncomment de gunzip line and comment the pg_dump one