Database backup

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.
Post Reply
Ady92100
Posts: 24
Joined: Thursday 22 January 2015 11:58
Target OS: NAS (Synology & others)
Domoticz version: >V3.6796
Location: Fr
Contact:

Database backup

Post by Ady92100 » Thursday 24 August 2017 10:32

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.
Synology DS212 + RFXTrx433 + AEon Stick S2
Oregon - Thgr122Nx / Chacon - module 1000w - détecteur de fumée 34131 / OWL -CM180 / Greenwave Multiprise

Hobbybob
Posts: 60
Joined: Monday 01 May 2017 19:03
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: Database backup

Post by Hobbybob » Thursday 24 August 2017 12:24

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.

Ady92100
Posts: 24
Joined: Thursday 22 January 2015 11:58
Target OS: NAS (Synology & others)
Domoticz version: >V3.6796
Location: Fr
Contact:

Re: Database backup

Post by Ady92100 » Thursday 24 August 2017 13:32

Hello
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

User avatar
Egregius
Posts: 2381
Joined: Thursday 09 April 2015 12:19
Target OS: Raspberry Pi
Domoticz version: BetaRPi2
Location: Beitem, BE
Contact:

Re: Database backup

Post by Egregius » Thursday 24 August 2017 14:01

Just copy your entire domoticz folder with rsync to another device and you don't need the auto backup function.

Ady92100
Posts: 24
Joined: Thursday 22 January 2015 11:58
Target OS: NAS (Synology & others)
Domoticz version: >V3.6796
Location: Fr
Contact:

Re: Database backup

Post by Ady92100 » Thursday 24 August 2017 15:52

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

User avatar
Egregius
Posts: 2381
Joined: Thursday 09 April 2015 12:19
Target OS: Raspberry Pi
Domoticz version: BetaRPi2
Location: Beitem, BE
Contact:

Re: Database backup

Post by Egregius » Thursday 24 August 2017 16:09

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests