jokay/docker-ccu-historian

Option for compact the database

etofi opened this issue · 2 comments

etofi commented

Is it possible to add the following two environment variables to make the database smaller?

  1. CONFIG_COMPACT_CRON
    Specifies in the normal cronjob format how often the compression should be executed (for example "* * 1 * *")
    If there is nothing in it, there is no compression.

  2. CONFIG_COMPACT_KEEP_MONTH
    Number of months you want to keep data (for example "12")

Then at the time defined in the variable CONFIG_COMPACT_CRON a script has to be executed which does the following one after the other.

  1. Stop CCU-Historian
  2. java -jar /opt/ccu-historian/ccu-historian.jar -clean $(date -d="CONFIG_COMPACT_KEEP_MONTH month ago" +%Y-%m-%d)
  3. java -jar /opt/ccu-historian/ccu-historian.jar -recalc
  4. java -jar /opt/ccu-historian/ccu-historian.jar -compact
  5. Start CCU-Historian

This would be great.

jokay commented

This seems indeed very useful.

I will look into this as soon as I have some spare time 👍

jokay commented

I think the main problem would be 1. Stop CCU-Historian as it would stop the container as well.

But may be I could add CONFIG_KEEP_MONTHS only so it can be executed (-clean, -recalc, -compact) before the start of CCU-Historian.