Error 403 when trying to backup AWS S3 database in heroku postgres

I am trying to deploy a Django app on Heroku. I have created a Heroku Postgres database and I want to import an existing PostgreSQL database from AWS S3 into it. I followed a tutorial in the Heroku docs to the letter. I created a Heroku Postgres database and pushed it to the primary db. I followed the Heroku AWS S3 tutorial to set all the configs so the hero can access my S3 bucket. But when I run heroku pg:backups restore 'https://s3.amazonaws.com/<bucket name>/<database name>' DATABASE_URL

, the error message "An error occurred and your backup has not finished" appears.

Here's the complete output heroku pg:backups info

:

=== Backup info: r012
Database:    BACKUP
Started:     2015-07-13 13:43:30 +0000
Finished:    2015-07-13 13:43:30 +0000
Status:      Failed
Type:        Manual
Backup Size: 0.00B
=== Backup Logs
2015-07-13 13:43:30 +0000: 2015/07/13 13:43:30 aborting: could not write to output stream: Expected HTTP Status 200, received: "403 Forbidden"
2015-07-13 13:43:30 +0000: pg_restore: [custom archiver] could not read from input file: end of file
2015-07-13 13:43:30 +0000: waiting for restore to complete
2015-07-13 13:43:30 +0000: restore done
2015-07-13 13:43:30 +0000: waiting for download to complete
2015-07-13 13:43:30 +0000: download done

      

Naturally, since this is a 403 error, I assumed there was something wrong with my authentication. I ran heroku config

and ran a triple check on all my config variables. The surrounding variables AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and DATABASE_URL are correct and match what I see on AWS and Heroku Postgres GUI.

Why am I seeing this error message?

+3


source to share


3 answers


Well, I feel silly, but the reason is because I forgot to add ".dump" to the end of the filename in my AWS URL.



+3


source


The same happens with AWS on Heroku

Heroku will sometimes refuse to import the backup / dump file if the permissions are not set properly in the dump file inside the AWS bucket. (If Heroku cannot access the file, it cannot download it.)



The permission settings can be found either in the Actions> Properties button or by clicking on the file and then clicking the Properties button on the right.

One easy fix is ​​to temporarily make the dump file public, restore your hero, and then block or delete the dump file.

+3


source


For Windows users
heroku pg:backups:restore "https://s3.amazonaws.com/me/items/3H0q/mydb.dump" DATABASE_URL

According to the official docs, if you are using windows make sure to use double quotes around the remote url. see official docs

-1


source







All Articles