How do I fix a pgbackups error: backup url is invalid?

1.5k Views Asked by At

I'm trying to follow the instructions on migrating to Cedar (except I did a major rewrite so this isn't a branch of the previous app but a separate one) and stuck at the db migration step. I installed the pgbackup and heroku postgresql addons but get this result:

j3(master) : heroku pgbackups:restore DATABASE heroku pgbackups:url --app dada-foe-110 --app something-something-4311 32mQkEpWyJdfplOnXhlCnCRsoxYE12-05-25 --app something-something-4311 EXTERNAL_BACKUP <---restore--- b002.dump

! WARNING: Destructive Action ! This command will affect the app: something-something-4311 ! To proceed, type "something-something-4311" or re-run this command with --confirm something-something-4311

[entered app name]

Retrieving... done

! An error occurred and your restore did not finish. ! The backup url is invalid. Use pgbackups:url to generate a new temporary URL.

5

There are 5 best solutions below

0
On BEST ANSWER

Turns out I needed to update the Heroku gem. Poor error messaging from them, though, that I had to go to a support ticket to understand this since I was only out of date one or two minor versions and you wouldn't expect breaking changes at that level. Oh well.

3
On

There is a bug with the Heroku gem version 2.26.(0 through 2). We have released a fix. Upgrade to version 2.26.3 or higher

Make sure the output of heroku pgbackups:url --app dada-foe-110 is something like https://s3.amazonaws.com/hkpgbackups/[email protected]/a273.dump?AWSAccessKeyId=AKIAJYEDAEBRU6KYW6QA&Expires=1337985248&Signature=secretsblah

0
On

Download the dump from the S3 URL which is provided and put it somewhere else which is freely accessible (I have an S3 account so I just stuck it up there - if your DB is extra large and you want to transfer directly between S3's if you have one the instructions here https://s3.amazonaws.com/thearthedge_backup/db_backup/b011.dump seem like they do the trick) and then use this new URL in your

heroku pgbackups:restore 'ADD_YOUR_NEW_BACKUP_URL_HERE_WITH_SINGLE_QUOTES' --app your-app-to-restore-to

I had been having the same problem for the past couple of days though relocating the backup away from Heroku has seemed to do the trick

0
On

Other reasons for the backup URL to be 'invalid' may be permissions or an error typing or copying the URL. For example, I tried the instructions from heroku to backup and restore a DB from one spot to another, and neglected to make the S3 file readable by Heroku, so the restore failed with this same error.

0
On

I had a similar problem trying to restore from S3 server. I simply added open/download permission for everyone on that file on S3, otherwise you need to include AWSAccessKeyId as described in Will's answer above.