I have used the h2 database for a Desktop based application (using swing). I also backed it up and stored it in my file system with the ".h2.db" extension. This is not a readable file. So how can I restore my h2 backup file?
1 Answers
It's recommended to create a ZIP file using a specific tool. It should be possible to use the tool on the copied file as well:
The recommended way to backup a database is to create a compressed SQL script file. This will result in a small, human readable, and database version independent backup. Creating the script will also verify the checksums of the database file. The Script tool is ran as follows:
java org.h2.tools.Script -url jdbc:h2:~/test -user sa -script test.zip -options compression zip
The ZIP file can then be used to restore the DB:
To restore a database from a SQL script file, you can use the RunScript tool:
java org.h2.tools.RunScript -url jdbc:h2:~/test -user sa -script test.zip -options compression zip
http://h2database.com/html/tutorial.html#upgrade_backup_restore

- 11
- 1