PostgreSQL backup
#!/bin/bash
CAS=`date +"%d.%m.%y %T"`
echo "Zacetek dumpanja: $CAS"
echo "Zacetek dumpanja: $CAS" >> /var/log/postdump.err
cd /var/backup/postgres
rm -f *.sql.gz
cd /var/lib/postgresql
for baza in `/bin/su -c "psql -l" postgres | tr -d ' ' | egrep -v "Name|-|Listofdatabases|rows|template0" | cut -f1 -d '|' | sed -e '/^$/d'`
do
echo "Obdelujem bazo $baza"
/bin/su -c "pg_dump $baza > $baza.sql" postgres
gzip -f --best $baza.sql
mv $baza.sql.gz /var/backup/postgres
done
CAS=`date +"%d.%m.%y %T"`
echo "Konec: $CAS"
echo "Konec: $CAS" >> /var/log/postdump.err
echo
echo >> /var/log/postdump.err