Page 1 of 1
Domoticz reinstall on USB drive; how to keep switch settings
Posted: Friday 25 December 2015 12:03
by Dutchsea
Hi,
I am going to do a fresh reinstall of Raspbian and Domoticz on my Pi. I have been tinkering with it (including accidently power losses) as the newby I am and feel its not 100% healthy anymore.
Its not going to be a install on top of the existing Domoticz as I plan to do the new install on a USB drive while its now on the Memory card.
I'd like to keep all settings of the switches somehow. I have read there is a database with the settings but I have not been able to find its location.
Can someone tell me what files I should save and copy to the new installed Domoticz?
Thx
Re: Domoticz reinstall on USB drive; how to keep switch sett
Posted: Friday 25 December 2015 17:32
by SweetPants
Setup->Settings->Backup/Restore
Save the database and if you are finished installing, restore it
Re: Domoticz reinstall on USB drive; how to keep switch sett
Posted: Saturday 26 December 2015 0:09
by nayr
domoticz.db in the root of your install, or through the gui using backup/restore.
Re: Domoticz reinstall on USB drive; how to keep switch sett
Posted: Saturday 26 December 2015 0:41
by Dutchsea
That easy

, thx both.
Re: Domoticz reinstall on USB drive; how to keep switch sett
Posted: Monday 28 December 2015 11:30
by TazDevl
I'm switching to usb after my SD got corrupted again, think my psu (big apple charger) isn't as stable as expected...
Hope I can revive the SD card enough to copy the .db file

