Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to back up the embedded H2 database engine while it is running?

Tags:

I would like to build up an web application with H2 database engine. However, I still don't know how to back up the data while the database is running after reading this tutorial:

http://www.h2database.com/html/tutorial.html#upgrade_backup_restore

Does H2 output its stored file to somewhere in the file system? Can I just back up the outputted files?

like image 200
Winston Chen Avatar asked Jan 10 '10 04:01

Winston Chen


People also ask

How do I backup my H2 database?

Use the following command for the same. BACKUP TO 'backup. zip'; On executing the above command, you will get the backup.

Where are H2 databases stored?

And in case it's not obvious, on Linux/MacOSX systems the H2 database files are stored under the path in the JDBC URL, so ~/test would be found at $HOME/test.

How do I know if H2 is running?

Step 3: Verify H2 Database InstallationClick Windows → type H2 Console → Click H2 console icon. Connect to the URL http://localhost:8082. At the time of connecting, the H2 database will ask for database registration as shown in the following screenshot.


1 Answers

H2 is stored on the file system, but it would be better to use the backup tools that you reference, because the file format can change between versions of H2. If you upgrade H2, it may not any longer be able to read the files it created in a previous version. Also, if you copy the files it uses, I would recommend shutting the database down first, otherwise the copied files may be unreadable by H2.

The location of the file depends on the jdbc url you specify. See the FAQ: http://www.h2database.com/html/faq.html

like image 75
Jay Askren Avatar answered Sep 20 '22 06:09

Jay Askren