Skip to content

Instantly share code, notes, and snippets.

@ademuk
Created December 1, 2014 22:38
Show Gist options
  • Save ademuk/743101b85c4f982b34ec to your computer and use it in GitHub Desktop.
Save ademuk/743101b85c4f982b34ec to your computer and use it in GitHub Desktop.
Dokku pgbackup
if [ "$#" -ne 4 ]; then
echo "Illegal number of parameters"
exit
fi
DB=$1
DESTINATION=$2
NAME=$3
DATE=$(date +"%Y-%m-%d")
RETENTION=$4
ssh dokku@appyharry.com postgresql:dump $DB | gzip -9 > $DESTINATION$NAME$DATE.gz
ls $DESTINATION$NAME*.gz | sort -r | awk "NR>$RETENTION" | xargs rm -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment