Created
May 24, 2017 08:26
-
-
Save tamirko/fdcd0785d8230a5c239cc5b1106b0bfd to your computer and use it in GitHub Desktop.
Create a Postgres Dump
This file contains 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 | |
clear | |
dbName="partner" | |
# all tables | |
tableNames=(alembic_version customers dynamic global_id logins products random_ascii resource_cache resources static_content variables) | |
# only relevant tables | |
tableNames=(customers dynamic products) | |
currDate=$(date +"%Y-%d-%m") | |
output_file="${dbName}_${currDate}.pg" | |
touch ${output_file} | |
echo "Writing dump to ${output_file} ..." | |
for currTableName in "${tableNames[@]}" | |
do | |
echo "Adding the dump of table: ${currTableName} ..." | |
pg_dump --data-only --table=${currTableName} $dbName >> $output_file ... | |
done | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment