how to restore h2 db?

2,469 views
Skip to first unread message

nirz

unread,
Jul 29, 2008, 1:35:00 PM7/29/08
to H2 Database
hi
I have created h2 DB and then made a backup of it using SQL command :
Backup To 'D:\backup.zip'.
I can see that zip file was created.
now I created new DB and I want to restore there my backup file.
I run from SQL command : 'java org.h2.tools.RunScript -url jdbc:h2:~/
test -user sa -script test.zip -options compression zip'
it doesn't work . I get following message :


"java org.h2.tools.RunScript -url jdbc:h2:~/localDb2 -user sa -script
D:\backup.zip -options compression zip;
Syntax error in SQL statement JAVA[*] ORG.H2.TOOLS.RUNSCRIPT -URL
JDBC:H2:~/LOCALDB2 -USER SA -SCRIPT D:\BACKUP.ZIP -OPTIONS COMPRESSION
ZIP ; SQL statement:
java org.h2.tools.RunScript -url jdbc:h2:~/localDb2 -user sa -script D:
\backup.zip -options compression zip [42000-75] 42000/42000 (Help)
org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement JAVA[*]
ORG.H2.TOOLS.RUNSCRIPT -URL JDBC:H2:~/LOCALDB2 -USER SA -SCRIPT D:
\BACKUP.ZIP -OPTIONS COMPRESSION ZIP ; SQL statement:
java org.h2.tools.RunScript -url jdbc:h2:~/localDb2 -user sa -script D:
\backup.zip -options compression zip

thanks

Brish

unread,
Jul 29, 2008, 5:21:14 PM7/29/08
to H2 Database
When you use backup it backs up the data files. You don't need to run
a script to get it back, just unzip the .zip file.

Personally I would do this to backup/restore:

Backup :

script to '/temp/backup.sql.gz' compression gzip;

To restore create a new database by making a connection to it and do
this :

runscript from '/temp/backup.sql.gz' compression gzip;

Brish

Thomas Mueller

unread,
Jul 29, 2008, 10:22:22 PM7/29/08
to h2-da...@googlegroups.com
Hi,

> I run from SQL command : 'java org.h2.tools.RunScript -url jdbc:h2:~/
> test -user sa -script test.zip -options compression zip'

Well, this is not a SQL statement, it is the command line to run the
Java class. Try executing this in the Command Prompt (Windows) or
Terminal (Linux). You need to switch to the right directory, and you
may need to add '-cp h2.jar'. Even easier is to use the H2 Console: in
the login page, click on 'Tools' and then 'RunScript'. Fill in the
required fields.

Regards,
Thomas

Reply all
Reply to author
Forward
0 new messages