Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 265
rebagliatte Avatar asked Jan 10 '12 21:01

rebagliatte


2 Answers

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
like image 129
Neil Middleton Avatar answered Oct 02 '22 17:10

Neil Middleton


Not sure if Heroku's changed since these were posted last January, but when I run

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

I kept getting an error that just said

"! Backup not found"

Even though, when I ran the command by itself to get the URL:

heroku pgbackups:url --app myapp

and then tried the URL out in the browser, that URL WAS correct.

So instead I just tried sending the copied/pasted URL to the command instead, like:

heroku pgbackups:restore DATABASE "http://urlgoeshere" --app myapp-staging

I had to use DOUBLE quotes around the URL, not SINGLE quotes. Otherwise I got this error:

The filename, directory name, or volume label syntax is incorrect. 'Expires' is not recognized as an internal or external command, operable program or batch file. 'Signature' is not recognized as an internal or external command, operable program or batch file.

like image 37
Gayle Avatar answered Oct 02 '22 17:10

Gayle