Automatic backup: Every day or week
Moderators: leecollings, remb0
-
- Posts: 53
- Joined: Thursday 06 March 2014 18:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Automatic backup: Every day or week
Automatic backup.
I installed a new Pi 3+ as Master. I forgot to make the last manual DB backup but this is not a big problem because I didn’t change anything after the last DB backup.
The only thing what I miss is my 1-Wire (6 sensors) data.
So is there an option or script what can send every day or week the DB and scripts folder to: *
* I have a in my network an Synology NAS and I have Dropbox.
What will be the best way to backup this and how?
(WhatsApp has for example an everyday backup to Google Drive. )
I installed a new Pi 3+ as Master. I forgot to make the last manual DB backup but this is not a big problem because I didn’t change anything after the last DB backup.
The only thing what I miss is my 1-Wire (6 sensors) data.
So is there an option or script what can send every day or week the DB and scripts folder to: *
* I have a in my network an Synology NAS and I have Dropbox.
What will be the best way to backup this and how?
(WhatsApp has for example an everyday backup to Google Drive. )
- EdwinK
- Posts: 1820
- Joined: Sunday 22 January 2017 21:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Rhoon
- Contact:
Re: Automatic backup: Every day or week
I just followed the steps outlined here. And it works great.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
-
- Posts: 53
- Joined: Thursday 06 March 2014 18:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Automatic backup: Every day or week
Tanks EdwinK,
I missed this
I will take look to it.
Thanks.
I missed this

Thanks.
- HansieNL
- Posts: 964
- Joined: Monday 28 September 2015 15:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Automatic backup: Every day or week
I have a NSF share (Synology) mounted on the Raspberry Pi. I created a backup script that runs via a crontab job every night.
If the backup is older than 14 days it will be deleted.
domoticz_backup.lst
If the backup is older than 14 days it will be deleted.
Code: Select all
#!/bin/bash
### PLACE THIS SCRIPT IN:/home/pi/domoticz/scripts as domoticz_backup.sh
DOMO_IP="192.168.2.1" # Domoticz IP
DOMO_PORT="8080" # Domoticz port
### END OF USER CONFIGURABLE PARAMETERS
TIMESTAMP=`/bin/date +%Y%m%d%H%M`
BACKUPDBFILE="domoticz_$TIMESTAMP.db"
BACKUPFILES="domoticz_$TIMESTAMP.tar.gz"
echo -e "\n\e[1;33mBacking up Domoticz. Please standby...\e[0m\n"
#Create backup and make tar archives
/usr/bin/curl -s http://$DOMO_IP:$DOMO_PORT/backupdatabase.php > /mnt/backupz/$BACKUPDBFILE
sudo tar --exclude='domoticz.db-shm' --exclude='domoticz.db-wal' --exclude='/home/pi/domoticz/www/dashticz/.git' -zcvf /mnt/backupz/$BACKUPFILES -T /home/pi/domoticz/scripts/domoticz_backup.lst
#Delete backups older than 14 days
/usr/bin/find /mnt/backupz/ -name '*.db' -mtime +14 -delete
/usr/bin/find /mnt/backupz/ -name 'domoticz_*.tar.gz' -mtime +14 -delete
echo -e "\n\e[1;33mBacking up Domoticz finished!\e[0m\n"
- Spoiler: show
Blah blah blah
-
- Posts: 141
- Joined: Tuesday 31 January 2017 20:34
- Target OS: -
- Domoticz version:
- Contact:
Re: Automatic backup: Every day or week
hi
just installed the backup like in the wiki.
when i test the script it makes a backup..
but it doesnt make the backup automaticly..
followed the wiki exactly..
it makes a a backup perfectly
also tried
and tried without sudo, and tried with pi instead of sudo.. but nothing
just installed the backup like in the wiki.
when i test the script it makes a backup..
but it doesnt make the backup automaticly..
followed the wiki exactly..
but when ipi@raspberrypi:~ $ sudo crontab -l
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
# * * * * * commando dat uitgevoerd moet worden
# - - - - -
# | | | | |
# | | | | +--------------------- dag van de week (0 - 6) (zondag=0)
# | | | +-------------------- maand (1 - 12)
# | | +--------- dag van de maand(1 - 31)
# | +----------- uur (0 - 23)
# +--------- minuten (0 - 59)
#------------------------------------------------------------------------
0 1 * * * sudo home/pi/domoticz/scripts/domoticz_backup.sh
0 3 22 * * /mnt/backup/system_backup.sh
Code: Select all
sudo home/pi/domoticz/scripts/domoticz_backup.sh
also tried
Code: Select all
sudo ~/domoticz/scripts/domoticz_backup.sh
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Automatic backup: Every day or week
Try to use a full qualified pathastrapowerrr wrote: ↑Saturday 20 April 2019 23:14 0 1 * * * sudo home/pi/domoticz/scripts/domoticz_backup.sh
0 1 * * * sudo /home/pi/domoticz/scripts/domoticz_backup.sh
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: 141
- Joined: Tuesday 31 January 2017 20:34
- Target OS: -
- Domoticz version:
- Contact:
Re: Automatic backup: Every day or week
Will try that tomorrow. I als tried it like sudo ~/Domoticz just like in the wiki. That should also work I thought.waaren wrote:Try to use a full qualified pathastrapowerrr wrote: ↑Saturday 20 April 2019 23:14 0 1 * * * sudo home/pi/domoticz/scripts/domoticz_backup.sh
0 1 * * * sudo /home/pi/domoticz/scripts/domoticz_backup.sh
Verzonden vanaf mijn iPhone met Tapatalk
-
- Posts: 141
- Joined: Tuesday 31 January 2017 20:34
- Target OS: -
- Domoticz version:
- Contact:
Re: Automatic backup: Every day or week
nope.. not working
when i enter i get as a result all is finished with no problems.
when i look at my server folder i have a perfect backup.
so script is working and also manual.
but when i use contrab its not making any backup.
here is my file
how is this possible…?
the time is for me to try over and over.. as this is for 20:18 everyday if i understand correctly.

when i enter
Code: Select all
~/domoticz/scripts/domoticz_backup.sh
when i look at my server folder i have a perfect backup.
so script is working and also manual.
but when i use contrab its not making any backup.
here is my file
Code: Select all
pi@raspberrypi:~ $ sudo crontab -l
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
# * * * * * commando dat uitgevoerd moet worden
# - - - - -
# | | | | |
# | | | | +--------------------- dag van de week (0 - 6) (zondag=0)
# | | | +-------------------- maand (1 - 12)
# | | +--------- dag van de maand(1 - 31)
# | +----------- uur (0 - 23)
# +--------- minuten (0 - 59)
#------------------------------------------------------------------------
18 20 * * * sudo ~/domoticz/scripts/domoticz_backup.sh
pi@raspberrypi:~ $
the time is for me to try over and over.. as this is for 20:18 everyday if i understand correctly.
- Minglarn
- Posts: 214
- Joined: Friday 21 August 2015 19:27
- Target OS: Raspberry Pi / ODroid
- Domoticz version: v3.8153
- Location: Stockholm / Sweden
- Contact:
Re: Automatic backup: Every day or week
Is it possible to make the bash script archive into same tar?
I've these folders backed up every night 01:00.
Is it possible to make only 1 archive instead of 4?
I've these folders backed up every night 01:00.
Code: Select all
### Send to Network disk through FTP
curl -s --disable-epsv -v -T"/tmp/$BACKUPFILEGZ" -u"$USERNAME:$PASSWORD" "ftp://$SERVER/$DESTDIRNAS"
curl -s --disable-epsv -v -T"/tmp/domoticz_scripts_$TIMESTAMP.tar.gz" -u"$USERNAME:$PASSWORD" "ftp://$SERVER/$DESTDIRNAS"
curl -s --disable-epsv -v -T"/tmp/telegram_scripts_$TIMESTAMP.tar.gz" -u"$USERNAME:$PASSWORD" "ftp://$SERVER/$DESTDIRNAS"
curl -s --disable-epsv -v -T"/tmp/plugins_scripts_$TIMESTAMP.tar.gz" -u"$USERNAME:$PASSWORD" "ftp://$SERVER/$DESTDIRNAS
“When you eliminate the impossible, whatever remains, however improbable, must be the truth.” -Spock in Star Trek VI
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Automatic backup: Every day or week
If you type sudo crontab -l you will see the crontab for root.
in that crontab the command sudo ~/domoticz/scripts/domoticz_backup.sh
will try to execute the script /root/domoticz/scripts/domoticz_backup.sh (because executed as root)
That's why I suggested to use the full qualified name being /home/pi/domoticz/scripts/domoticz_backup.sh
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: 141
- Joined: Tuesday 31 January 2017 20:34
- Target OS: -
- Domoticz version:
- Contact:
Re: Automatic backup: Every day or week
Yes! Thanks!!waaren wrote:If you type sudo crontab -l you will see the crontab for root.
in that crontab the command sudo ~/domoticz/scripts/domoticz_backup.sh
will try to execute the script /root/domoticz/scripts/domoticz_backup.sh (because executed as root)
That's why I suggested to use the full qualified name being /home/pi/domoticz/scripts/domoticz_backup.sh
Verzonden vanaf mijn iPhone met Tapatalk
Who is online
Users browsing this forum: No registered users and 1 guest