Search code examples
ruby-on-railsrubydatabaseherokupg

How to transfer the data from my production DB to my staging DB in heroku?


I'm trying to transfer the data from my production DB to my staging DB without success.

I'm following heroku's documentation on it: http://devcenter.heroku.com/articles/pgbackups#transfers

These are the commands I've run...

$ heroku addons:add pgbackups --remote staging
$ heroku addons:add pgbackups --remote production
$ heroku pgbackups:capture --remote production
$ heroku pgbackups:restore DATABASE `heroku pgbackups:url --remote production` --remote staging

And this is the message I get...

Usage: heroku pgbackups:restore [<DATABASE> [BACKUP_ID|BACKUP_URL]]

restore a backup to a database

if no DATABASE is specified, defaults to DATABASE_URL and latest backup
if DATABASE is specified, but no BACKUP_ID, defaults to latest backup

It seems I'm spelling something wrong, but I can't figure it out.

I've also tried the same command using the name of the apps instead of the remote...

$ heroku pgbackups:restore DATABASE `heroku pgbackups:url --app myapp` --app myapp-staging

But I get the same message with no actual transfer going on.

Any help is deeply appreciated.


Solution

  • I don't think you've captured correctly. Always use --app instead of --remote

    $ heroku pgbackups:capture --app myapp
    $ heroku pgbackups:restore DATABASE `heroku pgbackups:url --app myapp` --app myapp-staging