7

I have a shared heroku app, now I wan't to create a test app also in heroku with the same code, so I've created a new app, ok, the thing is that for the app to work it needs a database, so I'm trying to upload my local DB but don't know how to.

Can anyone tell me what do I have to type in my command line so I can get my local DB uploaded?

Thanks

Ps: The app uses Django

Yuval Adam
  • 161,610
  • 92
  • 305
  • 395
Sascuash
  • 3,661
  • 10
  • 46
  • 65

2 Answers2

6

You should restore database from a url, see heroku import doc:

heroku pgbackups:restore DATABASE 'http://f.cl.l...3z18/mydb.dump'

Edit:

The pgbackups addon has been deprecated. The process is now built in to the CLI tools. More details here. The new method looks like this:

heroku pg:backups restore 'http://f.cl.l...3z18/mydb.dump' DATABASE
Andrew Lavers
  • 8,023
  • 1
  • 33
  • 50
dani herrera
  • 48,760
  • 8
  • 117
  • 177
  • Ok, that seems to be the answer, just one more thing, How do I create or obtain the URL? – Sascuash Jan 24 '13 at 12:13
  • Do you have several ways: as doc say you can use Amazon S3 or CloudApp that is the fast way, also you can share it via drop box or open a port in your home router and let heroku to take file from your home machine. – dani herrera Jan 24 '13 at 13:56
  • this really is a horrible approach when dealing with sensitive data ... – Pinna_be Sep 11 '18 at 11:42
  • @Pinna_be , database url may be an httpS resouce (with S = Secure ) – dani herrera Sep 11 '18 at 16:25
5

@danihp's answer is a good one - it is exactly what the documentation recommends.

BUT it requires posting the file in some awkward place like S3.

However, as the OP asks - how can we do this without having to push the database dump to someplace awkward like S3?

The most convenient answer I've been able to find (mentioned in @danihp's comment) is to use dropbox.

In detail (not described in danihp's comment):

Simply

  • put the dump file into your "Public" dropbox folder
  • right click and choose "Copy Public Link"
  • Paste the url you just copied into the command:

    heroku pgbackups:restore DATABASE_URL "<paste link here>"
    

If you don't want to put the dump file in your "Public" folder, then you need to do one more step.

You need to

  • put is in some other dropbox folder
  • right click, and chose "share Dropbox Link"
  • paste the link into a browser, which will show you the dump file page
  • right click the "download" button and copy the URL.
  • paste that URL into the command.

HTH.

GreenAsJade
  • 14,459
  • 11
  • 63
  • 98