0

I'm using h2database version 1.4.200 with hibernate for saving in database file.

My programs needs to regulary save backup and I don't care about corruption's file's problems.

After looking the documentation : http://h2database.com/html/features.html#database_file_locking

I decided to use parameter LOCK_FILE=NO. I saved my models and keeped the entity manager opened. When I tryed to copy the db file "data.mv.db", my database file was always locked even if I used Lock_FILE=NO.

Parameter LOCK_FILE=NO, does it work correctly ? There is a alternative for copying speedly my db-file in java ?

Guyard
  • 53
  • 6

1 Answers1

2

Any attempt to copy the file when database is in use is a way to get a possibly corrupted backup.

H2 has BACKUP command for online backups.

BACKUP TO 'filename.zip'

This command creates a ZIP archive with a consistent copy of the database file.

Evgenij Ryazanov
  • 6,960
  • 2
  • 10
  • 18
  • Thank you, it solved my problem. For information : `Connection conn = DriverManager.getConnection(url); Statement st = conn.createStatement(); st.execute("BACKUP TO 'backup.zip'"); conn.close();` – Guyard Mar 25 '20 at 17:20