Skip to content

Backup Database and syncing

André Keßler edited this page Mar 3, 2019 · 1 revision

The application uses two different databases:

  • embedded h2 in-memory database
  • backup MySQL database

H2 in-memory database

The in-memory database is included in the application .war file already. It´s a fast and performant database which runs directly on the executed environment (raspberry pi). After stopping the application, every data inside this in-memory database will get lost.

MySQL database

You can set a backup database, to backup the measured values and configurations of the running application.

Database Syncing

When you have configured a backup database, the application will start sync-schedulers, to sync the data between the in-memory database and the backup database, as following...

Syncing at startup

When you starts the application, the in-memory h2 database will be empty. The following entities will get loaded from the backup database and will get imported to the h2 database:

  • TemperatureMeasurement: All temperature measurements will get imported
  • ScheduledShutterMovements: All defined timings for the shutter movements will get imported

Syncing at runtime

After starting the application, a database sync-job will get triggered, which performs every 1 minute. The following entities will get backuped:

  • TemperatureMeasurement: Get the date of the latest measurement of the backup-db, then search for newer entries after this date inside the embedded-db and copy these to the backup-db
  • ScheduledShuttermovements: Just delete all entries of the backup-db and insert all entries of the embedded-db

Clone this wiki locally