Skip to content

Instantly share code, notes, and snippets.

@sungmin-park
Last active December 8, 2016 05:44
Show Gist options
  • Save sungmin-park/83ba6fe53c7621cad1bdf34459d98b46 to your computer and use it in GitHub Desktop.
Save sungmin-park/83ba6fe53c7621cad1bdf34459d98b46 to your computer and use it in GitHub Desktop.
#!/bin/sh
if [ -z "$1" ]
then
echo "usage> $0 DATABASE" >&2
exit 1
fi
# Cannot use pipe. Pipe produces an empty backup file when pg_dump has errors.
FILE_NAME="$1-`date +"%Y%m%d-%H%M%S"`.sql"
pg_dump --no-owner --no-acl --file="$FILE_NAME" $1 && gzip "$FILE_NAME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment