0

I have been trying to get the data that I have on my database from the online servers (heroku) and copy it into a local database. I am new to both psql, heroku and basically to the whole concept of building web apps, so forgive me if I sound ignorant.

After reading this post saying that on windows I had to pg_dump and pg_restore separetely I went ahead and found the URL for my database and ran the pg_dump command successfully.

C:\>pg_dump postgres://ddzhoyyleezptg:X7AapV7z9LIYMDYXcEAVoNpA_e@ec2-54-83-17-8.compute-1.amazonaws.com:5432/***
(INFO OMITTED)
--
-- PostgreSQL database dump complete
--

and now I do not know how to move on. To clarify, my goal is to have a copy of the database that I have online so that I am able to work with the data locally without affecting the data on the server.

Any help is appreciated, Thank you in advance.

Community
  • 1
  • 1
al3x901
  • 15
  • 2
  • have you tried using the `pg_restore` command? https://devcenter.heroku.com/articles/heroku-postgres-import-export – trueinViso Jun 15 '15 at 23:57
  • @trueinViso I looked at the documentation and it was asking for the name of the dump file, I don't know where pg_dump creates the file in my system. how do i go about finding that out? – al3x901 Jun 16 '15 at 03:06
  • It should dump it in the directory where you run the command, you run the two commands that people are copy and pasting below then run `pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump` replacing myuser and mydb with your username and db name. – trueinViso Jun 16 '15 at 15:49

2 Answers2

0

You can use this commands

 $ heroku pg:backups capture
 $ curl -o latest.dump `heroku pg:backups public-url`

Ref Heroku backup pg database

Sagar.Patil
  • 991
  • 8
  • 17
0

To export the data from your Heroku Postgres database, create a new backup and use any number of download tools, such as curl or wget, to store the backup locally.

 heroku pg:backups capture

 curl -o latest.dump `heroku pg:backups public-url`

Hope this will help you.

Akshay Borade
  • 2,442
  • 12
  • 26
  • @al3x901: For more details please refer `Importing and Exporting Heroku Postgres Databases with PG Backups` https://devcenter.heroku.com/articles/heroku-postgres-import-export – Akshay Borade Jun 16 '15 at 05:42