Database backup
Moderators: leecollings, remb0
-
- Posts: 24
- Joined: Thursday 22 January 2015 10:58
- Target OS: NAS (Synology & others)
- Domoticz version: >V3.6796
- Location: Fr
- Contact:
Database backup
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.
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.
Synology DS212 + RFXTrx433 + AEon Stick S2
Oregon - Thgr122Nx / Chacon - module 1000w - détecteur de fumée 34131 / OWL -CM180 / Greenwave Multiprise
Oregon - Thgr122Nx / Chacon - module 1000w - détecteur de fumée 34131 / OWL -CM180 / Greenwave Multiprise
Re: Database backup
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.
I cannot find the option in the configuration-tabs, but if it is a standard-option in Domoticz it could be interesting.
-
- Posts: 24
- Joined: Thursday 22 January 2015 10:58
- Target OS: NAS (Synology & others)
- Domoticz version: >V3.6796
- Location: Fr
- Contact:
Re: Database backup
Hello
Settings>Parameter>Database Backup
backup every hour
Settings>Parameter>Database Backup
backup every hour
Synology DS212 + RFXTrx433 + AEon Stick S2
Oregon - Thgr122Nx / Chacon - module 1000w - détecteur de fumée 34131 / OWL -CM180 / Greenwave Multiprise
Oregon - Thgr122Nx / Chacon - module 1000w - détecteur de fumée 34131 / OWL -CM180 / Greenwave Multiprise
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Database backup
Just copy your entire domoticz folder with rsync to another device and you don't need the auto backup function.
-
- Posts: 24
- Joined: Thursday 22 January 2015 10:58
- Target OS: NAS (Synology & others)
- Domoticz version: >V3.6796
- Location: Fr
- Contact:
Re: Database backup
thanks for the hint
Synology DS212 + RFXTrx433 + AEon Stick S2
Oregon - Thgr122Nx / Chacon - module 1000w - détecteur de fumée 34131 / OWL -CM180 / Greenwave Multiprise
Oregon - Thgr122Nx / Chacon - module 1000w - détecteur de fumée 34131 / OWL -CM180 / Greenwave Multiprise
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Database backup
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.
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.
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.
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
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
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.
-
- Posts: 12
- Joined: Sunday 18 September 2016 18:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.1
- Location: Oxford
- Contact:
Re: Database backup
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 ???
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 ???
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Database backup
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 ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 12
- Joined: Sunday 18 September 2016 18:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.1
- Location: Oxford
- Contact:
Re: Database backup
Yes, a bash script that emulates the same folder structure is the most sensible solution.
Who is online
Users browsing this forum: No registered users and 1 guest