Backup and restore through JDBC

Started by Marlon Petryover 19 years ago15 messages
#1Marlon Petry
marlonpetry@gmail.com

Hello List
I am trying to develop, a API to carry through backup and restore through
JDBC.
I think that the best form is to use JNI.
Some Suggestion?

#2Albe Laurenz
all@adv.magwien.gv.at
In reply to: Marlon Petry (#1)
Re: Backup and restore through JDBC

Marlon Petry wrote:

I am trying to develop, a API to carry through backup and
restore through JDBC.
I think that the best form is to use JNI.
Some Suggestion?

Do you mean 'backup' or 'export/dump'?
If you mean 'export', do you need anything besides SQL?
If you mean 'backup', how do you want to restore from
a client machine when there is no server running?
And if you're on the server, why would you want to use Java?

Yours,
Laurenz Albe

#3Marlon Petry
marlonpetry@gmail.com
In reply to: Albe Laurenz (#2)
Re: Backup and restore through JDBC

The idea is to make one pg_dump of the server and to keep in the machine of
client.
And to restore this pg_dump when it will be necessary through the machine of
the client.
Perhaps I will have that to use some store procedure in the server, I do not
know

regards
Marlon

2006/9/29, Albe Laurenz < all@adv.magwien.gv.at>:

Marlon Petry wrote:

I am trying to develop, a API to carry through backup and
restore through JDBC.
I think that the best form is to use JNI.
Some Suggestion?

Do you mean 'backup' or 'export/dump'?
If you mean 'export', do you need anything besides SQL?
If you mean 'backup', how do you want to restore from
a client machine when there is no server running?
And if you're on the server, why would you want to use Java?

Yours,
Laurenz Albe

--
Marlon

"A busca infinita à felicidade nos priva de vivê-la a cada dia..." (Elba
Lucas)

#4Andrew Dunstan
andrew@dunslane.net
In reply to: Marlon Petry (#3)
Re: Backup and restore through JDBC

Marlon Petry wrote:

The idea is to make one pg_dump of the server and to keep in the
machine of client.
And to restore this pg_dump when it will be necessary through the
machine of the client.
Perhaps I will have that to use some store procedure in the server, I
do not know

pg_dump and pg_restore do not need to run on the server machine. Why not
just run them where you want the dump stored?

cheers

andrew

#5Marlon Petry
marlonpetry@gmail.com
In reply to: Andrew Dunstan (#4)
Re: Backup and restore through JDBC

The idea is to make one pg_dump of the server and to keep in the
machine of client.
And to restore this pg_dump when it will be necessary through the
machine of the client.
Perhaps I will have that to use some store procedure in the server, I
do not know

pg_dump and pg_restore do not need to run on the server machine. Why not
just run them where you want the dump stored?

cheers

andrew

But I would need to have installed pg_dump and pg_restore in machine client?
Without having installed pg_dump and pg_restore,how I could make

regards,Marlon

#6Andrew Dunstan
andrew@dunslane.net
In reply to: Marlon Petry (#5)
Re: Backup and restore through JDBC

Marlon Petry wrote:

pg_dump and pg_restore do not need to run on the server machine.
Why not
just run them where you want the dump stored?

But I would need to have installed pg_dump and pg_restore in machine
client?
Without having installed pg_dump and pg_restore,how I could make

You can't. pg_dump in particular embodies an enormous amount of
knowledge that simply does not exist elsewhere. There is no dump/restore
API, and there is nothing you can hook up to using JNI, AFAIK.

cheers

andrew

#7Andreas Pflug
pgadmin@pse-consulting.de
In reply to: Andrew Dunstan (#6)
Re: Backup and restore through JDBC

Andrew Dunstan wrote:

Marlon Petry wrote:

pg_dump and pg_restore do not need to run on the server machine.
Why not
just run them where you want the dump stored?

But I would need to have installed pg_dump and pg_restore in machine
client?
Without having installed pg_dump and pg_restore,how I could make

You can't. pg_dump in particular embodies an enormous amount of
knowledge that simply does not exist elsewhere. There is no
dump/restore API, and there is nothing you can hook up to using JNI,
AFAIK.

Recently, there was the proposal to extract that knowledge to a library
(making pg_dump itself just a wrapper). This sounds valuable more and
more, is anybody working on this for 8.3?

Regards,
Andreas

#8Markus Schaber
schabi@logix-tt.com
In reply to: Marlon Petry (#5)
Re: Backup and restore through JDBC

Hi, Marlon,

Marlon Petry wrote:

But I would need to have installed pg_dump and pg_restore in machine
client?
Without having installed pg_dump and pg_restore,how I could make

pg_dump and pg_restore should be runnable (possible with a small shell /
bash wrapper script) without any "installation", simply having them and
all neded libs lying in the current directory. They don't need any
registry keys, weird environment settings or such, just some libs which
should be present on most platforms, except libpq.

Using a java application for dump/restore will burden you with
installing a JVM, the PostgreSQL JDBC drivers, and your application,
which seems at least equal effort and more ressources.

Btw, another idea is to run pg_dump on the server, but pipe its output
to the client, e. G. via running it through telnet or SSH (yes there are
SSH servers for windows), and then piping it to a file on the client (e.
G. using plink.exe from the putty package). Or use netcat or so.

On a unix box, when you're really crazy, and want to ignore all security
restrictions, you could even install pg_dump via inetd, and then
everyone connecting via TCP on the appropriate port gets a dump of the
database. :-)

HTH,
Markus
--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS

Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org

#9Marlon Petry
marlonpetry@gmail.com
In reply to: Andreas Pflug (#7)
Re: Backup and restore through JDBC

Marlon Petry wrote:

pg_dump and pg_restore do not need to run on the server machine.
Why not
just run them where you want the dump stored?

But I would need to have installed pg_dump and pg_restore in machine
client?
Without having installed pg_dump and pg_restore,how I could make

You can't. pg_dump in particular embodies an enormous amount of
knowledge that simply does not exist elsewhere. There is no
dump/restore API, and there is nothing you can hook up to using JNI,
AFAIK.

Recently, there was the proposal to extract that knowledge to a library
(making pg_dump itself just a wrapper). This sounds valuable more and
more, is anybody working on this for 8.3?

Regards,
Andreas

I have interest in working,how i could start ?

regards,marlon

#10Andrew Dunstan
andrew@dunslane.net
In reply to: Marlon Petry (#9)
Re: Backup and restore through JDBC

Marlon Petry wrote:>

You can't. pg_dump in particular embodies an enormous amount of
knowledge that simply does not exist elsewhere. There is no
dump/restore API, and there is nothing you can hook up to using JNI,
AFAIK.

Recently, there was the proposal to extract that knowledge to a
library
(making pg_dump itself just a wrapper). This sounds valuable more and
more, is anybody working on this for 8.3?

I have interest in working,how i could start ?

Start by reading the code in src/bin/pg_dump

Then after you recover from your head exploding you start devising some
sort of sane API ...

cheers

andrew

#11Marlon Petry
marlonpetry@gmail.com
In reply to: Andrew Dunstan (#10)
Re: Backup and restore through JDBC

Marlon Petry wrote:>

You can't. pg_dump in particular embodies an enormous amount of
knowledge that simply does not exist elsewhere. There is no
dump/restore API, and there is nothing you can hook up to using

JNI,

AFAIK.

Recently, there was the proposal to extract that knowledge to a
library
(making pg_dump itself just a wrapper). This sounds valuable more

and

more, is anybody working on this for 8.3?

I have interest in working,how i could start ?

Start by reading the code in src/bin/pg_dump

Then after you recover from your head exploding you start devising some
sort of sane API ...

cheers

andrew

ok. i'm trying start.

#12Tom Dunstan
pgsql@tomd.cc
In reply to: Markus Schaber (#8)
Re: Backup and restore through JDBC

Markus Schaber wrote:

Marlon Petry wrote:

But I would need to have installed pg_dump and pg_restore in machine
client?
Without having installed pg_dump and pg_restore,how I could make

pg_dump and pg_restore should be runnable (possible with a small shell /
bash wrapper script) without any "installation", simply having them and
all neded libs lying in the current directory.

There's probably a case for having static builds of pg_dump and
pg_restore around for various architectures, if only to help people out
when they don't have access to a build environment etc. Either a set of
static binaries on the website, or an easy way to build them from the
source tree (they could then be copied to the target system).

It strikes me that Marlon hasn't really explained why he wants to use
JDBC. I assume that your application is Java based, but trust me,
invoking pg_dump through Runtime.exec() or whatever is going to be much,
much easier than any of the other things you've suggested, such as
making a pg_dump API and using JNI to call it. That's just pain city, in
a bunch of ways.

Do you need to process the dump inside your program in some way? Or do
you just need to store a dump and restore it later? Why the fascination
with using an API?

On a unix box, when you're really crazy, and want to ignore all security
restrictions, you could even install pg_dump via inetd, and then
everyone connecting via TCP on the appropriate port gets a dump of the
database. :-)

Oh, man, my head just exploded reading that. That's taking evil and
being *creative* with it. :)

Cheers

Tom

#13Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andrew Dunstan (#10)
Re: Backup and restore through JDBC

Andrew Dunstan <andrew@dunslane.net> writes:

Then after you recover from your head exploding you start devising some
sort of sane API ...

That's the hard part. There is no percentage in having a library if
it doesn't do anything significantly different from what you could
accomplish via
system("pg_dump ...switches....");

What is it you hope to accomplish by having a library, exactly?
(And don't say "more control over the dump process". pg_dump is already
on the hairy edge of maintainability; we do *not* need to try to deal
with making it still function correctly after an application programmer
makes some random intervention in the process.)

regards, tom lane

#14Andreas Pflug
pgadmin@pse-consulting.de
In reply to: Tom Lane (#13)
Re: Backup and restore through JDBC

Tom Lane wrote:

Andrew Dunstan <andrew@dunslane.net> writes:

Then after you recover from your head exploding you start devising some
sort of sane API ...

That's the hard part. There is no percentage in having a library if
it doesn't do anything significantly different from what you could
accomplish via
system("pg_dump ...switches....");

What is it you hope to accomplish by having a library, exactly?
(And don't say "more control over the dump process".

Some more progress feedback would be really nice.

pg_dump is already
on the hairy edge of maintainability; we do *not* need to try to deal
with making it still function correctly after an application programmer
makes some random intervention in the process.)

Agreed. The only sane approach seems to have a single dump function call
(that takes a set of parameters as prepared by command line scanning)
and a set of callbacks that enable api users to do sensible stuff at
different stages of the backup process.

Regards,
Andreas

#15Markus Schaber
schabi@logix-tt.com
In reply to: Tom Dunstan (#12)
Re: Backup and restore through JDBC

Hi, Tom,

Tom Dunstan wrote:

On a unix box, when you're really crazy, and want to ignore all security
restrictions, you could even install pg_dump via inetd, and then
everyone connecting via TCP on the appropriate port gets a dump of the
database. :-)

Oh, man, my head just exploded reading that. That's taking evil and
being *creative* with it. :)

Well, combine that with some firewall / hosts.allow rules, and sslwrap
with certificate based 2-way authentication, if you "insist" on
security. :-)

Keep on lauging,
Markus
--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS

Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org