Page 1 of 1
Automatic backup: Every day or week
Posted: Thursday 19 July 2018 19:30
by Ritmeester
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. )
Re: Automatic backup: Every day or week
Posted: Thursday 19 July 2018 19:32
by EdwinK
I just followed the steps outlined
here. And it works great.
Re: Automatic backup: Every day or week
Posted: Thursday 19 July 2018 19:41
by Ritmeester
Tanks EdwinK,
I missed this

I will take look to it.
Thanks.
Re: Automatic backup: Every day or week
Posted: Thursday 19 July 2018 21:02
by HansieNL
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.
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"
domoticz_backup.lst
- Spoiler: show
-
/etc/fail2ban/filter.d/domoticz.conf
/etc/fail2ban/jail.local
/etc/fstab
/etc/init.d/domoticz.sh
/etc/logrotate.d/domoticz
/home/pi
Re: Automatic backup: Every day or week
Posted: Saturday 20 April 2019 23:14
by astrapowerrr
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..
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)
#------------------------------------------------------------------------
0 1 * * * sudo home/pi/domoticz/scripts/domoticz_backup.sh
0 3 22 * * /mnt/backup/system_backup.sh
but when i
Code: Select all
sudo home/pi/domoticz/scripts/domoticz_backup.sh
it makes a a backup perfectly
also tried
Code: Select all
sudo ~/domoticz/scripts/domoticz_backup.sh
and tried without sudo, and tried with pi instead of sudo.. but nothing
Re: Automatic backup: Every day or week
Posted: Saturday 20 April 2019 23:34
by waaren
astrapowerrr wrote: ↑Saturday 20 April 2019 23:14
0 1 * * * sudo home/pi/domoticz/scripts/domoticz_backup.sh
Try to use a full qualified path
0 1 * * * sudo /home/pi/domoticz/scripts/domoticz_backup.sh
Re: Automatic backup: Every day or week
Posted: Saturday 20 April 2019 23:50
by astrapowerrr
waaren wrote:astrapowerrr wrote: ↑Saturday 20 April 2019 23:14
0 1 * * * sudo home/pi/domoticz/scripts/domoticz_backup.sh
Try to use a full qualified path
0 1 * * * sudo /home/pi/domoticz/scripts/domoticz_backup.sh
Will try that tomorrow. I als tried it like sudo ~/Domoticz just like in the wiki. That should also work I thought.
Verzonden vanaf mijn iPhone met Tapatalk
Re: Automatic backup: Every day or week
Posted: Monday 22 April 2019 20:23
by astrapowerrr
nope.. not working
when i enter
Code: Select all
~/domoticz/scripts/domoticz_backup.sh
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
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:~ $
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.
Re: Automatic backup: Every day or week
Posted: Tuesday 23 April 2019 21:45
by Minglarn
Is it possible to make the bash script archive into same tar?
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
Is it possible to make only 1 archive instead of 4?
Re: Automatic backup: Every day or week
Posted: Tuesday 23 April 2019 22:24
by waaren
astrapowerrr wrote: ↑Monday 22 April 2019 20:23
nope.. not working
how is this possible…?
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
Re: Automatic backup: Every day or week
Posted: Tuesday 23 April 2019 22:30
by astrapowerrr
waaren wrote:astrapowerrr wrote: ↑Monday 22 April 2019 20:23
nope.. not working
how is this possible…?
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
Yes! Thanks!!
Verzonden vanaf mijn iPhone met Tapatalk