FIX for The database disk image is malformed Topic is solved

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: FIX for The database disk image is malformed

Post by waaren »

jake wrote: Tuesday 21 April 2020 21:13 Would it be worthwhile to mv the whole backup folder to another folder name? Maybe this gives domoticz the possibiliy to build the data set again.
It certainly looks like a access rights related issue so it's worth a try. I don't know when domoticz looks for the directory structure so to be sure it picks up the absence of the backup directory I would:

deactivate automatic backup and apply changes in settings page
stop domoticz
cd <domoticz dir>
mv backups/ backups_keep/
start domoticz
activate automatic backup and apply changes in settings page
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: FIX for The database disk image is malformed

Post by jake »

waaren wrote: Tuesday 21 April 2020 21:44
jake wrote: Tuesday 21 April 2020 21:13 Would it be worthwhile to mv the whole backup folder to another folder name? Maybe this gives domoticz the possibiliy to build the data set again.
It certainly looks like a access rights related issue so it's worth a try. I don't know when domoticz looks for the directory structure so to be sure it picks up the absence of the backup directory I would:

deactivate automatic backup and apply changes in settings page
stop domoticz
cd <domoticz dir>
mv backups/ backups_keep/
start domoticz
activate automatic backup and apply changes in settings page
Yes, that sound like the safest plan to me too. I will try it, within 12 minutes I am supposed to know if it workd (21:48 at the moment of writing)
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: FIX for The database disk image is malformed

Post by jake »

jake wrote: Tuesday 21 April 2020 21:48
waaren wrote: Tuesday 21 April 2020 21:44
jake wrote: Tuesday 21 April 2020 21:13 Would it be worthwhile to mv the whole backup folder to another folder name? Maybe this gives domoticz the possibiliy to build the data set again.
It certainly looks like a access rights related issue so it's worth a try. I don't know when domoticz looks for the directory structure so to be sure it picks up the absence of the backup directory I would:

deactivate automatic backup and apply changes in settings page
stop domoticz
cd <domoticz dir>
mv backups/ backups_keep/
start domoticz
activate automatic backup and apply changes in settings page
Yes, that sound like the safest plan to me too. I will try it, within 12 minutes I am supposed to know if it workd (21:48 at the moment of writing)
There we go, actually in my previous post was the answer already. See the difference in access rights of the backup folder. I really messed it up by not using sudo (which I actually did on purpose, because the domoticz file itself also has pi:pi ownership. I forgot to check the access rights to the domoticz.db file

Code: Select all

drwxr-x---   5 root root     4096 Apr 21 22:00 backups
drwxr-xr-x   5 pi   pi       4096 Apr 21 21:08 backups_keep
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: FIX for The database disk image is malformed

Post by waaren »

jake wrote: Tuesday 21 April 2020 22:02

Code: Select all

drwxr-x---   5 root root     4096 Apr 21 22:00 backups
So All good now?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: FIX for The database disk image is malformed

Post by jake »

waaren wrote: Tuesday 21 April 2020 22:14
jake wrote: Tuesday 21 April 2020 22:02

Code: Select all

drwxr-x---   5 root root     4096 Apr 21 22:00 backups
So All good now?
Yes, thanks for the suggestions.
Btw, the backup folder was only generated at the time of backup, not immediately after applying the settings.
Wienen
Posts: 5
Joined: Wednesday 17 October 2018 13:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: FIX for The database disk image is malformed

Post by Wienen »

jvdz wrote: Saturday 05 January 2019 14:26 You could try this approach by dumping the current database and loading the dumpfile into a new database like this bash file:

Code: Select all

#! /bin/sh
sudo service domoticz stop
cd /home/pi/domoticz
rm -f dump.sql
echo Dump domoticz.db to dump.sql
sudo sqlite3 domoticz.db  <<EOF
.mode insert
.output dump.sql
.dump
.exit
EOF

rm -f domoticz.fixed.db
echo create new domoticz.fixed.db loading dump.sql
sudo sqlite3 domoticz.fixed.db  <<EOF
.read dump.sql
.exit
EOF
After this you only need to rename the old domoticz.db file to something else and the new domoticz.fixed.db to domoticz.db.
Worth try?

Jos
Thanks Jos, you are my hero!! This fixed my corrupted .db!!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest