Skip to content

Instantly share code, notes, and snippets.

@panterch
Created February 8, 2021 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save panterch/911aa92dfda6cf1fd2c1d867378a69c0 to your computer and use it in GitHub Desktop.
Save panterch/911aa92dfda6cf1fd2c1d867378a69c0 to your computer and use it in GitHub Desktop.
Heroku offsite Backup Skript
#!/bin/bash
current_time=$(date "+%Y.%m.%d-%H.%M")
for n in $(heroku apps | grep prod | cut -d ' ' -f 1)
do
echo "backing up: $n"
heroku pg:backups:download --app $n -o /backup/heroku/$n.dump
done
echo "Finished"
# Rotation durch logrotate
@panterch
Copy link
Author

panterch commented Feb 9, 2021

Upload the file to 'heroku-database-restore'
Select the file -> edit permissions -> add public access
Copy the public URL
Login to heroku via cli
Start the restore:
heroku pg:backups:restore 'GCLOUD_BUCKET_URL' DATABASE_URL -a APP_NAME -confirm APP_NAME
GCLOUD_BUCKET_URL -> URL to the file
APP_NAME -> name of the app
Delete the file

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