Skip to content

Instantly share code, notes, and snippets.

@tamirko
Created May 24, 2017 08:26
Show Gist options
  • Save tamirko/fdcd0785d8230a5c239cc5b1106b0bfd to your computer and use it in GitHub Desktop.
Save tamirko/fdcd0785d8230a5c239cc5b1106b0bfd to your computer and use it in GitHub Desktop.
Create a Postgres Dump
#!/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