Created
August 14, 2015 16:57
-
-
Save egoens/70950031aeec2df5d074 to your computer and use it in GitHub Desktop.
Shell script for exporting all tables for any given postgresql database_name
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 | |
# exports separate sql files for each table in the db. excludes "pg_" and "sql_" prefixed tables | |
for table in $(psql database_name -t -c "Select table_name From information_schema.tables Where table_type='BASE TABLE' and table_name not like 'pg_%' and table_name not like 'sql_%'"); | |
do pg_dump -t $table database_name > /path/to/export/your/tables/$table.sql; | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment