Backup Blockly Scripts

Configure a cron job on the OS to call openhab-cli backup.

Or you can just create a script that does this and drop it into /etc/cron.daily. Just don’t use any extensions for the file name (e.g. backup instead of backup.sh).

That’s the most appropriate approach.

Note that the JSONDB creates up to n backups automatically on every change where n is configurable. I think 5 is the default.

1 Like

What time does this usually run?

Best, Jay

It differs from one system to the next. Usually sometime early in the morning. You can see the cron expression for each folder using the command:

grep run-parts /etc/crontab

On a stock Raspberry Pi OS that shows:

17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )

It runs each script in sequence so if there is a long running script and your particular backup script isn’t first it might be some time adter that time before the script is run.

You can of course modify the time by changing the crontab, but beware that there may be other parts of the operating system or software that has placed stuff in that folder and expect them to be run at that time.

1 Like