You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Calvin Smith <ca...@thatone.com> on 2004/11/23 01:47:12 UTC

Unable to restore a Derby database

hi,

I'm having trouble restoring a Derby database. I backed it up to another
directory, and then tried adding a few rows to the original database, 
disconnecting, and then connecting again with the restoreFrom attribute. 
I was able to connect successfully, but the extra records were still in 
the database, and it hadn't been overwritten.

I tried to connect first through ANT (since this is part of my build
process), but just to be sure that ANT wasn't causing the problem, I
connected with a JDBC client (DBVisualizer) and observed the same behavior.

The URL I ordinarily connect to is:

jdbc:derby:net://localhost:1527/asdf;create=true

After doing the backup of the database, I verified that there were a
bunch of files in my backup directory under a directory called
'asdf' (the database name), which seems like a successful backup, but 
when I connect with the following URL:

jdbc:derby:net://localhost:1527/asdf;restoreFrom=/home/cs/Desktop/workspace/asdf/db/derby-backups

nothing is different, and the restoreFrom apparently did nothing. Here
are my config details:

Java VM:  Java HotSpot(TM) Client VM
Java Version:  1.4.2_06-b03
Java Vendor:  Sun Microsystems Inc.
OS Name:  Linux
OS Arch:  i386
OS Version:  2.6.9

Both the Derby and Universal JDBC driver were downloaded about 5 days
ago, so they're probably the latest versions, but here's what JDBC
records as the versions:

Apache Derby
10.0.2.1
IBM DB2 JDBC Universal Driver Architecture
2.4.17

I also tried connecting directly using ij, and observed the same
behavior. I started ij, then executed:

connect
'jdbc:derby:net://localhost:1527/asdf;restoreFrom=/home/cs/Desktop/workspace/asdf/db/derby-backups:user=test;password=test;';

And I observed that the data created after the backup occurred was still 
there.

Any ideas what might be going on? If anybody has been able to
successfully restore, I'd really appreciate seeing a connectUrl or two 
that worked correctly.

Thanks in advance...

-calvin

p.s. Erring on the side of too much info, here is the ANT target which 
shows how I'm starting the server:

<target name="db-start" description="Start derby on localhost:1527">
	<mkdir dir="${derby.basedir}"/>
	<java classname="org.apache.derby.drda.NetworkServerControl" fork="yes" 
dir="${derby.basedir}">
         <arg line="start"/>
	<jvmarg value="-Dderby.system.home=${derby.basedir}"/>
	<jvmarg value="-Xmx256m"/>
         <classpath refid="db.derby.server.classpath"/>
     </java>
</target>

Roughly equivalent to:

cd ${derby.basedir}; java -Dderby.system.home=${derby.basedir} -Xmx256m 
-classpath ${db.derby.server.classpath} 
org.apache.derby.drda.NetworkServerControl start


Re: Unable to restore a Derby database [SOLVED?]

Posted by Calvin Smith <ca...@thatone.com>.
Jean T. Anderson wrote:

>Calvin Smith wrote:
>
>  
>
>>Okay, I'll file an issue.
>>
>>Is there some trick to doing this, or is it not allowable to the
>>public perhaps? When I try to do "create new issue", the pulldown to
>>select the project has only one option, "MyFaces". There is no option
>>for Derby.
>>    
>>
>
>Might the information at this link help?
>
>     http://incubator.apache.org/derby/DerbyBugGuidelines.html
>
>It also links to a doc with verbose tips.
>
> -jean
>  
>

Thanks, Jean. I saw that page but wondered if there was some 
undocumented procedure. It seems that it was a browser issue, since all 
the projects show up on the pulldown now but didn't earlier (same page, 
same pulldown).

I'll create the Jira issue about restore error messages this evening.

-calvin

Re: Unable to restore a Derby database [SOLVED?]

Posted by "Jean T. Anderson" <jt...@bristowhill.com>.
Calvin Smith wrote:

> Okay, I'll file an issue.
>
> Is there some trick to doing this, or is it not allowable to the
> public perhaps? When I try to do "create new issue", the pulldown to
> select the project has only one option, "MyFaces". There is no option
> for Derby.

