Skip to content

Instantly share code, notes, and snippets.

@rjdp
Created January 14, 2017 07:30
Show Gist options
  • Save rjdp/742a93b0621d832d36095e3666b9027f to your computer and use it in GitHub Desktop.
Save rjdp/742a93b0621d832d36095e3666b9027f to your computer and use it in GitHub Desktop.
dump each db postgres
#!/bin/bash
echo "PostgreSQL"
export PGPASSWORD="postgre password here"
DBLIST=`psql -U postgres -d postgres -q -t -c 'SELECT datname from pg_database'`
for d in $DBLIST
do
echo "Dumping $d";
pg_dump -U postgres $d > /path/to/dump/directory/$d.postgres.sql
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment