Page 1 of 1

Quick (re)install of Domoticz

Posted: Saturday 25 February 2017 10:32
by Toulon7559
Yesterday my Domoticz on RaspberryB crashed due to a corrupt SD-card.
Means a complete reinstall and setting of the software packages.
;-) There are more useful and mor interesting activities to spend a morning .........

In 'earlier days' we had an SD-image to start, but presently we have to 'manually grab' a selection of designated files from internet.
Not asking that such SD-image returns, but would it be possible to collect the set of installation-procedures in a kind of batch-file, for an automated run for (re)install?
In combination with a shortcut-method to insert backup-files in place from an external drive, (easier) enabling a more or less seamless continuation of the operations/registrations? For example, the reverse direction from these backups.

Re: Quick (re)install of Domoticz

Posted: Saturday 25 February 2017 18:03
by HansieNL
I got a spare sd-card. I know how frustrating it is when the sd-card gets corrupted. I have a backup script that runs in the night and maks a backup on an USB stick.
So if sd-card gets corrupted again it takes only one hour to be back on the road again.

Re: Quick (re)install of Domoticz

Posted: Sunday 26 February 2017 0:40
by edwin1234
Nice,
Could you share that backup script?

Re: Quick (re)install of Domoticz

Posted: Sunday 26 February 2017 8:12
by Toulon7559
@HansieNL
I have a second SD-card as well, because I make 2 copies when I need to reinstall.
But that method implies that I only can start slightly quicker with re-install, not that I am uptodate with that SD-copy: still a lot of work to get back on track.
Is your backup-method to USB-stick one of those documented here?
Otherwise appreciated that you publish your script, or perhaps add it to the indicated Wiki-section.

IMHO backup of the database etc. is not really the issue, because several methods already well-documented.
Making a quick, fresh installation of the 'basic' configuration seems more interesting, in combination with easily restoring the backup-info.

Why a 'fresh' installation desirable?
Because over time with any package of software, some ageing & rubbish & corruption creeps in, which slows down the processing.
;-) And a re-install after a crash is then an opportunity to clean-up and to become most uptodate .........
;-) ;-) Blessing in disguise!

Re: Quick (re)install of Domoticz

Posted: Tuesday 28 February 2017 5:29
by Number8
I have a backup script as well. But you should be very carefull on the version of Domoticz you reinstall. It has to be of the same version as the version that crashed or, most probably, you will not be able to use the DB anymore
In order to avoid SD card wear, I have a USB key on which all logs files are wrote.
And I use high quality SD cards

Here is my script

Code: Select all

#!/bin/bash
SERVER="xxx.xxx.xxx.xxx"	# IP of Network disk, used for ftp
USERNAME="ftpBackup"	# FTP username of Network disk used for ftp
PASSWORD="password"         # FTP password of Network disk used for ftp
DESTDIR="/opt/backup"   	# used for temorarily storage
DOMO_IP="xxx.xxx.xxx.xxx"  	# Domoticz IP 
DOMO_PORT="8080"        	# Domoticz port 

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 dabase backup and ZIP it
/usr/bin/curl -s http://$DOMO_IP:$DOMO_PORT/backupdatabase.php > /tmp/$BACKUPFILE
gzip -9 /tmp/$BACKUPFILE
# Send to Network disk through FTP
curl --silent --disable-epsv --upload-file "/tmp/$BACKUPFILEGZ" -u "$USERNAME:$PASSWORD" "ftp://$SERVER/NetBackup/Domoticz/"  > /dev/null
# Remove temp backup file
/bin/rm /tmp/$BACKUPFILEGZ
/bin/rm /tmp/backup.db

# backup scripts folder
BACKUPFILEDIR="domoticz_folder_$TIMESTAMP.tar.gz" # Change the xxx to yours
# Create backup and ZIP it
# cd to the directory in in order to avoid the message removing leading / from member names
cd /home/pi/domoticz
tar -zcf /tmp/$BACKUPFILEDIR scripts
#Send to Network disk through FTP
curl --silent --disable-epsv --upload-file "/tmp/$BACKUPFILEDIR" -u "$USERNAME:$PASSWORD" "ftp://$SERVER/NetBackup/Domoticz/"  > /dev/null
# Remove temp backup file
/bin/rm /tmp/$BACKUPFILEDIR
# Done!

Re: Quick (re)install of Domoticz

Posted: Thursday 02 March 2017 16:18
by Toulon7559
Being a lazy user, a related question:
would it be possible to periodically backup the complete, actual SD-image to an external drive?

Idea behind it:
if you have an almost uptodate SD-image as backup, in case of corruption (or other calamity) you could restore that image onto an SD-card, switch SD-cards and restart&continue operations ....
;-) Cannot imagine easier & quicker 'repair&restart' than such procedure.
Avoids also the risk mentioned by Number8

Re: Quick (re)install of Domoticz

Posted: Thursday 02 March 2017 16:24
by Number8
Smart idea, no idea how to achieve this though

Re: Quick (re)install of Domoticz

Posted: Thursday 02 March 2017 17:18
by mlamie
Toulon7559 wrote:Being a lazy user, a related question:
would it be possible to periodically backup the complete, actual SD-image to an external drive?

Idea behind it:
if you have an almost uptodate SD-image as backup, in case of corruption (or other calamity) you could restore that image onto an SD-card, switch SD-cards and restart&continue operations ....
;-) Cannot imagine easier & quicker 'repair&restart' than such procedure.
Avoids also the risk mentioned by Number8
Check out:
https://github.com/billw2/rpi-clone

Re: Quick (re)install of Domoticz

Posted: Thursday 02 March 2017 19:05
by Toulon7559
Thanks mlamie for the hint:
even better to make a direct clone-SD-card!
;-) Such hints are the bonus of forums!
For this first line of backup now just have to find an USB-cardreader as annex for my Raspberries.
Probably also a good time to setup a second line of automatic periodic backup towards an external drive.
Better (double) safe than sorry .....

Only 2 small afterthoughts:
1) frequent writing to an SD-card should be prevented, because it reduces lifetime of the SD-card.
Therefore cloning/backup immediately after successful (re)instal and then not more frequent than once a day?
2) cloning should be made with a certain interval, to reduce the risk that a corrupt image is written.
Or is that an imaginary risk, considering that a corruption of the 'primary' SD-card probably will cause a crash (preventing a backup)?