users@glassfish.java.net

Re: How to back up and restore the GF derby databases

From: Jagadish Prasath Ramu <Jagadish.Ramu_at_Sun.COM>
Date: Mon, 26 May 2008 15:55:55 +0530

Hi Paul,


On Mon, 2008-05-26 at 11:59 +0200, Paul MERLIN wrote:
> Hi Jagadish,
>
> Thanks for answering.
>
> Le Monday 26 May 2008 10:28:14 Jagadish Prasath Ramu, vous avez écrit :
> > Can you try setting the property "restoreFrom" via datasource property
> > "connectionAttributes"
> >
> > eg:
> > connectionAttributes=";create=true" // can be found in appserver's
> > DerbyPool
> > properties
> >
> > similarly try setting:
> > connectionAttributes=";create=true;restoreFrom=path"
> >
> > [I havent tried it, and you may have to remove the property once the
> > backup is complete.]
> Ok, so if I want to automate this, I would have to fetch the current
> connectionAttributes property of my connection pool, append the restoreFrom
> directive, then "do something", then restore the old value of
> connectionAttributes.
>
> Now my question is what is this "do something" ? Is a simple
> ping-connection-pool enough ? I don't think so, as there may be already
> openned connections in the pool so new connectionAttributes won't be used.
> Plus I would like to restore the database without starting glassfish so my
> deployed apps are not available.
>
> I feel all this a little dirty, there's no documented way of doing
> backup/restore easily for the GF database ?
>
> Maybe the best way to go would be to do all this without glassfish nor asadmin
> and write scripts that start a derby process only for doing the restore. What
> do you think ?

Yes, you can start the database server alone using "start-database"
command. This does not boot the database until a connection is requested
for that particular database.

Then, from a java client, you can connect to the database (and hence
boot) via a URL (you can use org.apache.derby.jdbc.ClientDriver )
appended with "restoreForm" property as suggested in
http://db.apache.org/derby/docs/10.2/adminguide/tadminhubbkup44.html


Thanks,
-Jagadish