Daily backup, automatically, of database
Moderators: leecollings, remb0
- Bernd
- Posts: 27
- Joined: Tuesday 04 February 2014 8:44
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.1
- Location: The Netherlands, De Wijk
- Contact:
Daily backup, automatically, of database
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?
Raspberry Pi 4 2GB (RPi OS Light)
RFXCOM RFXtrx433E, firmware version = 1025
RFXCOM RFXtrx433E, firmware version = 1025
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Daily backup, automatically, of database
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
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: 113
- Joined: Friday 08 January 2016 12:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Daily backup, automatically, of database
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:
Do I just over write the MM DD and TT ?
So if I want to delete anything older than 15days, id do:
Or for files over a month:
Thanks.
Sion.
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`
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`
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`
Sion.
running domoticz 3.4834 on rpi2, with
Hue bridge / bulbs.
lightwave rf sockets, mood controlers, sensors & contacts.
Home bridge / Siri.
Ha bridge / echo Alexa.
Hard wired alarm system - setting home / away status.
Next: harmony hub.
Hue bridge / bulbs.
lightwave rf sockets, mood controlers, sensors & contacts.
Home bridge / Siri.
Ha bridge / echo Alexa.
Hard wired alarm system - setting home / away status.
Next: harmony hub.
- waltervl
- Posts: 5844
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Daily backup, automatically, of database
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.
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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Who is online
Users browsing this forum: No registered users and 1 guest