2

I am running java web application on heroku. Now i am trying to get the sql dump file from the application.

ProcessBuilder builder = new ProcessBuilder("cmd.exe", "/c", "pg_dump  -U postgres -Fc --schema=" + schema + " " + dbName + " >" + path);

The above code works perfectly on local machine having windows.

The question is, how can i get dump file from heroku hosted app using process builder or any other method from the java app?

thanks in advance...

2 Answers 2

1

You're creating a process that appears to be using Windows commands. The probability of your Heroku instance being Windows is, I believe, zero.

If you're trying to get a dump of the database, you should check the documentation.

$ heroku pg:backups capture
$ curl -o latest.dump `heroku pg:backups public-url`
Sign up to request clarification or add additional context in comments.

3 Comments

You could try installing Linux and get your ProcessBuilder to work on that.
Steve, i want to do this on heroku hosted app. Is there any code that i can do from java?
If you run the command on the dyno, you won't be able to access the dump file.
1

You need to use the Linux command:

ProcessBuilder builder = new ProcessBuilder("/usr/bin/pg_dump", "-U postgres -Fc --schema=" + schema + " " + dbName + " >" + path);

However, this only works because the pg tools are installed on the dyno for you. But in this way, you won't be able to access the file you dump. So you would also need to execute some code to upload it to S3 or something.

Also make sure you use the right username and password. It most likely is not "postgres".

1 Comment

Thanks codefinger, can you send me the code to execute to upload on S3?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.