Re: Domoticz reinstall on USB drive; how to keep switch sett
Posted: Monday 28 December 2015 17:48
by nayr
beware of counterfeit SD cards, they just keep writing over the same small bit of flash continuously so they appear bigger then they are.. of course this corrupts everything.
even legit sd cards I went through a few before I found one reliable enough for being a domoticz appliance.. I am using Samsung Pro cards now after having both Sandisk and Kingston uSD crap out on me in short order.
Re: Domoticz reinstall on USB drive; how to keep switch sett
Posted: Monday 28 December 2015 18:22
by NietGiftig
nayr wrote: I am using Samsung Pro cards now after having both Sandisk and Kingston uSD crap out on me in short order.
I'm using a small SSD in an USB enclosure.
Until now no problems.
Re: Domoticz reinstall on USB drive; how to keep switch sett
Posted: Monday 28 December 2015 18:56
by Egregius
What is the difference between SD Card and USB stick? Aren't they the same?
Re: Domoticz reinstall on USB drive; how to keep switch sett
Posted: Monday 28 December 2015 23:10
by nayr
SD card dont have to go through the USB bus, its potentially faster than USB 2.0.. I dunno what the Pi's bus speeds are but my CuBox can definitely see higher speeds off microsd than usb..
in my case the SD card is for boot and main OS, all heavy writing is done to a 4TB eSata.. but its mostly just ftp storage for my IP cams.
Re: Domoticz reinstall on USB drive; how to keep switch sett
Posted: Wednesday 30 December 2015 20:15
by Dutchsea
Egregius wrote:What is the difference between SD Card and USB stick? Aren't they the same?
Been reading various post that Raspian on USB is more stable and as a bonus much faster.
So expect the same applies to Domoticz on Rasbian on USB
Re: Domoticz reinstall on USB drive; how to keep switch sett
Posted: Wednesday 30 December 2015 21:11
by Egregius
What I mainly meant whas: why would a SD card get corrupted and an USB stick doesn't?
About speed... You made me think
What is you put all files upon boot in a ramdrive and sync them regularly to sd card? Wouldn't that be a big speed improvement?
Re: Domoticz reinstall on USB drive; how to keep switch sett
Posted: Wednesday 30 December 2015 21:28
by Dutchsea
Googling shows different views as to why. Drivers, power supply, smaller memory cores (i doubt this), karma...
A discussion here
https://www.raspberrypi.org/forums/view ... 62&t=83346
Some of the driver issues may have been fixed by now.
Maybe stability aint an issue anymore but its a fun project.
Re: Domoticz reinstall on USB drive; how to keep switch sett
Posted: Wednesday 30 December 2015 21:41
by Egregius
Hmm, no noticable speed difference between running domoticz from SD or from tmpfs. Timigs are exactly the same: 0,097 seconds to read status of 60 devices of a floorplan thru json api.
So I'm not going to look any further for running from memory.
Re: Domoticz reinstall on USB drive; how to keep switch sett
Posted: Wednesday 30 December 2015 21:51
by Dutchsea
Nice test. Indeed shows there is no dif.
For reference, article which was my starting point. No reasons/proof provided for better speed/stability.
Just took it for granted.
http://raspipress.com/2013/05/install-a ... ash-drive/
Re: Domoticz reinstall on USB drive; how to keep switch settings
Posted: Sunday 27 November 2016 13:05
by dbldutch
Although this is a pretty old post right now, I thought to document what I just did to make the change from the SD to a USB drive work. I had to collect information from several places.
This is my first post on this forum, so please bare with me.
I used an 8MB mini USB stick, and wanted to have Domoticz run exclusively from that stick.
Warning:
Don't be tempted to install and use usbmount, I lost a few hours trying to get the access rights working, but failed doing that.
Mounting the USB drive:
Find out what the UUID is: (safer than using sda1 or 2)
ls -l /dev/disk/by-uuid
Depending on the format, you either get a very long string, or a short one like this : 66C8-1C51
You can try to mount this first with:
sudo mount UUID=66C8-1C51 /mnt/usb -o uid=pi,gid=pi
The uid and gid bits are important in order to get user access to the drive later on.
Use
df
to see if it worked. You should get something like this:
/dev/sda1 7817216 26692 7790524 1% /mnt/usb
Check the ownership rights:
ls -al /mnt/usb
If that works, unmount the drive again with:
umount /dev/sda1
Find out what the format of the USB drive is:
df -T
And make a note.
To mount the drive at boot time, do this:
sudo nano /etc/fstab
And add this:
# USB stick
UUID=66C8-1C51 /mnt/usb vfat defaults,umask=000,uid=pi,gid=pi 0 2
vfat is the format that was reported with df -T
The additional umask will set everything on (rwxrwxrwx), you can modify that if you want.
You can reboot the Pi now to see if it all worked.
Now copy the domoticz installation in /home/pi to the USB disk: (you may have to install rsync first)
rsync -rlptDOv /home/pi/domoticz /mnt/usb --owner --group
--owner and --group will maintain the original rights.
Although I did not see any effects when I tried, I still modified this file, just in case:
sudo nano setupVars.conf
change the directory from /home/pi/domoticz to /mnt/usb/domoticz
Preserve an original copy of the startup script:
sudo cp /etc/init.d/domoticz.sh /etc/init.d/domoticz.orig
Now modify the startup script:
sudo nano /etc/init.d/domoticz.sh
Change the following:
DAEMON=/mnt/usb/domoticz/$NAME
#DAEMON=/home/pi/domoticz/$NAME
Update the systemd environment:
sudo systemctl daemon-reload
Restart the domoticz server:
service domoticz.sh restart
Check it, if all went well, reboot the Pi and check again.
Enjoy!
Re: Domoticz reinstall on USB drive; how to keep switch settings
Posted: Sunday 19 February 2017 19:55
by pvklink
I followed the below procedure from this forum to move domotics to an usb stick.
ls -l /dev/disk/by-uuid
sudo mkdir /media/usb1
sudo mount UUID=E9B1-43F0 /media/usb1 -o uid=pi,gid=pi
DF
You should get something like this:
/dev/sda1 7817216 26692 7790524 1% /media/usb1
Check the ownership rights:
ls -al /media/usb1
If that works, unmount the drive again with:
sudo umount /dev/sda1
Find out what the format of the USB drive is:
df -T
And make a note.
To mount the drive at boot time, do this:
sudo nano /rsyncetc/fstab
And add this:
# USB stick
UUID=E9B1-43F0 /media/usb1 vfat defaults,umask=000,uid=pi,gid=pi 0 2
vfat is the format that was reported with df -T
The additional umask will set everything on (rwxrwxrwx), you can modify that if you want.
You can reboot the Pi now to see if it all worked.
Now copy the domoticz installation in /home/pi to the USB disk:
rsync -rlptDOv /home/pi/domoticz /media/usb1 --owner --group
Although I did not see any effects when I tried, I still modified this file, just in case:
sudo nano setupVars.conf
change the directory from /home/pi/domoticz to /media/usb1/domoticz
@pvk does not exist
Preserve an original copy of the startup script:
sudo cp /etc/init.d/domoticz.sh /etc/init.d/domoticz.orig
Now modify the startup script:
sudo nano /etc/init.d/domoticz.sh
Change the following:
DAEMON=/media/usb1/domoticz/$NAME
#DAEMON=/home/pi/domoticz/$NAME
Update the systemd environment:
sudo systemctl daemon-reload
@pvk gives an error
Restart the domoticz server:
service domoticz.sh restart
@pvk gives an error: "could not open lock file /var/run/domoticz.pid, I rebooted the machine, everything seems to work!
I did get a couple of errors:
1) sudo nano setupVars.conf does not exist
2) sudo systemctl daemon-reload gives an error
3) service domoticz.sh restart gives an error: "could not open lock file /var/run/domoticz.pid,
I rebooted the machine, everything seems to work!
I missed one command in these procedure, to delete the old domoticz folder!
Are these errors a problem, otherwise a try to delete the original domoticz folder...