Skip to content

Instantly share code, notes, and snippets.

@Hirurg103
Last active September 21, 2017 10:11
Show Gist options
  • Save Hirurg103/4195ffcacb215d2d93e6caef7b772fdb to your computer and use it in GitHub Desktop.
Save Hirurg103/4195ffcacb215d2d93e6caef7b772fdb to your computer and use it in GitHub Desktop.
function dump() {
time=$(date '+%H_%M_%S');
date=$(date '+%Y_%m_%d');
database=$1;
dumps_dir="$HOME/dumps";
mkdir -p "$dumps_dir/$date";
dumpfile=$dumps_dir/$date/$time"_"$database"_dump".psql.gz
pg_dump $database -W -U ontheway --no-privileges --clean --exclude-table=schema_migrations | gzip > $dumpfile;
echo $dumpfile;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment