Page 1 of 1

Change Database location Raspberry Pi

Posted: Thursday 16 November 2017 20:43
by Preko
Hello everyone.

I have recently created a Domoticz webserver on a raspberry pi.

I want to change the database location to be not on the SDCard but on a USB KEY (which will be forced to have the same driver number upon rebbot).

1 - is there a way to modify the path ?
2 - is it "acceptable" to do this ?

Thank you all ;)

NB : I have not found a topic / answer related to this question ...

Re: Change Database location Raspberry Pi

Posted: Tuesday 02 January 2018 20:43
by Orionos
I'm surprised nobody answered this. Apparently this community isn't as active as we'd hope. Given the still quite complex nature of Domoticz, I would have expected a lot more whiz-kids. Anyway...

You can easily alter the startup line for domoticz to point to a different file.

In the case of systemd, you'll find a line in the domoticz.service file similar to this:

Code: Select all

ExecStart=/home/domoticz/domoticz/domoticz -www 8080 -sslwww 443 -dbase /home/domoticz/domoticz/domoticz.db
As you can see, the location of your database is just a little startup-option away. Given that it's part of the program, I imagine it's perfectly acceptable.

Important: Make certain the user that runs domoticz has read-write permission on the directory that holds the file. Otherwise, domoticz will boot, but you'll have lots of SQL errors.

Re: Change Database location Raspberry Pi

Posted: Tuesday 02 January 2018 21:02
by EddyG
I am suprised why 'nobody' uses the 'default' linux methode of calling: ./domoticz --help or /home/pi/domoticz/domoticz --help
You see all the parameters you could use on domoticz.

Re: Change Database location Raspberry Pi

Posted: Tuesday 02 January 2018 21:04
by ben53252642
Or you could just use a symbolic link (I use many for making certain files operate from tmpfs reducing writes to the SD card).

Example:

Code: Select all

mkdir -p /tmp/domoticz
ln -sf /tmp/domoticz/domoticz.db-shm /root/domoticz/domoticz.db-shm
ln -sf /tmp/domoticz/domoticz.db-wal /root/domoticz/domoticz.db-wal
ln -sf /tmp/domoticz/ozwcp.poll.XXXXXX.xml /root/domoticz/ozwcp.poll.XXXXXX.xml
ln -sf /tmp/domoticz/ozwcp.scenes.XXXXXX /root/domoticz/ozwcp.scenes.XXXXXX
ln -sf /tmp/domoticz/ozwcp.stat.XXXXXX /root/domoticz/ozwcp.stat.XXXXXX
ln -sf /tmp/domoticz/ozwcp.topo.XXXXXX /root/domoticz/ozwcp.topo.XXXXXX
ln -sf /tmp/domoticz/domocookie.txt /root/domoticz/domocookie.txt
ln -sf /tmp/domoticz/domoticz_beta.tgz /root/domoticz/domoticz_beta.tgz
mkdir -p /tmp/domoticz/Config
ln -sf /tmp/domoticz/Config/OZW_Log.txt /root/domoticz/Config/OZW_Log.txt
service domoticz start

Re: Change Database location Raspberry Pi

Posted: Tuesday 02 January 2018 21:13
by EddyG
It's not a good idea to put the database on a tmpfs, because if you have a power failure or reboot you lose the database.
Why not use the startup parameter to relocate the database, that's what the parameter is intended for.

Re: Change Database location Raspberry Pi

Posted: Sunday 29 April 2018 22:21
by albercola
Hi,

Orionos gave the best solution for my problem. Unfortunately i cannot locate the domoticz.service file.

EddyG gave another good suggestion but i am not able to solve my problem in that way.

Can you please help me?

Re: Change Database location Raspberry Pi

Posted: Sunday 29 April 2018 22:32
by waaren
albercola wrote:
Sunday 29 April 2018 22:21
Hi,

Orionos gave the best solution for my problem. Unfortunately i cannot locate the domoticz.service file.

EddyG gave another good suggestion but i am not able to solve my problem in that way.

Can you please help me?
@albercola,
I use Berryboot . Now I only boot from the sd card and all other IO is done from/to USB or SCSI attached storage. I use my Synology NAS for it with the the additional benefit of being able to have hourly snapshots of my domoticz production system. It saved my data already on a couple of occasions.