Page 1 of 1
Database backup
Posted: Thursday 24 August 2017 10:32
by Ady92100
Suggestion
The automatic backup of the database is scheduled each hour (at "*:00"). It may takes some times.
and Timer scripts are scheduled each minute.
Among my timer scripts, some are triggered every minute, some each hour (and need to be triggered at *:00) .
So each hour (*:00) timer scripts are triggered precisely during a database backup.
Therefore you find regularly in the log messages like the following
2017-08-24 04:00:10.181 Error: EventSystem: Warning!, lua script /usr/local/domoticz/var/scripts/lua/script_time_central.lua has been running for more than 10 seconds
2017-08-24 05:00:10.505 Error: EventSystem: Warning!, lua script /usr/local/domoticz/var/scripts/lua/script_time_central.lua has been running for more than 10 seconds
2017-08-24 08:00:10.236 Error: EventSystem: Warning!, lua script /usr/local/domoticz/var/scripts/lua/script_time_central.lua has been running for more than 10 seconds
Suggestion
"add an offset (in minutes) in the parameter tab to launch the database backup at a suitable minute of the hour at *:minutes""
to avoid conflict between timer script launched each hour and the database backup scheduled at hour+xxminutes.
Thanks for the work on DZ.
Re: Database backup
Posted: Thursday 24 August 2017 12:24
by Hobbybob
Sorry if I understand wrong, but there is an option in standard Domoticz to backup the database every hour? Or is it a script that you have running?
I cannot find the option in the configuration-tabs, but if it is a standard-option in Domoticz it could be interesting.
Re: Database backup
Posted: Thursday 24 August 2017 13:32
by Ady92100
Hello
Settings>Parameter>Database Backup
backup every hour
Re: Database backup
Posted: Thursday 24 August 2017 14:01
by Egregius
Just copy your entire domoticz folder with rsync to another device and you don't need the auto backup function.
Re: Database backup
Posted: Thursday 24 August 2017 15:52
by Ady92100
thanks for the hint
Re: Database backup
Posted: Thursday 24 August 2017 16:09
by Egregius
For Synology:
This script makes a complete backup of the domoticz folder, it's database and scripts. The script keeps a versioned backup of every day you run it.
Code: Select all
#!/bin/sh
NOW=$(date +"%Y-%m-%d")
SOURCE="/volume1/@appstore/domoticz/"
DESTINATION="/volume1/homes/guy/backup/domoticz"
LOGFILE=/volume1/web/secure/backups/logs/domoticz.$NOW.txt
echo ------------------------------------ START domoticz -- $(date +"%Y-%m-%d %H:%M:%S") UTC+2 | tee -a $LOGFILE
rsync -aP --exclude-from '/volume1/homes/guy/backup/excludedfiles.txt' --stats --delete-after --ignore-errors --links --link-dest="$DESTINATION/__prev/" "$SOURCE" "$DESTINATION/$NOW" | tee -a $LOGFILE
rm -f "$DESTINATION/__prev"
ln -s "$NOW" "$DESTINATION/__prev"
echo ------------------------------------ END domoticz -- $(date +"%Y-%m-%d %H:%M:%S") UTC+2 | tee -a $LOGFILE
For Raspberry:
Script executed at synology nas to backup domoticz installed on a Raspberry Pi.
Same as above, script makes a complete backup of the domoticz folder, it's database and scripts. The script keeps a versioned backup of every day you run it.
Code: Select all
#!/bin/sh
NOW=$(date +"%Y-%m-%d")
NAME="RPI-Domoticz"
SOURCE="[email protected]:/home/pi/domoticz/"
DESTINATION="/volume1/homes/guy/backup/$NAME"
LOGFILE=/volume1/homes/guy/backup/__Logs/$NAME.$NOW.txt
echo ------------------- START $NAME -- $(date +"%Y-%m-%d %H:%M:%S") | tee -a $LOGFILE
rsync -aP --exclude-from '/volume1/homes/guy/backup/excludedfiles.txt' -e "ssh -i /root/.ssh/home" --stats --delete-after --links --link-dest="$DESTINATION/__prev/" "$SOURCE" "$DESTINATION/$NOW" | tee -a $LOGFILE
rm -f "$DESTINATION/__prev"
ln -s "$NOW" "$DESTINATION/__prev"
echo ------------------- END $NAME -- $(date +"%Y-%m-%d %H:%M:%S") | tee -a $LOGFILE
If you change the structure of the date in the NOW variable you could have a version for every hour.
Only changed files are copied. So first backup will be big. Sequential backups only the size of the database.
Cleaning up the old versions is as simple as removing the oldest folders.
Re: Database backup
Posted: Tuesday 27 August 2019 10:41
by StratosHF
I like the built in backup tool as it gives you lots of restore points (hourly/daily/monthly).
I find the hourly backup a bit over the top and it makes the system (RPi 3) a bit laggy on the hour (this then gives me ear ache when the family moan about the response times). Could the built in backup tool be modified to backup every 12 or 24 hours?
If it's hard coded I wondered if cron could be used to turn the backup on/off using a json setting enableautobackup ???
Re: Database backup
Posted: Tuesday 27 August 2019 19:48
by waaren
StratosHF wrote: ↑Tuesday 27 August 2019 10:41
I like the built in backup tool as it gives you lots of restore points (hourly/daily/monthly).
If it's hard coded I wondered if cron could be used to turn the backup on/off using a json setting enableautobackup ???
It is hard coded and there is no JSON to enable / disable it. It needs to be set via the webpage or directly in the database.
But if you are able to make a cron job to send a JSON, wouldn't it be just as easy to use a cron JOB to just move a copy of the database to a any folder / any name ? Effectively using the same / similar naming convention as domoticz use for the autoBackup ?
Re: Database backup
Posted: Tuesday 27 August 2019 19:56
by StratosHF
Yes, a bash script that emulates the same folder structure is the most sensible solution.