Skip to content

Instantly share code, notes, and snippets.

@plexus
Created May 11, 2012 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plexus/2659586 to your computer and use it in GitHub Desktop.
Save plexus/2659586 to your computer and use it in GitHub Desktop.
PostgreSQL database dump wrapper
#!/bin/bash
# pg_dump wrapper
# - add 'CREATE DATABASE' to dump
# - compress with bzip2
# - timestamp
if [[ "$1" == "" ]]; then
echo " Usage: "
echo " $0 <db_name>"
echo
echo " This will create a timestamped, compressed sql dump of a single database."
echo " To restore use"
echo " bzcat <dump_file> | psql -q"
else
pg_dump -C $1 | bzip2 > $1_`date "+%Y%m%d-%H%M"`.sql.bz2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment