Page 1 of 1

Update resets db file

Posted: Monday 05 May 2025 19:13
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.

Re: Update resets db file

Posted: Monday 05 May 2025 19:44
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)?

Re: Update resets db file

Posted: Monday 05 May 2025 23:12
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

Re: Update resets db file

Posted: Tuesday 06 May 2025 0:01
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.

Re: Update resets db file

Posted: Tuesday 06 May 2025 4:35
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?

Re: Update resets db file

Posted: Wednesday 07 May 2025 7:16
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".

Re: Update resets db file

Posted: Wednesday 07 May 2025 9:12
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.

Re: Update resets db file

Posted: Wednesday 07 May 2025 9:21
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.

Re: Update resets db file

Posted: Wednesday 07 May 2025 20:29
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

Re: Update resets db file

Posted: Thursday 08 May 2025 12:01
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

Re: Update resets db file

Posted: Thursday 08 May 2025 20:35
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

Re: Update resets db file

Posted: Friday 09 May 2025 8:37
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)

Re: Update resets db file

Posted: Tuesday 13 May 2025 22:04
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.