I've been looking for a while for the best way to backup my Domoticz instance that's running on a Raspberry Pi.
I want to be able to restore it with minimal downtime should the device or the software fail.
Domoticz own Backup function works, but it only backs up it's own database, not the scripts that you made.
I've looked at various ways of imaging the SD card without pulling it out (that's just prone to forgetting) but nothing that really works without installing a complete backup solution for one machine. That's just overkill for me.
After a tiresome search and several good nights of sleep, I decided it's just better to backup the database, the crons and every script and just reinstall raspbian with Domoticz when the time comes.
Then it's just a matter of uploading the database and putting all backed up files in the locations.
To do this automatically, i've written a script that can be run as a cron. You can find it here: https://github.com/MoebiusZero/Scripts/blob/main/Bash/auto_backup.sh
There are only a few settings you need to change:
Change the line below to the IP address and portnumber of your Domoticz server, for example: 192.168.1.1:8080
Then change this line if you want to use a different backup location, leave the $TIMESTAMP part at the end, this will create a folder in the directory with the date when the backup was made as the foldername.
Makes it easy to find your backups no?
To make a cron, use the crontab -e
command. Then add the following line at the bottom:0 3 * * * /home/pi/domoticz/scripts/auto_backup.sh
Change the path to wherever you placed your script. In this case, the script is tasked to run every day at 3 AM.
If you want to change this I suggest using this crontab generator: https://crontab.guru/#0_4_*_*_*
This should help making your own schedule.