RubyDude1012
RubyDude1012

Reputation: 477

heroku pgbackups - how does it work?

I'm trying to migrate a database over to a new app from an existing one using pgbackups, but I'm running into issues. I've read the documentation on heroku's dev site but I'm still getting errors.

I've got the plugin installed for both databases and I can successfully go to my source db and copy/capture it.

$ heroku pgbackups:capture -a costrecovery --expire

HEROKU_POSTGRESQL_ONYX_URL (DATABASE_URL)  ----backup--->  b007

←[0KCapturing... doneB -
←[0KStoring... done

And then I change to the directory of the app I want to copy the db to and followed the instructions listed by heroku. The problem is that I don't know if it's not working because their is a bug or if it's because I'm not interpreting the instructions properly, which is entirely possible. First I'll list the instructions from heroku's dev site and then the commands I've tried.

HEROKUS INSTRUCTIONS

$ heroku pgbackups:restore DATABASE -a target-app \
    `heroku pgbackups:url -a source-app`

COMMANDS I'VE TRIED

$ heroku pgbackups:restore DATABASE_URL -a boiling-reef-2060 \
> heroku pgbackups:url -a costrecovery
!    Backup not found


$ heroku pgbackups:restore HEROKU_POSTGRESQL_GREEN_URL -a boiling-reef-2060 \
> 'heroku pgbackups:url -a costrecovery'
!    Backup not found


$ heroku pgbackups:restore DATABASE -a boiling-reef-2060 \
> 'heroku pgbackups:url -a costrecovery'
!    Backup not found


$ heroku pgbackups:restore DATABASE_URL -a costrecovery-copy2 \
> heroku pgbackups:"https://s3.amazonaws.com/hkpgbackups/[email protected]/b
007.dump?AWSAccessKe
> yId=AKIAJFDIRYCGYNFXR4FQ&Expires=1365184330&Signature=po0wZ982Jbx%2Fkv0bKk0iv
P%2
> FRWac%3D"
!    Resource not found

Can someone helpl me out with the proper syntax? Thanks

Upvotes: 4

Views: 1879

Answers (1)

hgmnz
hgmnz

Reputation: 13306

pgbackups can restore from a database on your same app, or from any pgbackups URL, as in, the one you captured in your source application/database. The instructions use backticks (`) to shell out and grab the pgbackups URL from your source application. The pgbackups:url command will provide such an URL. Try running this, to understand what's happening:

heroku pgbackups:url -a costrecovery

(assuming costrecovery is where you captured your data).

Knowing this, you should be able to simply run:

heroku pgbackups:restore DATABASE_URL --app boiling-reef-2060 `heroku pgbackups:url --app costrecovery

Upvotes: 5

Related Questions