Page 2 of 5
Re: Different Backups from Crontab to network
Posted: Sunday 08 December 2013 15:32
by leonardo
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!
Re: Different Backups from Crontab to network
Posted: Wednesday 11 December 2013 22:10
by remb0
[solved] nice.
Re: Different Backups from Crontab to network
Posted: Thursday 12 December 2013 21:31
by Derik
and counting:
- ScreenShot108.jpg (89.67 KiB) Viewed 8082 times
Re: Different Backups from Crontab to network
Posted: Monday 23 December 2013 1:04
by Derik
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 ..
Re: Different Backups from Crontab to network
Posted: Monday 06 October 2014 16:02
by schmm
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
Different Backups from Crontab to network
Posted: Friday 13 March 2015 17:22
by LJ80
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?
Re: Different Backups from Crontab to network
Posted: Wednesday 25 March 2015 21:01
by jjnj
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
Re: Different Backups from Crontab to network
Posted: Saturday 23 May 2015 21:50
by sschouten
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.
Re: Different Backups from Crontab to network
Posted: Sunday 24 May 2015 21:24
by sincze
Why not use a simple rsync in crontab?
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
Re: Different Backups from Crontab to network
Posted: Wednesday 27 May 2015 12:05
by Skorpion
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.
Re: Different Backups from Crontab to network
Posted: Friday 24 July 2015 16:58
by ThinkPad
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
Re: Different Backups from Crontab to network
Posted: Saturday 25 July 2015 16:45
by kraades
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.
Re: Different Backups from Crontab to network
Posted: Sunday 26 July 2015 9:36
by jannl
Why do you want zip? A program like 7zip on Windows reads tar & zip/gzip etc.
Re: Different Backups from Crontab to network
Posted: Sunday 26 July 2015 10:46
by ThinkPad
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.
Re: Different Backups from Crontab to network
Posted: Thursday 30 July 2015 0:25
by G3rard
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).
Re: Different Backups from Crontab to network
Posted: Friday 07 August 2015 13:41
by Skorpion
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?
Re: Different Backups from Crontab to network
Posted: Monday 07 September 2015 10:27
by ThinkPad
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
Re: Different Backups from Crontab to network
Posted: Monday 07 September 2015 13:12
by Justintime
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!
Re: Different Backups from Crontab to network
Posted: Monday 07 September 2015 21:06
by ThinkPad
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
Re: Different Backups from Crontab to network
Posted: Tuesday 17 November 2015 21:38
by mdo82
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?