Different Backups from Crontab to network
Moderator: leecollings
-
- Posts: 14
- Joined: Sunday 21 July 2013 22:04
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Italy
- Contact:
Re: Different Backups from Crontab to network
Hello dudes, I'm sorry I passed a lot of time out of Forum, I'm busy with other thinks and I have really little time for Domoticz
Please if someone needs help with script, just drop me a private message and I should get a notification email!
Please if someone needs help with script, just drop me a private message and I should get a notification email!
-
- Posts: 1601
- Joined: Friday 18 October 2013 23:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Arnhem/Nijmegen Nederland
- Contact:
Re: Different Backups from Crontab to network
and counting:
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
-
- Posts: 1601
- Joined: Friday 18 October 2013 23:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Arnhem/Nijmegen Nederland
- Contact:
Re: Different Backups from Crontab to network
Go one step further ..
I can also make a backup for the script folder with the same setting and crontab?
If I'm going to write more scripts is one of handy backup ok ..
Thank you ..
And ps I had often necessary the backups ..
I can also make a backup for the script folder with the same setting and crontab?
If I'm going to write more scripts is one of handy backup ok ..
Thank you ..
And ps I had often necessary the backups ..
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
-
- Posts: 8
- Joined: Monday 29 September 2014 21:28
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Weert (Netherlands)
- Contact:
Re: Different Backups from Crontab to network
You can add this to the script before Done to enable the backup of the scripts folder
Code: Select all
### Backup Script Folder
tar -zcvf /tmp/domoticz_scripts_$TIMESTAMP.tar.gz /home/pi/domoticz/scripts/
### Send to Network disk through FTP
curl -s --disable-epsv -v -T"/tmp/domoticz_scripts_$TIMESTAMP.tar.gz" -u"$USERNAME:$PASSWORD" "ftp://$SERVER/$DESTDIR/"
### Remove temp backup file
/bin/rm /tmp/domoticz_scripts_$TIMESTAMP.tar.gz
-
- Posts: 20
- Joined: Wednesday 14 January 2015 21:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Different Backups from Crontab to network
I followed all steps from the wiki but wen I am at the step for testing I get this message back:
What have I done wrong or what am i missing?
Code: Select all
'!b.gzCan't open '/tmp/domoticz_20150313172005
curl: try 'curl --help' or 'curl --manual' for more information
* Illegal characters found in URL
/bin/rm: cannot remove `/tmp/domoticz_20150313172005\r.db.gz\r\r': No such file or directory
Re: Different Backups from Crontab to network
Found out the temp folder isn't correct. Make a folder on the pi where the script can backup to. I just made a folder in /home/pi/domoticz/scripts/backupLJ80 wrote:Hi all,
I followed all steps from the wiki but wen I am at the step for testing I get this message back:
What have I done wrong or what am i missing?Code: Select all
'!b.gzCan't open '/tmp/domoticz_20150313172005 curl: try 'curl --help' or 'curl --manual' for more information * Illegal characters found in URL /bin/rm: cannot remove `/tmp/domoticz_20150313172005\r.db.gz\r\r': No such file or directory
-
- Posts: 9
- Joined: Thursday 23 April 2015 13:54
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Different Backups from Crontab to network
i still get the same error i already make a new folder
'!b.gzCan't open '/tmp/domoticz_20150523214855
curl: try 'curl --help' or 'curl --manual' for more information
* Illegal characters found in URL
/bin/rm: cannot remove `/home/pi/domoticz/scripts/backupnas/domoticz_20150523214855\r.db\r': No such file or directory
the pi is creating the file but not upload it to the ftp server.
what i'm do i wrong.
'!b.gzCan't open '/tmp/domoticz_20150523214855
curl: try 'curl --help' or 'curl --manual' for more information
* Illegal characters found in URL
/bin/rm: cannot remove `/home/pi/domoticz/scripts/backupnas/domoticz_20150523214855\r.db\r': No such file or directory
the pi is creating the file but not upload it to the ftp server.
what i'm do i wrong.
- sincze
- Posts: 1299
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: Different Backups from Crontab to network
Why not use a simple rsync in crontab?
This is keeping my system going for over a year now.
You have to mount the external drive ofcourse. in my case mounted to /mnt/syno
Code: Select all
crontab -e
Code: Select all
# Version 15-12-2014:
3 * * * * rsync -r -t --delete /home/pi/domoticz /mnt/syno/Domoticz
You have to mount the external drive ofcourse. in my case mounted to /mnt/syno
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
-
- Posts: 27
- Joined: Thursday 15 January 2015 9:51
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Different Backups from Crontab to network
Hi guys,
I am trying to establish a connection with my Synology via SFTP to upload my backups. Via Filezilla, I can get a working connection, but via the script, I got the following output when executing my script via CLI. I'm certain that the problem lies with the authentication of fingerprint/keys, but I don't know how to put this in my script.
Line in script:
CLI output:
I hope that someone can help me out.
I am trying to establish a connection with my Synology via SFTP to upload my backups. Via Filezilla, I can get a working connection, but via the script, I got the following output when executing my script via CLI. I'm certain that the problem lies with the authentication of fingerprint/keys, but I don't know how to put this in my script.
Line in script:
Code: Select all
curl -s --disable-epsv -v -T"/tmp/$BACKUPFILEGZ" -u"$USERNAME:$PASSWORD" "sftp://$SERVER/Domoticz/Backups/DB/"
Code: Select all
* About to connect() to 192.168.XX.XX port 22 (#0)
* Trying 192.168.XX.XX...
* connected
* Connected to 192.168.XX.XX (192.168.XX.XX) port 22 (#0)
* SFTP 0x9a50a8 state change from SSH_STOP to SSH_INIT
* SFTP 0x9a50a8 state change from SSH_INIT to SSH_S_STARTUP
* SFTP 0x9a50a8 state change from SSH_S_STARTUP to SSH_HOSTKEY
* SSH MD5 fingerprint: MyFingerprint
* SSH host check: 2, key: <none>
* SFTP 0x9a50a8 state change from SSH_HOSTKEY to SSH_SESSION_FREE
* SFTP 0x9a50a8 state change from SSH_SESSION_FREE to SSH_STOP
* SSH DISCONNECT starts now
* SSH DISCONNECT is done
* Closing connection #0
* SSL peer certificate or SSH remote key was not OK
-
- Posts: 890
- Joined: Tuesday 30 September 2014 8:49
- Target OS: Linux
- Domoticz version: beta
- Location: The Netherlands
- Contact:
Re: Different Backups from Crontab to network
Just posting my script here, maybe someone can use it. It creates a backup of the database, the www folder (i have custom frontpage.html for my tablet in it) and the scripts folder.
It is based on locations on my NAS, and the backups are also stored on this same NAS.
The backup is just stored as a .db file, the two folders (www & script) are compressed in a .tar.gz file. I prefer .zip, but have not yet found out how to configure the 'tar' parameters.
I run it every evening at 23:55 by a cronjob:
It is based on locations on my NAS, and the backups are also stored on this same NAS.
Code: Select all
#!/bin/bash
DOMO_IP="192.168.4.4" # Domoticz IP
DOMO_PORT="8084" # Domoticz port
### END OF USER CONFIGURABLE PARAMETERS
TIMESTAMP=`/bin/date +%Y%m%d%H%M%S`
BACKUPFILE="domoticzbackup_$TIMESTAMP.db" # backups will be named "domoticz_YYYYMMDDHHMMSS.db.gz"
BACKUPFILEGZ="$BACKUPFILE".gz
#Create backup and make tar archives
/usr/bin/curl -s http://$DOMO_IP:$DOMO_PORT/backupdatabase.php > /volume1/dataschijf/Domoticz_backup/database/$BACKUPFILE
tar -zcvf /volume1/dataschijf/Domoticz_backup/scripts/domoticz_scripts_$TIMESTAMP.tar.gz /volume1/@appstore/domoticz/var/scripts/
tar -zcvf /volume1/dataschijf/Domoticz_backup/www/domoticz_wwwfolder_$TIMESTAMP.tar.gz /volume1/@appstore/domoticz/www/
#Delete backups older than 31 days
/usr/bin/find /volume1/dataschijf/Domoticz_backup/database/ -name '*.db' -mtime +31 -delete
/usr/bin/find /volume1/dataschijf/Domoticz_backup/scripts/ -name '*.tar.gz' -mtime +31 -delete
/usr/bin/find /volume1/dataschijf/Domoticz_backup/www/ -name '*.tar.gz' -mtime +31 -delete
I run it every evening at 23:55 by a cronjob:
Code: Select all
55 23 * * * root sh /volume1/@appstore/domoticz/var/scripts/bash/domobackup.sh
Last edited by ThinkPad on Friday 24 July 2015 17:00, edited 1 time in total.
Reason: Forgot to add cronjob
Reason: Forgot to add cronjob
I am not active on this forum anymore.
- kraades
- Posts: 36
- Joined: Wednesday 24 June 2015 9:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: The Netherlands
- Contact:
Re: Different Backups from Crontab to network
Maybe you can use gzip/gzunzip instead.ThinkPad wrote:The backup is just stored as a .db file, the two folders (www & script) are compressed in a .tar.gz file. I prefer .zip, but have not yet found out how to configure the 'tar' parameters.
-
- Posts: 625
- Joined: Thursday 02 October 2014 6:36
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.2
- Location: Geleen
- Contact:
Re: Different Backups from Crontab to network
Why do you want zip? A program like 7zip on Windows reads tar & zip/gzip etc.
-
- Posts: 890
- Joined: Tuesday 30 September 2014 8:49
- Target OS: Linux
- Domoticz version: beta
- Location: The Netherlands
- Contact:
Re: Different Backups from Crontab to network
True, but .zip is native supported on all operating systems, including Android. On my PC i have 7-zip indeed.
It is not that important, but i would prefer zip over tar.gz.
It is not that important, but i would prefer zip over tar.gz.
I am not active on this forum anymore.
- G3rard
- Posts: 669
- Joined: Wednesday 04 March 2015 22:15
- Target OS: -
- Domoticz version: No
- Location: The Netherlands
- Contact:
Re: Different Backups from Crontab to network
Thanks, I am using this script to backup the files to Onedrive via CloudSync (encrypted since one of the last updates).ThinkPad wrote:Just posting my script here, maybe someone can use it. It creates a backup of the database, the www folder (i have custom frontpage.html for my tablet in it) and the scripts folder.
It is based on locations on my NAS, and the backups are also stored on this same NAS.
The backup is just stored as a .db file, the two folders (www & script) are compressed in a .tar.gz file. I prefer .zip, but have not yet found out how to configure the 'tar' parameters.Code: Select all
#!/bin/bash DOMO_IP="192.168.4.4" # Domoticz IP DOMO_PORT="8084" # Domoticz port ### END OF USER CONFIGURABLE PARAMETERS TIMESTAMP=`/bin/date +%Y%m%d%H%M%S` BACKUPFILE="domoticzbackup_$TIMESTAMP.db" # backups will be named "domoticz_YYYYMMDDHHMMSS.db.gz" BACKUPFILEGZ="$BACKUPFILE".gz #Create backup and make tar archives /usr/bin/curl -s http://$DOMO_IP:$DOMO_PORT/backupdatabase.php > /volume1/dataschijf/Domoticz_backup/database/$BACKUPFILE tar -zcvf /volume1/dataschijf/Domoticz_backup/scripts/domoticz_scripts_$TIMESTAMP.tar.gz /volume1/@appstore/domoticz/var/scripts/ tar -zcvf /volume1/dataschijf/Domoticz_backup/www/domoticz_wwwfolder_$TIMESTAMP.tar.gz /volume1/@appstore/domoticz/www/ #Delete backups older than 31 days /usr/bin/find /volume1/dataschijf/Domoticz_backup/database/ -name '*.db' -mtime +31 -delete /usr/bin/find /volume1/dataschijf/Domoticz_backup/scripts/ -name '*.tar.gz' -mtime +31 -delete /usr/bin/find /volume1/dataschijf/Domoticz_backup/www/ -name '*.tar.gz' -mtime +31 -delete
I run it every evening at 23:55 by a cronjob:Code: Select all
55 23 * * * root sh /volume1/@appstore/domoticz/var/scripts/bash/domobackup.sh
Not using Domoticz anymore
-
- Posts: 27
- Joined: Thursday 15 January 2015 9:51
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Different Backups from Crontab to network
This is what I still needed. Thanks!ThinkPad wrote:Just posting my script here, maybe someone can use it. It creates a backup of the database, the www folder (i have custom frontpage.html for my tablet in it) and the scripts folder.
It is based on locations on my NAS, and the backups are also stored on this same NAS.
Code: Select all
#Delete backups older than 31 days /usr/bin/find /volume1/dataschijf/Domoticz_backup/database/ -name '*.db' -mtime +31 -delete /usr/bin/find /volume1/dataschijf/Domoticz_backup/scripts/ -name '*.tar.gz' -mtime +31 -delete /usr/bin/find /volume1/dataschijf/Domoticz_backup/www/ -name '*.tar.gz' -mtime +31 -delete
I am running Domoticz on a RPi and I store the backups on my Synology. A little problem that I am having is that it is searching for this directory on my RPi, which obviously cannot be found because this dir is located on my NAS. For now I am running this command on my NAS, but I would like to implement this in the backup script that I use on my RPi.
Does anyone know how to easily do this?
-
- Posts: 890
- Joined: Tuesday 30 September 2014 8:49
- Target OS: Linux
- Domoticz version: beta
- Location: The Netherlands
- Contact:
Re: Different Backups from Crontab to network
Maybe a nice tip, for uploading doorbell snapshots to Dropbox i used this script a while: https://github.com/andreafabrizi/Dropbox-Uploader
I had it running on my Raspberry, which worked fine. On my Synology NAS it doesn't work because it needs a real 'Bash' shell, Synology only has 'ash' which won't work according to the author of the script. But i now use the 'Cloud Sync' package on my NAS
But it might be useful to upload backups (.tar.gz) to Dropbox.... Benefit is that you also have version history with Dropbox.
Downside is that you can't do the auto-removal of old backups with this script, it can only push files to Dropbox, it doesn't work like a directory like on your PC.
I still use my backup script url this post. Saved my life already a few times
I had it running on my Raspberry, which worked fine. On my Synology NAS it doesn't work because it needs a real 'Bash' shell, Synology only has 'ash' which won't work according to the author of the script. But i now use the 'Cloud Sync' package on my NAS
But it might be useful to upload backups (.tar.gz) to Dropbox.... Benefit is that you also have version history with Dropbox.
Downside is that you can't do the auto-removal of old backups with this script, it can only push files to Dropbox, it doesn't work like a directory like on your PC.
I still use my backup script url this post. Saved my life already a few times
I am not active on this forum anymore.
-
- Posts: 228
- Joined: Thursday 21 May 2015 9:08
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Contact:
Re: Different Backups from Crontab to network
I wish i could backup the WWW and Script folder. But i dont have a NAS server. I changed your script with my location but nothing happens.ThinkPad wrote:Just posting my script here, maybe someone can use it. It creates a backup of the database, the www folder (i have custom frontpage.html for my tablet in it) and the scripts folder.
It is based on locations on my NAS, and the backups are also stored on this same NAS.
The backup is just stored as a .db file, the two folders (www & script) are compressed in a .tar.gz file. I prefer .zip, but have not yet found out how to configure the 'tar' parameters.Code: Select all
#!/bin/bash DOMO_IP="192.168.4.4" # Domoticz IP DOMO_PORT="8084" # Domoticz port ### END OF USER CONFIGURABLE PARAMETERS TIMESTAMP=`/bin/date +%Y%m%d%H%M%S` BACKUPFILE="domoticzbackup_$TIMESTAMP.db" # backups will be named "domoticz_YYYYMMDDHHMMSS.db.gz" BACKUPFILEGZ="$BACKUPFILE".gz #Create backup and make tar archives /usr/bin/curl -s http://$DOMO_IP:$DOMO_PORT/backupdatabase.php > /volume1/dataschijf/Domoticz_backup/database/$BACKUPFILE tar -zcvf /volume1/dataschijf/Domoticz_backup/scripts/domoticz_scripts_$TIMESTAMP.tar.gz /volume1/@appstore/domoticz/var/scripts/ tar -zcvf /volume1/dataschijf/Domoticz_backup/www/domoticz_wwwfolder_$TIMESTAMP.tar.gz /volume1/@appstore/domoticz/www/ #Delete backups older than 31 days /usr/bin/find /volume1/dataschijf/Domoticz_backup/database/ -name '*.db' -mtime +31 -delete /usr/bin/find /volume1/dataschijf/Domoticz_backup/scripts/ -name '*.tar.gz' -mtime +31 -delete /usr/bin/find /volume1/dataschijf/Domoticz_backup/www/ -name '*.tar.gz' -mtime +31 -delete
I run it every evening at 23:55 by a cronjob:Code: Select all
55 23 * * * root sh /volume1/@appstore/domoticz/var/scripts/bash/domobackup.sh
Code: Select all
#!/bin/bash
# LOCAL/FTP/SCP/MAIL PARAMETERS
SERVER="192.168.1.1" # IP of Network disk, used for ftp
USERNAME="myuser" # FTP username of Network disk used for ftp
PASSWORD="Myspasswrd" # FTP password of Network disk used for ftp
DESTDIR="/opt/backup" # used for temorarily storage
DOMO_IP="DOMO_ip" # Domoticz IP
DOMO_PORT="DOMO_port" # Domoticz port
### END OF USER CONFIGURABLE PARAMETERS
TIMESTAMP=`/bin/date +%Y%m%d%H%M%S`
BACKUPFILE="domoticz_$TIMESTAMP.db" # backups will be named "domoticz_YYYYMMDDHHMMSS.db.gz"
BACKUPFILEGZ="$BACKUPFILE".gz
### Create backup and ZIP it
/usr/bin/curl -s http://$DOMO_IP:$DOMO_PORT/backupdatabase.php > /tmp/$BACKUPFILE
gzip -9 /tmp/$BACKUPFILE
tar -zcvf /Seagate_Expansion_Drive/Domoticz/scripts/domoticz_scripts_$TIMESTAMP.tar.gz /home/pi/domoticz/scripts
tar -zcvf /Seagate_Expansion_Drive/Domoticz/domoticz_wwwfolder_$TIMESTAMP.tar.gz /home/pi/domoticz/www
### Send to Network disk through FTP
curl -s --disable-epsv -v -T"/tmp/$BACKUPFILEGZ" -u"$USERNAME:$PASSWORD" "ftp://$SERVER/Seagate_Expansion_Drive/Domoticz/"
### Remove temp backup file
/bin/rm /tmp/$BACKUPFILEGZ
### Done!
-
- Posts: 890
- Joined: Tuesday 30 September 2014 8:49
- Target OS: Linux
- Domoticz version: beta
- Location: The Netherlands
- Contact:
Re: Different Backups from Crontab to network
Sorry, can't help you. I don't use FTP so i don't know how to modify it to reflect to your situationJustintime wrote:I wish i could backup the WWW and Script folder. But i dont have a NAS server. I changed your script with my location but nothing happens.ThinkPad wrote:Just posting my script here, maybe someone can use it. It creates a backup of the database, the www folder (i have custom frontpage.html for my tablet in it) and the scripts folder.
It is based on locations on my NAS, and the backups are also stored on this same NAS.
[...]
[...]
I am not active on this forum anymore.
-
- Posts: 9
- Joined: Tuesday 17 November 2015 21:26
- Target OS: -
- Domoticz version:
- Location: The Netherlands
- Contact:
Re: Different Backups from Crontab to network
With this script, I keep an error.
I have no idea just what goes wrong
If i run: sudo domoticz_backup.sh the error i get is:
The information what i used is the following:
Do does anyone know where it is likely to go wrong?
I have no idea just what goes wrong
If i run: sudo domoticz_backup.sh the error i get is:
Code: Select all
sudo: domoticz_backup.sh: command not found
Code: Select all
#!/bin/bash
# LOCAL/FTP/SCP/MAIL PARAMETERS
SERVER="IP-ADDRESS Network Disk" # IP of Network disk, used for: ftp mail scp
USERNAME="username" # FTP username of Network disk used for: ftp mail scp
PASSWORD="password" # FTP password of Network disk used for: f$
DESTDIR="" # used for: local
DOMO_IP="IP-ADRESS Domoticz" # Domoticz IP used for all
DOMO_PORT="8080" # Domoticz port used for all
### END OF USER CONFIGURABLE PARAMETERS
TIMESTAMP=`/bin/date +%Y%m%d%H%M%S`
BACKUPFILE="domoticz_$TIMESTAMP.db"
BACKUPFILEGZ="$BACKUPFILE".gz
Who is online
Users browsing this forum: No registered users and 1 guest