Might the information at this link help?

     http://incubator.apache.org/derby/DerbyBugGuidelines.html

It also links to a doc with verbose tips.

 -jean


Re: Unable to restore a Derby database [SOLVED?]

Posted by Calvin Smith <ca...@thatone.com>.
Hmmm, I'm able to see all the projects in the Jira pulldown now, so I'm 
not sure what the problem was, but I'll create an issue shortly.

-calvin

Calvin Smith wrote:

> Okay, I'll file an issue.
>
> Is there some trick to doing this, or is it not allowable to the 
> public perhaps? When I try to do "create new issue", the pulldown to 
> select the project has only one option, "MyFaces". There is no option 
> for Derby.
>
> thanks,
>
> Calvin
>


Re: Unable to restore a Derby database [SOLVED?]

Posted by Calvin Smith <ca...@thatone.com>.
Okay, I'll file an issue.

Is there some trick to doing this, or is it not allowable to the public 
perhaps? When I try to do "create new issue", the pulldown to select the 
project has only one option, "MyFaces". There is no option for Derby.

thanks,

Calvin

Mike Matrigali wrote:

> I also think you should file a JIRA entry.  I would have at least
> expected some message in the derby.log.  A discussion would be good
> as I don't know what users want in this case.  Should the connection
> request:
> ~    a) fail with a reasonable message back to user
> ~    b) succeed but with a warning that the restore did not work back to
> user
> ~    c) succeed but with an error in derby.log
> ~    d) fail but with an error in derby.log
> ~    e) succeed with no message
> a or b seems reasonable, c or d may be easiest to implement, e seems
> unreasonable.
>
> The actual code to execute the restore from backup happens in derby at
> "boot" time.  And historically it has been hard to get good error
> messages back to user when boot fails at such a low level, I am not
> sure what happened in this particular case as I did not debug it.
>
>

Re: Unable to restore a Derby database [SOLVED?]

Posted by Mike Matrigali <mi...@sbcglobal.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I also think you should file a JIRA entry.  I would have at least
expected some message in the derby.log.  A discussion would be good
as I don't know what users want in this case.  Should the connection
request:
~    a) fail with a reasonable message back to user
~    b) succeed but with a warning that the restore did not work back to
user
~    c) succeed but with an error in derby.log
~    d) fail but with an error in derby.log
~    e) succeed with no message
a or b seems reasonable, c or d may be easiest to implement, e seems
unreasonable.

The actual code to execute the restore from backup happens in derby at
"boot" time.  And historically it has been hard to get good error
messages back to user when boot fails at such a low level, I am not
sure what happened in this particular case as I did not debug it.



Amit Handa wrote:
| Calvin Smith wrote:
|
|>Oh man, do I feel stupid. I just re-read the manual again and realized
|>that the restore from path is not the directory into which the backup
|>occurred, but the sub-directory that the backup created in that directory.
|>
|>I was doing:
|>
|>connect 'jdbc:derby:myDb;restoreFrom=/mybackupdir';
|>
|>instead of:
|>
|>connect 'jdbc:derby:myDb;restoreFrom=/mybackupdir/myDb';
|>
|>After trying the second form, it works perfectly. Perhaps a better
|>message (indicating success or failure, instead of silence in both
|>cases) would be helpful, but this was a case of PEBCAK
|>(http://www.hyperdictionary.com/computing/pebcak).
|>
|>Thanks again, and I apologize for wasting anybody's time on a silly
|>problem....
|>
|>-calvin
|>
|>p.s. If anybody thinks that the silent response when the backup
|>directory (which contains the backup database directory) exists but the
|>backup database directory doesn't exist is a bug, I'll be happy to file
|>a Jira issue. This is inconsistent with the behavior when the backup
|>database directory does exist but isn't valid, and the user is notified
|>of an error.
|
|
| Calvin,
|
| I think it would be good to file a bug and have a discussion around it,
| since you started the thread.
| We can always close it later, if we[derby-users] feel otherwise.
|
| thanks,
| Amit
|
|
|
|
|
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBpLTsEpeslyHqPs0RAupwAJ42kgH2y+NTyoiFF+RGn/CUr/R5zACeIuql
h1dOehznio9vVNpR2xKoyP0=
=6lch
-----END PGP SIGNATURE-----

Re: Unable to restore a Derby database [SOLVED?]

Posted by Amit Handa <Am...@Sun.COM>.
Calvin Smith wrote:
> Oh man, do I feel stupid. I just re-read the manual again and realized 
> that the restore from path is not the directory into which the backup 
> occurred, but the sub-directory that the backup created in that directory.
> 
> I was doing:
> 
> connect 'jdbc:derby:myDb;restoreFrom=/mybackupdir';
> 
> instead of:
> 
> connect 'jdbc:derby:myDb;restoreFrom=/mybackupdir/myDb';
> 
> After trying the second form, it works perfectly. Perhaps a better 
> message (indicating success or failure, instead of silence in both 
> cases) would be helpful, but this was a case of PEBCAK 
> (http://www.hyperdictionary.com/computing/pebcak).
> 
> Thanks again, and I apologize for wasting anybody's time on a silly 
> problem....
> 
> -calvin
> 
> p.s. If anybody thinks that the silent response when the backup 
> directory (which contains the backup database directory) exists but the 
> backup database directory doesn't exist is a bug, I'll be happy to file 
> a Jira issue. This is inconsistent with the behavior when the backup 
> database directory does exist but isn't valid, and the user is notified 
> of an error.

Calvin,

I think it would be good to file a bug and have a discussion around it,
since you started the thread.
We can always close it later, if we[derby-users] feel otherwise.

thanks,
Amit





Re: Unable to restore a Derby database [SOLVED?]

Posted by Calvin Smith <ca...@thatone.com>.
Oh man, do I feel stupid. I just re-read the manual again and realized 
that the restore from path is not the directory into which the backup 
occurred, but the sub-directory that the backup created in that directory.

I was doing:

connect 'jdbc:derby:myDb;restoreFrom=/mybackupdir';

instead of:

connect 'jdbc:derby:myDb;restoreFrom=/mybackupdir/myDb';

After trying the second form, it works perfectly. Perhaps a better 
message (indicating success or failure, instead of silence in both 
cases) would be helpful, but this was a case of PEBCAK 
(http://www.hyperdictionary.com/computing/pebcak).

Thanks again, and I apologize for wasting anybody's time on a silly 
problem....

-calvin

p.s. If anybody thinks that the silent response when the backup 
directory (which contains the backup database directory) exists but the 
backup database directory doesn't exist is a bug, I'll be happy to file 
a Jira issue. This is inconsistent with the behavior when the backup 
database directory does exist but isn't valid, and the user is notified 
of an error.

Re: Unable to restore a Derby database

Posted by Calvin Smith <ca...@thatone.com>.
Hi Mike,

Thanks for the response. More comments interspersed below...

Mike Matrigali wrote:

>I am not sure what is going on, here are some things I can think of to
>try to learn more.
>
>o can you try using ij directly and not using the network server, just
>  to isolate the issue.
>  
>
Behavior is identical using ij and the embedded server. I've included at 
the bottom a complete transcript of what I tried.

>o how do you back up the database?  Are you using the derby system
>  procedure?
>  
>
I backed up using SYSCS_UTIL.SYSCS_BACKUP_DATABASE. See command recorded 
in session below.

>o is there any chance that there are still connections to the database
>  when the restoreFrom connection is made?
>  
>
I verified this time that there were no other connections both from 
within ij and using 'ps aux |grep -i java' before launching java, and am 
pretty certain there were no other connections this time. I've now tried 
this on 2 machines, and observed the same behavior (both pretty much 
same config though) through the network server and through ij embedded, 
as below.

>o Did you look at error log files, was there anything in there?
>  
>

The error file is whatever the default is, which I believe is 
'derby.log' in the system home dir, and I see nothing in there but 
indications of success. No errors are reported. Interestingly, though, I 
don't see any indication that a restore attempted either, but the backup 
of the database definitely does get created.

>Can anyone comment if this is the correct syntax for passing the
>restoreFrom attribute through the network server?
>  
>
 
Or if the syntax below is correct for the embedded database from ij?

Here is what I tried this time, exactly:

calvins@nihilo derby-test $ pwd
/home/calvins/derby-test
calvins@nihilo derby-test $ java -classpath 
lib/derby.jar:lib/derbytools.jar org.apache.derby.tools.ij
ij version 10.0 (C) Copyright IBM Corp. 1997, 2004.
ij> connect 'jdbc:derby:test';
ERROR XJ004: Database 'test' not found.
ij> connect 'jdbc:derby:test;create=true';
ij> create table asdf (id smallint primary key not null);
0 rows inserted/updated/deleted
ij> insert into asdf values (1);
1 row inserted/updated/deleted
ij> insert into asdf values (2);
1 row inserted/updated/deleted
ij> select * from asdf;
ID
------
1
2

2 rows selected
ij> disconnect;
ij> connect 'jdbc:derby:test';
ij> select * from asdf;
ID
------
1
2

2 rows selected
ij> CALL 
SYSCS_UTIL.SYSCS_BACKUP_DATABASE('/home/calvins/derby-test/derby-backups');
0 rows inserted/updated/deleted
ij> disconnect;
ij> exit;
calvins@nihilo derby-test $ ls -a /home/calvins/derby-test/derby-backups
./  ../  test/
calvins@nihilo derby-test $ java -classpath 
lib/derby.jar:lib/derbytools.jar org.apache.derby.tools.ij
ij version 10.0 (C) Copyright IBM Corp. 1997, 2004.
ij> connect 'jdbc:derby:test';
ij> select * from asdf;
ID
------
1
2

2 rows selected
ij> insert into asdf values (3);
1 row inserted/updated/deleted
ij> select * from asdf;
ID
------
1
2
3

3 rows selected
ij> disconnect;
ij> connect 
'jdbc:derby:test;restoreFrom=/home/calvins/derby-test/derby-backups';
ij> select * from asdf;
ID
------
1
2
3

3 rows selected
ij> disconnect;
ij> connect 
'jdbc:derby:test;restoreFrom=/home/calvins/derby-test/derby-backups';
ij> select * from asdf;
ID
------
1
2
3

3 rows selected
ij> disconnect;
ij> exit;
calvins@nihilo derby-test $

The restoreFrom is apparently doing something, since moving the backup 
directory results in the following if I try to restore:

ij> connect 
'jdbc:derby:test;restoreFrom=/home/calvins/derby-test/derby-backups';
ERROR XJ040: Failed to start database 'test', see the next exception for 
details.
ERROR XBM0Y: Backup database directory 
/home/calvins/derby-test/derby-backups not found. Please make sure that 
the specified backup path is right.
ij>

And if the backup directory is there, but the database backup 
sub-directory is not there, I get the following:

> ij> connect 
> 'jdbc:derby:test;restoreFrom=/home/calvins/derby-test/derby-backups';
> ERROR XJ040: Failed to start database 'test', see the next exception 
> for details.
> ERROR XBM0Q: File 
> /home/calvins/derby-test/derby-backups/service.properties not found. 
> Please make sure that backup copy is the correct one and it is not 
> corrupted.
> ij>
>

Just in case this is helpful, here are the contents of the backed up 
BACKUP.HISTORY and service.properties files in the backup sub-directory:

calvins@nihilo test $ cat BACKUP.HISTORY
Tue Nov 23 20:03:59 PST 2004:Backup started for database located at 
/home/calvins/derby-test/test

calvins@nihilo test $ cat service.properties
#/home/calvins/derby-test/test
# ********************************************************************
# ***                Please do NOT edit this file.                 ***
# *** CHANGING THE CONTENT OF THIS FILE MAY CAUSE DATA CORRUPTION. ***
# ********************************************************************
#Tue Nov 23 20:01:32 PST 2004
SysschemasIndex2Identifier=225
SyscolumnsIdentifier=144
SysconglomeratesIndex1Identifier=49
SysconglomeratesIdentifier=32
SyscolumnsIndex2Identifier=177
SysschemasIndex1Identifier=209
SysconglomeratesIndex3Identifier=81
SystablesIndex2Identifier=129
SyscolumnsIndex1Identifier=161
derby.serviceProtocol=org.apache.derby.database.Database
SysschemasIdentifier=192
derby.storage.propertiesId=16
SysconglomeratesIndex2Identifier=65
derby.serviceLocale=en_US
SystablesIdentifier=96
SystablesIndex1Identifier=113


Any more ideas?

Thanks,

Calvin




Re: Unable to restore a Derby database

Posted by Mike Matrigali <mi...@sbcglobal.net>.
I am not sure what is going on, here are some things I can think of to
try to learn more.

o can you try using ij directly and not using the network server, just
  to isolate the issue.
o how do you back up the database?  Are you using the derby system
  procedure?
o is there any chance that there are still connections to the database
  when the restoreFrom connection is made?
o Did you look at error log files, was there anything in there?

Can anyone comment if this is the correct syntax for passing the
restoreFrom attribute through the network server?

Calvin Smith wrote:

> hi,
> 
> I'm having trouble restoring a Derby database. I backed it up to another
> directory, and then tried adding a few rows to the original database,
> disconnecting, and then connecting again with the restoreFrom attribute.
> I was able to connect successfully, but the extra records were still in
> the database, and it hadn't been overwritten.
> 
> I tried to connect first through ANT (since this is part of my build
> process), but just to be sure that ANT wasn't causing the problem, I
> connected with a JDBC client (DBVisualizer) and observed the same behavior.
> 
> The URL I ordinarily connect to is:
> 
> jdbc:derby:net://localhost:1527/asdf;create=true
> 
> After doing the backup of the database, I verified that there were a
> bunch of files in my backup directory under a directory called
> 'asdf' (the database name), which seems like a successful backup, but
> when I connect with the following URL:
> 
> jdbc:derby:net://localhost:1527/asdf;restoreFrom=/home/cs/Desktop/workspace/asdf/db/derby-backups
> 
> 
> nothing is different, and the restoreFrom apparently did nothing. Here
> are my config details:
> 
> Java VM:  Java HotSpot(TM) Client VM
> Java Version:  1.4.2_06-b03
> Java Vendor:  Sun Microsystems Inc.
> OS Name:  Linux
> OS Arch:  i386
> OS Version:  2.6.9
> 
> Both the Derby and Universal JDBC driver were downloaded about 5 days
> ago, so they're probably the latest versions, but here's what JDBC
> records as the versions:
> 
> Apache Derby
> 10.0.2.1
> IBM DB2 JDBC Universal Driver Architecture
> 2.4.17
> 
> I also tried connecting directly using ij, and observed the same
> behavior. I started ij, then executed:
> 
> connect
> 'jdbc:derby:net://localhost:1527/asdf;restoreFrom=/home/cs/Desktop/workspace/asdf/db/derby-backups:user=test;password=test;';
> 
> 
> And I observed that the data created after the backup occurred was still
> there.
> 
> Any ideas what might be going on? If anybody has been able to
> successfully restore, I'd really appreciate seeing a connectUrl or two
> that worked correctly.
> 
> Thanks in advance...
> 
> -calvin
> 
> p.s. Erring on the side of too much info, here is the ANT target which
> shows how I'm starting the server:
> 
> <target name="db-start" description="Start derby on localhost:1527">
>     <mkdir dir="${derby.basedir}"/>
>     <java classname="org.apache.derby.drda.NetworkServerControl"
> fork="yes" dir="${derby.basedir}">
>         <arg line="start"/>
>     <jvmarg value="-Dderby.system.home=${derby.basedir}"/>
>     <jvmarg value="-Xmx256m"/>
>         <classpath refid="db.derby.server.classpath"/>
>     </java>
> </target>
> 
> Roughly equivalent to:
> 
> cd ${derby.basedir}; java -Dderby.system.home=${derby.basedir} -Xmx256m
> -classpath ${db.derby.server.classpath}
> org.apache.derby.drda.NetworkServerControl start
> 
>