0

So I'm trying to add my local database info to heroku database.

Firstly I tried to get public url:

    justas@justas-Lenovo-M490s ~/dev/myrubyblog $ heroku pg:backups public-url
The following URL will expire at 2016-10-06 10:04:52 +0000:
  "https://xfrtu.s3.amazonaws.com/c9d6480e-da41-4783-b54e-027ff267d19e/2016-10-05T20%3A06%3A08Z/67d4ad22-8cc7-4b86-aee9-7c2e648bb5aa?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJCSJJKP7D4MYHIDQ%2F20161006%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20161006T090452Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=d5807003573a49d241caf0e6805e4b770e6b25c861a7ccca0772f282167a4bed"

and I can freely download it using browser. But if I try to import it:

justas@justas-Lenovo-M490s ~/dev/myrubyblog $ heroku pg:backups restore DATABASE "URL described above"
 !    Unknown database: URL described above. Valid options are: DATABASE_URL

I also tried using DATABASE_URL but I get same results.

Then secondly I tried to import like this:

justas@justas-Lenovo-M490s ~/dev/myrubyblog $ heroku pg:backups capture
Use Ctrl-C at any time to stop monitoring progress; the backup
will continue running. Use heroku pg:backups info to check progress.
Stop a running backup with heroku pg:backups cancel.

DATABASE ---backup---> b002

Backup completed

and if I list all backups, I can clearly see that it was created:

justas@justas-Lenovo-M490s ~/dev/myrubyblog $ heroku pg:backups
=== Backups
ID    Backup Time                Status                               Size    Database
----  -------------------------  -----------------------------------  ------  --------
b002  2016-10-06 09:09:15 +0000  Completed 2016-10-06 09:09:17 +0000  7.45kB  DATABASE
b001  2016-10-05 20:06:08 +0000  Completed 2016-10-05 20:06:09 +0000  7.45kB  DATABASE

=== Restores
No restores found. Use `heroku pg:backups restore` to restore a backup

=== Copies
No copies found. Use `heroku pg:copy` to copy a database to another

but it wont let me restore/import it:

justas@justas-Lenovo-M490s ~/dev/myrubyblog $ heroku pg:backups restore DATABASE b002
 !    Unknown database: b002. Valid options are: DATABASE_URL

same results with using DATABASE_URL instead of DATABASE. I realy need your help. Hope I gave you enough information.

Justas
  • 163
  • 1
  • 7

1 Answers1

0

To import .sql file in heroku

heroku pg:psql --app YOUR_APP_NAME_HERE < updates.sql

To import from another heroku app database.

heroku pg:backups restore `heroku pg:backups public-url -a YOUR_PRODUCTION_APP_NAME` YOUR_STAGING_DATABASE_NAME --app YOUR_STAGING_APP_NAME --confirm YOUR_STAGING_APP_NAME

Similar question: How can I import a .sql file into my Heroku postgres database?

Community
  • 1
  • 1
Jayaprakash
  • 1,407
  • 1
  • 9
  • 19