Quick (re)install of Domoticz

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

Post Reply
Toulon7559
Posts: 859
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Quick (re)install of Domoticz

Post 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.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
User avatar
HansieNL
Posts: 964
Joined: Monday 28 September 2015 15:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Quick (re)install of Domoticz

Post 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.
Blah blah blah
edwin1234
Posts: 287
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: Quick (re)install of Domoticz

Post by edwin1234 »

Nice,
Could you share that backup script?
Toulon7559
Posts: 859
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Quick (re)install of Domoticz

Post 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!
Last edited by Toulon7559 on Wednesday 01 March 2017 12:18, edited 1 time in total.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Number8
Posts: 374
Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:

Re: Quick (re)install of Domoticz

Post 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!
Debian buster on NUC and three RPi with buster.
Toulon7559
Posts: 859
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Quick (re)install of Domoticz

Post 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
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Number8
Posts: 374
Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:

Re: Quick (re)install of Domoticz

Post by Number8 »

Smart idea, no idea how to achieve this though
Debian buster on NUC and three RPi with buster.
User avatar
mlamie
Posts: 122
Joined: Friday 25 October 2013 17:12
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: The Netherlands
Contact:

Re: Quick (re)install of Domoticz

Post 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
Raspberry Pi 3, RaZberry, RFXtrx433
Various Z-Wave devices, KlikAanKlikUit devices, ESP8266 NodeMCU, Sonoff POW and a Essent E-thermostaat
IP camera: Dahua 4MP IPC-HDBW4421R-AS, Vivotek FD8134V
Toulon7559
Posts: 859
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Quick (re)install of Domoticz

Post 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)?
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest