Update resets db file

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!

Moderators: leecollings, remb0

Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post

Please mark your topic as Solved when the problem is solved.
Post Reply
User avatar
Varazir
Posts: 378
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Update resets db file

Post by Varazir »

Version: 2025.1 (build 16675)
Build Hash: 8577ac07c
Compile Date: 2025-05-05 09:45:17
dzVents Version: 3.1.8
Python Version: 3.7.3 (default, Mar 23 2024, 16:12:05) [GCC 8.3.0]

When I update my domoticz the DB is reset to factory, this has happen several times.
I thought was duet to the db files has root permissions so I changed them to the default pi user but same happen.
Lucky I have hourly backup of the db so I could always restore.

Before:
Image

After
Image

This time I did a backup of the db file before I updated.
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
waltervl
Posts: 5733
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Update resets db file

Post by waltervl »

The db should be accessible by the account that is running Domoticz. In your case it should be root.

Edit: And how do you update? By the web use interface or the command prompt (eg sudo ./updaterelease)?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Varazir
Posts: 378
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Update resets db file

Post by Varazir »

waltervl wrote: Monday 05 May 2025 19:44 The db should be accessible by the account that is running Domoticz. In your case it should be root.

Edit: And how do you update? By the web use interface or the command prompt (eg sudo ./updaterelease)?
Tried both web gui and command line same outcome. Today I used web GUI
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
waltervl
Posts: 5733
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Update resets db file

Post by waltervl »

When you import a database backup succesfully from webgui and then update Domoticz from webgui it should (Edit:) not start with an empty database. Then you have to check your permissions.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
gizmocuz
Posts: 2484
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Update resets db file

Post by gizmocuz »

That's indeed odd and should not happen!

I have to assume you installed Domoticz via the 'bash' command? This so the system knows where it is installed.

You also did not modify any parameters of the startup file?

You can check the updatebeta/updaterelease scripts to see what is going on

You don't have to use the hourly backup feature, and maybe here it goes wrong.

The updatebeta/updaterelease script is already making a backup before it updates in the backup folder (see the script)

Do you also use the beta versions?

When you update to the beta version by going to the domoticz folder, and issuing: ./updatebeta, does that also start with a clean database?

You also don't have any scripts running (like rsync) on the domoticz folder?
Quality outlives Quantity!
User avatar
Varazir
Posts: 378
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Update resets db file

Post by Varazir »

Hello,

I have been running this installation several years now and almost always beta.
This issue started few months back.

I haven't checked the script, but the backup tar file do not contain the db file.
That was the first place I checked.

Same happen when I update from console. The db file get "reset".
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
Varazir
Posts: 378
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Update resets db file

Post by Varazir »

waltervl wrote: Tuesday 06 May 2025 0:01 When you import a database backup succesfully from webgui and then update Domoticz from webgui it should (Edit:) not start with an empty database. Then you have to check your permissions.
I restored the db using console.
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
Varazir
Posts: 378
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Update resets db file

Post by Varazir »

gizmocuz wrote: Tuesday 06 May 2025 4:35 That's indeed odd and should not happen!

I have to assume you installed Domoticz via the 'bash' command? This so the system knows where it is installed.

You also did not modify any parameters of the startup file?

You can check the updatebeta/updaterelease scripts to see what is going on

You don't have to use the hourly backup feature, and maybe here it goes wrong.

The updatebeta/updaterelease script is already making a backup before it updates in the backup folder (see the script)

Do you also use the beta versions?

When you update to the beta version by going to the domoticz folder, and issuing: ./updatebeta, does that also start with a clean database?

You also don't have any scripts running (like rsync) on the domoticz folder?
I'll run the script with bash and -v to see what happens.

Only non standard setup I have is that I have mounted the backup folder to my NAS.
So all backup files get saved on my NAS.
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
Varazir
Posts: 378
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Update resets db file

Post by Varazir »

I tried to run it as bash en verbose but didn't give me much
You can see that the db is down to 4MB after update.

Code: Select all

pi@zwave2:~/domoticz $ bash --verbose -c ./updatebeta
./updatebeta
Stopping Domoticz...
Making backup of current installation...
rm: cannot remove 'backups/domoticz_backup_20250426_233138:': No such file or directory
rm: cannot remove 'plugins': Is a directory
rm: cannot remove 'backups/domoticz_backup_20250403_132204:': No such file or directory
rm: cannot remove 'www': Is a directory
rm: cannot remove 'Config': Is a directory
rm: cannot remove 'scripts': Is a directory
rm: cannot remove 'plugins': Is a directory
rm: cannot remove 'dzVents': Is a directory
rm: cannot remove 'ozwcp.poll.XXXXXX.xml': No such file or directory
rm: cannot remove 'updatebeta~': No such file or directory
Output file: backups/domoticz_backup_20250507_202330.tar.gz
Backup finished...
Downloading latest beta version...
Checking file integrity...
Installing new version...
...................................
Starting Domoticz... (please standby...)
Done...
pi@zwave2:~/domoticz $ ls -all
total 13296
drwxr-xr-x   8 pi   pi       4096 May  7 20:24 .
drwxr-xr-x  22 pi   pi       4096 May  7 20:22 ..
drwxrwx---  17 root root     4096 May  7 20:23 backups
drwxr-xr-x 124 pi   pi       4096 Feb 26 15:25 Config
-rwxr-xr-x   1 pi   pi   12285484 May  5 09:46 domoticz
-rw-r-----   1 root root     4096 May  7 20:24 domoticz.db
-rw-r-----   1 root root    32768 May  7 20:24 domoticz.db-shm
-rw-r-----   1 root root  1067112 May  7 20:24 domoticz.db-wal
-rw-r--r--   1 pi   pi       5996 Dec 25 09:57 domoticz.sh
drwxr-xr-x   4 pi   pi       4096 Nov 29  2023 dzVents
-rw-r--r--   1 pi   pi     123003 May  5 09:34 History.txt
-rw-r--r--   1 pi   pi      35147 Nov 29  2023 License.txt
drwxr-xr-x  10 pi   pi       4096 Nov 29  2023 plugins
drwxr-xr-x   9 pi   pi       4096 Jan  5 15:15 scripts
-rw-r--r--   1 pi   pi       3908 May  5 08:32 server_cert.pem
-rwxr-xr-x   1 pi   pi       1810 Jan  2  2024 updatebeta
-rwxr-xr-x   1 pi   pi       1830 Jan  2  2024 updaterelease
drwxr-xr-x  14 pi   pi       4096 Mar  9 09:07 www
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
gizmocuz
Posts: 2484
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Update resets db file

Post by gizmocuz »

There is definitely something wrong with your setup/folder rights

As you can see, it gives lots of remove errors, which should not be there.

Please have a look at the updatebeta script, there are only 2 'rm' commands executed

1, it deletes all backups older then the latest 5
2, it deletes the downloaded (update) archive

As you already said, you mounted something... My advise is, leave everything at default, and then test.

I am quite sure it has something to do with that mount, it should for sure not remove these folders !

Domoticz vacuums the database when making a backup (from the settings page), it also archives/compressed the current database
Quality outlives Quantity!
User avatar
Varazir
Posts: 378
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Update resets db file

Post by Varazir »

gizmocuz wrote: Thursday 08 May 2025 12:01 There is definitely something wrong with your setup/folder rights

As you can see, it gives lots of remove errors, which should not be there.

Please have a look at the updatebeta script, there are only 2 'rm' commands executed

1, it deletes all backups older then the latest 5
2, it deletes the downloaded (update) archive

As you already said, you mounted something... My advise is, leave everything at default, and then test.

I am quite sure it has something to do with that mount, it should for sure not remove these folders !

Domoticz vacuums the database when making a backup (from the settings page), it also archives/compressed the current database
This setup have been working for years, why now ?
I mounted the backups folder and it's excluded from the TAR command.

the error comes from that I untared a backup file. So the script tried to remove the untared folder.
I cleaned up the backup folder so only back folders(hourly/daily/monthly) and the compressed backup file and now the update beta
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
gizmocuz
Posts: 2484
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Update resets db file

Post by gizmocuz »

No idea why it is not working now, nothing has been changed in this process, and you mentioned you had problems before.

Now that you cleaned up your backup folder, does everything work correctly?
If not, could you stop the domoticz service, unmount the backup folder, just leave it as a normal folder, with normal rights
start domoticz, all should still work, then execute the updatebeta script inside the Domoticz folder
It should update, and your database should not be touched!
(The update process does not touch your database)
Quality outlives Quantity!
User avatar
Varazir
Posts: 378
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Update resets db file

Post by Varazir »

gizmocuz wrote: Friday 09 May 2025 8:37 No idea why it is not working now, nothing has been changed in this process, and you mentioned you had problems before.

Now that you cleaned up your backup folder, does everything work correctly?
If not, could you stop the domoticz service, unmount the backup folder, just leave it as a normal folder, with normal rights
start domoticz, all should still work, then execute the updatebeta script inside the Domoticz folder
It should update, and your database should not be touched!
(The update process does not touch your database)
Yes, the update works again after I cleaned up the backup folder.
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest