Different Backups from Crontab to network

All kinds of 'OS' scripts
leonardo
Posts: 7
Joined: Sunday 21 July 2013 22:04
Target OS: -
Domoticz version:
Contact:

Re: Different Backups from Crontab to network

Post by leonardo » Sunday 08 December 2013 16:32

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!

User avatar
remb0
Posts: 935
Joined: Thursday 11 July 2013 22:21
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Different Backups from Crontab to network

Post by remb0 » Wednesday 11 December 2013 23:10

[solved] nice.
All Domoticz compatible products at shop: https://www.domoticz.com/wiki/Compatibl ... n_gearbest

User avatar
Derik
Posts: 2082
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Different Backups from Crontab to network

Post by Derik » Thursday 12 December 2013 22:31

and counting:
ScreenShot108.jpg
ScreenShot108.jpg (89.67 KiB) Viewed 4365 times
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

User avatar
Derik
Posts: 2082
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Different Backups from Crontab to network

Post by Derik » Monday 23 December 2013 2:04

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 .. ;) ;)
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

schmm
Posts: 36
Joined: Monday 29 September 2014 21:28
Target OS: Raspberry Pi
Domoticz version:
Location: Weert (Netherlands)
Contact:

Re: Different Backups from Crontab to network

Post by schmm » Monday 06 October 2014 16:02

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

LJ80
Posts: 49
Joined: Wednesday 14 January 2015 22:49
Target OS: Raspberry Pi
Domoticz version:
Contact:

Different Backups from Crontab to network

Post by LJ80 » Friday 13 March 2015 18:22

I followed all steps from the wiki but wen I am at the step for testing I get this message back:

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
What have I done wrong or what am i missing?

jjnj
Posts: 240
Joined: Thursday 31 July 2014 13:51
Target OS: Windows
Domoticz version:
Location: NL
Contact:

Re: Different Backups from Crontab to network

Post by jjnj » Wednesday 25 March 2015 22:01

LJ80 wrote:Hi all,

I followed all steps from the wiki but wen I am at the step for testing I get this message back:

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
What have I done wrong or what am i missing?
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/backup

sschouten
Posts: 6
Joined: Thursday 23 April 2015 13:54
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Different Backups from Crontab to network

Post by sschouten » Saturday 23 May 2015 21:50

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.

User avatar
sincze
Posts: 906
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi
Domoticz version: 3.8875
Location: Netherlands
Contact:

Re: Different Backups from Crontab to network

Post by sincze » Sunday 24 May 2015 21:24

Why not use a simple rsync in crontab?

Code: Select all

crontab -e

Code: Select all

# Version 15-12-2014:

3 * * * * rsync -r -t --delete /home/pi/domoticz /mnt/syno/Domoticz
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
Using Pass2php since 2016-12
LAN: RFLink, P1-Port, OTGW, MySensors
USB: RFXCom, ZWave
WIFI: Mi-light Wifi-Bridge, Sonoff, ESP8266, Xiaomi Gateway
Solar: Omnik Inverter, PVOutput
Video: Kodi clients with Harmony HUB
Sensors: You name it I probably got 1.

Skorpion
Posts: 33
Joined: Thursday 15 January 2015 10:51
Target OS: Raspberry Pi
Domoticz version:
Location: The Netherlands
Contact:

Re: Different Backups from Crontab to network

Post by Skorpion » Wednesday 27 May 2015 12:05

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:

Code: Select all

curl -s --disable-epsv -v -T"/tmp/$BACKUPFILEGZ" -u"$USERNAME:$PASSWORD" "sftp://$SERVER/Domoticz/Backups/DB/"
CLI output:

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
I hope that someone can help me out.

User avatar
ThinkPad
Posts: 1754
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Different Backups from Crontab to network

Post by ThinkPad » Friday 24 July 2015 16:58

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

#!/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
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:

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
ThinkTheme - theme for Domoticz
My (Dutch) blog: http://thinkpad.tweakblogs.net - My Domoticz scripts: Bitbucket
I'm not (very) active anymore on this forum as i don't use Domoticz anymore.

