Postgres backup

Lists: pgsql-general
From: "pd" <petedawn(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Postgres backup
Date: 2006-10-02 04:20:12
Message-ID: 1159762812.810912.111310@m73g2000cwd.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

guys,

i have a java web app with a postgres backend. now i want to implement
a db database functionality from within my web app. now i have got
this so far,

String[] args = {"\"C:\\Program
Files\\PostgreSQL\\8.1\\bin\\pg_dump\"", " -i", " -h", " localhost", "
-p", " 5432", " -U", " postgres", " -F", " t", " -b", " -v", " -f", "
\"C:\\Test.backup\"", " TESTDB"};

String result = "";
if (args.length > 0) {
result = args[0]; // start with the first element
for (int i=1; i<args.length; i++) {
result = result + args[i];
}
}

Process p = Runtime.getRuntime().exec(result);

Now on executing this i am getting a file called Test.backup, but its
0KB compeletely empty. can somebody tell me what i am doing wrong and
how can i fix it. somebody also told me that this is not the best way
of doing this, and i was wondering is there a better way of
implementhing this.

Thanks.


From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: pd <petedawn(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Postgres backup
Date: 2006-10-02 16:03:08
Message-ID: 20061002160308.GD29699@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Sun, Oct 01, 2006 at 09:20:12PM -0700, pd wrote:
> guys,
>
> i have a java web app with a postgres backend. now i want to implement
> a db database functionality from within my web app. now i have got
> this so far,
>
> String[] args = {"\"C:\\Program
> Files\\PostgreSQL\\8.1\\bin\\pg_dump\"", " -i", " -h", " localhost", "
> -p", " 5432", " -U", " postgres", " -F", " t", " -b", " -v", " -f", "
> \"C:\\Test.backup\"", " TESTDB"};

Do you really have space in those strings? Because that's not going to
work.

Secondly, work out where your STDERR is going, because any error
messages from pg_dump will have gone there...

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.


From: "Damian C" <jamianb(at)gmail(dot)com>
To: "Martijn van Oosterhout" <kleptog(at)svana(dot)org>, pd <petedawn(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Postgres backup
Date: 2006-10-02 20:08:35
Message-ID: 2bbc8f530610021308t53944ec0v81e95689a637c63d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 10/3/06, Martijn van Oosterhout <kleptog(at)svana(dot)org> wrote:
> On Sun, Oct 01, 2006 at 09:20:12PM -0700, pd wrote:
> > guys,
> >
> > i have a java web app with a postgres backend. now i want to implement
> > a db database functionality from within my web app. now i have got
> > this so far,
> >
> > String[] args = {"\"C:\\Program
> > Files\\PostgreSQL\\8.1\\bin\\pg_dump\"", " -i", " -h", " localhost", "
> > -p", " 5432", " -U", " postgres", " -F", " t", " -b", " -v", " -f", "
> > \"C:\\Test.backup\"", " TESTDB"};
>

> Secondly, work out where your STDERR is going, because any error
> messages from pg_dump will have gone there...

For some useful info on draining STDERR (and seeing error codes etc)
from with java see
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
-Damian