Question

I need to use the pg_dump command to dump my development db to a file and then upload this to my heroku hosted rails app.

I am unable to use the rails command

  "heroku db:push"

I have been asked by Heroku support to use the pg_dump tool to send transfer databases between cleint and server.

I just ran this command:

  pg_dump -U XXXXX -w app0521_development

It output the entire contents of my database to the console

But this command for some reason fails:

  pg_dump -U postgres -w app0521_development > test.dump

with this error message -bash: test.dump: Permission denied

Was it helpful?

Solution

I think you will either need to make a special folder and give the postgres user/group access read+write to it, or you should be able to send it to /tmp/test.dump;

pg_dump -U postgres -w app0521_development > /tmp/test.dump

Most of the time (at least on Ubuntu), the /tmp folder has "read+write+execute" for everyone. Just a warning... if it's got sensative data, it's out there for everyone that can get on that box. So, clean it up! And also of note, the /tmp folder has the "t" flag set. The "t" indicates that only the user (and root) that created a file in this directory can delete that file.

If you want to create your own folder, just google "chgrp" - and then of course you need to give "read-write" to the group.

OTHER TIPS

with this error message -bash: test.dump: Permission denied

Try putting a > before the test.dump and see what happens. I assume that is the backup file you want to have? That sounds like filesystem permissions issues.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top