Reputation: 101
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...
Upvotes: 2
Views: 161
Reputation: 10338
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".
Upvotes: 1
Reputation: 8202
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`
Upvotes: 1