User avatar
kraades
Posts: 37
Joined: Wednesday 24 June 2015 9:47
Target OS: Raspberry Pi
Domoticz version: Stable
Location: The Netherlands
Contact:

Re: Different Backups from Crontab to network

Post by kraades » Saturday 25 July 2015 16:45

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.
Maybe you can use gzip/gzunzip instead.

User avatar
jannl
Posts: 955
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Geleen
Contact:

Re: Different Backups from Crontab to network

Post by jannl » Sunday 26 July 2015 9:36

Why do you want zip? A program like 7zip on Windows reads tar & zip/gzip etc.

User avatar
ThinkPad
Posts: 1754
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Different Backups from Crontab to network

Post by ThinkPad » Sunday 26 July 2015 10:46

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.
ThinkTheme - theme for Domoticz
My (Dutch) blog: http://thinkpad.tweakblogs.net - My Domoticz scripts: Bitbucket
I'm not (very) active anymore on this forum as i don't use Domoticz anymore.

User avatar
G3rard
Posts: 827
Joined: Wednesday 04 March 2015 23:15
Target OS: Linux
Domoticz version: V3.8153
Location: The Netherlands
Contact:

Re: Different Backups from Crontab to network

Post by G3rard » Thursday 30 July 2015 0:25

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

#!/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
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:

Code: Select all

55      23      *       *       *       root    sh      /volume1/@appstore/domoticz/var/scripts/bash/domobackup.sh
Thanks, I am using this script to backup the files to Onedrive via CloudSync (encrypted since one of the last updates).
Ubuntu Server 14.04 | Domoticz v3.8153 | RFXtrx433E | Z-Wave Aeotec Z-Stick S2
Frontpage | Sonos PHP | Dark th3me | Sony Bravia Python plugin | Sonos Python plugin

Skorpion
Posts: 33
Joined: Thursday 15 January 2015 10:51
Target OS: Raspberry Pi
Domoticz version:
Location: The Netherlands
Contact:

Re: Different Backups from Crontab to network

Post by Skorpion » Friday 07 August 2015 13:41

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
This is what I still needed. Thanks!

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?

User avatar
ThinkPad
Posts: 1754
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Different Backups from Crontab to network

Post by ThinkPad » Monday 07 September 2015 10:27

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 :lol:
ThinkTheme - theme for Domoticz
My (Dutch) blog: http://thinkpad.tweakblogs.net - My Domoticz scripts: Bitbucket
I'm not (very) active anymore on this forum as i don't use Domoticz anymore.

Justintime
Posts: 319
Joined: Thursday 21 May 2015 9:08
Target OS: Raspberry Pi
Domoticz version: Beta
Contact:

Re: Different Backups from Crontab to network

Post by Justintime » Monday 07 September 2015 13:12

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

#!/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
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:

Code: Select all

55      23      *       *       *       root    sh      /volume1/@appstore/domoticz/var/scripts/bash/domobackup.sh
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.

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!	

User avatar
ThinkPad
Posts: 1754
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Different Backups from Crontab to network

Post by ThinkPad » Monday 07 September 2015 21:06

Justintime wrote:
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 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.
[...]
Sorry, can't help you. I don't use FTP so i don't know how to modify it to reflect to your situation :(
ThinkTheme - theme for Domoticz
My (Dutch) blog: http://thinkpad.tweakblogs.net - My Domoticz scripts: Bitbucket
I'm not (very) active anymore on this forum as i don't use Domoticz anymore.

mdo82
Posts: 13
Joined: Tuesday 17 November 2015 22:26
Target OS: -
Domoticz version:
Location: The Netherlands
Contact:

Re: Different Backups from Crontab to network

Post by mdo82 » Tuesday 17 November 2015 22:38

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:

Code: Select all

sudo: domoticz_backup.sh: command not found
The information what i used is the following:

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
Do does anyone know where it is likely to go wrong?

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests