Skip to content

Instantly share code, notes, and snippets.

@viktorbenei
Created March 5, 2019 13:14
Show Gist options
  • Save viktorbenei/2e569abd10a409df121cba62a53f51ca to your computer and use it in GitHub Desktop.
Save viktorbenei/2e569abd10a409df121cba62a53f51ca to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -ex
if [ -z "$HEROKU_APP_ID" ] ; then
echo '!!! HEROKU_APP_ID not set'
exit 1
fi
if [ -z "$HEROKU_DB_ADDON_ID" ] ; then
echo "!!! HEROKU_DB_ADDON_ID not set. You can get the Heroku DB addon ID from: $ heroku pg:info -a $HEROKU_APP_ID | grep -i 'add-on'"
exit 1
fi
heroku maintenance:on -a $HEROKU_APP_ID
sleep 10
heroku pg:maintenance:run "$HEROKU_DB_ADDON_ID" -a $HEROKU_APP_ID
sleep 10
# wait for the maintenance to complete
heroku pg:wait -a $HEROKU_APP_ID
sleep 10
heroku maintenance:off -a $HEROKU_APP_ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment