Change Database location Raspberry Pi

On various Hardware and OS systems: pi / windows / routers / nas, etc
Post Reply
Preko
Posts: 1
Joined: Thursday 16 November 2017 20:38
Target OS: Raspberry Pi
Domoticz version:
Contact:

Change Database location Raspberry Pi

Post by Preko » Thursday 16 November 2017 20:43

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 ...

Orionos
Posts: 6
Joined: Friday 15 December 2017 21:29
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Change Database location Raspberry Pi

Post by Orionos » Tuesday 02 January 2018 20:43

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.

User avatar
EddyG
Posts: 278
Joined: Monday 02 November 2015 6:54
Target OS: Raspberry Pi
Domoticz version: 4.9788
Location: Rhenen, Netherlands
Contact:

Re: Change Database location Raspberry Pi

Post by EddyG » Tuesday 02 January 2018 21:02

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.
Regards,
Eddy

ben53252642
Posts: 418
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Change Database location Raspberry Pi

Post by ben53252642 » Tuesday 02 January 2018 21:04

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

User avatar
EddyG
Posts: 278
Joined: Monday 02 November 2015 6:54
Target OS: Raspberry Pi
Domoticz version: 4.9788
Location: Rhenen, Netherlands
Contact:

Re: Change Database location Raspberry Pi

Post by EddyG » Tuesday 02 January 2018 21:13

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.
Regards,
Eddy

albercola
Posts: 10
Joined: Monday 19 February 2018 19:15
Target OS: Windows
Domoticz version:
Contact:

Re: Change Database location Raspberry Pi

Post by albercola » 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?

User avatar
waaren
Posts: 807
Joined: Tuesday 03 January 2017 15:18
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Change Database location Raspberry Pi

Post by waaren » Sunday 29 April 2018 22:32

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.
Raspberry (debian stretch via berryboot on Synology DS916+) , Domoticz (almost) latest Beta, , dzVents 2.6, RFLink, RFXtrx433e, P1, Youless, Harmony, Hue, Yeelight, Xiaomi, HomeWizard, Zwave, Amazon echo

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 0 guests