Skip to content

Instantly share code, notes, and snippets.

@croaky
Created May 24, 2012 01:59
Show Gist options
  • Save croaky/2779013 to your computer and use it in GitHub Desktop.
Save croaky/2779013 to your computer and use it in GitHub Desktop.
#!/bin/sh
load-production() {
backup-production
get-backup | restore-from-backup
}
backup-production() {
heroku pgbackups:capture --expire `heroku-production`
}
get-backup() {
curl -o `production-backup-url`
}
restore-from-backup() {
pg_restore --verbose --clean --no-acl --no-owner -d `local-database-name`
}
production-backup-url() {
printf "heroku pgbackups:url `heroku-production`"
}
local-database-name() {
printf "`current-directory`_development"
}
heroku-production() {
printf "--app `current-directory`-production"
}
current-directory() {
pwd | awk -F'/' '{print $NF}'
}
@sikachu
Copy link

sikachu commented May 24, 2012

Dan, on line 13 you don't need -o. Otherwise everything looks fine (except there're too many functions that're so risky to be overridden.)

@croaky
Copy link
Author

croaky commented May 24, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment