Page 1 of 1
Daily backup, automatically, of database
Posted: Saturday 17 August 2019 10:22
by Bernd
The RPi has the bad behavior to crash once in a while. All data between the period of the last manual backup and the moment of the crash is then lost. Is it possible to auto-email the database daily from out of Domoticz?
Re: Daily backup, automatically, of database
Posted: Saturday 17 August 2019 18:16
by waaren
Bernd wrote: ↑Saturday 17 August 2019 10:22
The RPi has the bad behavior to crash once in a while. All data between the period of the last manual backup and the moment of the crash is then lost. Is it possible to auto-email the database daily from out of Domoticz?
If your database size is not very big ( this works with my database of approximate 10 Mbyte ) you can use this in a cron job or in a bash script triggered by an domoticz event / script.
Code: Select all
domoDir=/home/pi/domoticz # change to location of your domoticz.db
[email protected] # change to your Email address
sudo echo "Backup attached" > message.txt
sudo cp $domoDir/domoticz.db $domoDir/backup.db
sudo mail -s "backup" $mailAddress -A $domoDir/backup.db < message.txt
sudo rm $domoDir/backup.db
sudo rm message.txt
Re: Daily backup, automatically, of database
Posted: Tuesday 28 December 2021 2:15
by sion
Hi guys.
I’m following the guide for backing up to nas in the wiki, and have what’s probably A stupid question.
On the part of the code for deleting old backups:
Code: Select all
# work out our cutoff date
MM=`date --date="$ndays days ago" +%b`
DD=`date --date="$ndays days ago" +%d`
TT=`date --date="$ndays days ago" +%s`
Do I just over write the MM DD and TT ?
So if I want to delete anything older than 15days, id do:
Code: Select all
# work out our cutoff date
00=`date --date="$ndays days ago" +%b`
15=`date --date="$ndays days ago" +%d`
00=`date --date="$ndays days ago" +%s`
Or for files over a month:
Code: Select all
# work out our cutoff date
01=`date --date="$ndays days ago" +%b`
00=`date --date="$ndays days ago" +%d`
00=`date --date="$ndays days ago" +%s`
Thanks.
Sion.
Re: Daily backup, automatically, of database
Posted: Tuesday 28 December 2021 21:51
by waltervl
You are referring to this wiki page I presume
https://www.domoticz.com/wiki/Daily_bac ... ternal_hdd
In the extension for deleting old backups you only have to modify the ndays=19 line if you want to set something else. The rest will be done for you.