Created
June 18, 2012 16:51
-
-
Save kkdeploy/2949374 to your computer and use it in GitHub Desktop.
pg_dump all tables not consistently (!!!)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| mydir=/var/lib/pgsql/backups/`date +%Y-%m-%d_%H-%M` | |
| function dumpdb { | |
| mkdir -p $mydir/$1 | |
| for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" $1` ; do | |
| pg_dump -t $tbl $1 | gzip > $mydir/$1/$tbl.sql.gz; | |
| done | |
| } | |
| function dumpall { | |
| for db in `psql -qAt -c "SELECT datname FROM pg_database;"` ; do | |
| dumpdb $db; | |
| done | |
| } | |
| dumpall |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment