How to Restore a H2 Database Backup

September 28th, 2021

Go to Administration > System Settings > SQL database backup

Screenshot 2019-01-04 15.42.34.png

Click the down arrow in the “Select a file to restore” list and select the backup you want to restore from the drop down list. Next click the Restore database button. Once the restore has finished be sure to restart Mango to insure all your configuration is loaded properly.

If you are having issues starting Mango you can first rename or delete your current H2 database file: /databases/mah2.h2.db Start Mango and you will now have a new clean database. You can login with admin | admin and complete the restore process. Be sure you do not restore a database that is from an older version of Mango.

Restoring H2 Database via CLI

To restore an H2 database via command line (Ubuntu) follow these steps:

  • Stop Mango:
systemctl stop mango
  • Relocate existing H2 database file(s) for rollback if needed (from within the mango/databases/ directory):
mv mah2.200.* ~/
  • Locate the filename of the core-database zip file to restore.

  • Locate the absolute paths for the following directories:

    • mango/lib/h2-1.4.200.jar (or your version of h2)
    • mango/databases
    • mango/backups
  • NOTE: If you're using the h2-1.4.196.jar, in the restore command below, change both the mango/lib path to the correct file name AND change the output to mango/databases/mah2 instead of mango/databases/mah2.200

  • Run the restore process (use the absolute paths for mango/lib, mango/databases, and mango/backups):

java -cp /opt/mango/lib/h2-1.4.200.jar -url "jdbc:h2:/opt/mango/databases/mah2.200;MV_STORE=TRUE" -user "" -password "" -script /opt/mango/backup/ -options compression zip
  • Confirm the files are accessible to the user of the Mango service (in mango/):
chown -R mango:mango databases
  • Start Mango:
systemctl start mango

Restoring Any Database From a Backup File

You can set the db.createTables.restorFrom variable in the file to the location of a backup file. This supports both .zip and .sql files

Copyright © 2024 Radix IoT, LLC.