Page 1 of 1

Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Posted: Thursday 03 July 2025 13:31
by andrehj
Somehow a device with a lot of historic data is no longer present in Domoticz (also in Setup → Devices) :( . Don't understand how that happened, I must have deleted it accidentally... :oops:

From the output of scripts I can see that it's missing since the 8th of June.
I have a domoticz_backup.db from June 2nd.

Is it possible to retrieve the device data (table) from that old backup and somehow insert it into my current database? Is there a how-to which explains how to do that? From my scripts I know the correct Device Idx.

From other devices and scripts I can estimate the values of the missing days. It would be nice if I could insert these into the table as well. But how do I accomplish that?

Thanks in advance for any help,

Andrehj

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Posted: Thursday 03 July 2025 15:55
by waltervl
See the database merge tool mentioned in this topic: viewtopic.php?p=312243#p312243

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Posted: Thursday 03 July 2025 20:05
by Varazir
waltervl wrote: Thursday 03 July 2025 15:55 See the database merge tool mentioned in this topic: viewtopic.php?p=312243#p312243
I can't download the file

https://releases.domoticz.com/releases/ ... BMerger.7z

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Posted: Thursday 03 July 2025 20:09
by jvdz

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Posted: Thursday 03 July 2025 20:38
by Varazir
jvdz wrote: Thursday 03 July 2025 20:09 Try: https://releases.domoticz.com/release/t ... BMerger.7z
Thanks it worked, It looked strange at first but didn't try to remove the extra.

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Posted: Friday 04 July 2025 10:23
by andrehj
waltervl wrote: Thursday 03 July 2025 15:55 See the database merge tool mentioned in this topic: viewtopic.php?p=312243#p312243
Thanks for the help!

However, as far as I understand, that tool can only merge some specific tables, or all tables. I just need to gather my historic data from one specific Idx, and integrate that into the current database.
I don't understand how I can do that with this tool.

Do I have to simply run
DomoticzDBMerger.exe --inputdb=olddatabase.db --outputdb=currentdatabase.db --merge-all
and hope that it works?

Or can I use the command
--transfer-old=idx --transfer-new=idx
to copy one idx from the old db to the current db? And than by keeping the idx the same it should just copy that index?
DomoticzDBMerger.exe --inputdb=olddatabase.db --outputdb=currentdatabase.db --transfer-old=137 --transfer-new=137

And will the latter work if a device with the new index is not yet present in the output database? Or do I have to create it first and let the merger simply fill that data?

So many questions...

Too bad there is no more elaborate help for this tool.

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Posted: Friday 04 July 2025 12:27
by waltervl
If you know the device type of the device that misses data you can determine what the table is you need to merge.
Is the device completely gone or just some historic data?
Because when the device is completely gone you have a bigger issue.

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Posted: Friday 04 July 2025 12:29
by andrehj
waltervl wrote: Friday 04 July 2025 12:27 If you know the device type of the device that misses data you can determine what the table is you need to merge.
Is the device completely gone or just some historic data?
Because when the device is completely gone you have a bigger issue.
The device is completely gone.

Idea: Create a new device (of the same type), and than add the data from the table of the old database?

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Posted: Friday 04 July 2025 12:38
by waltervl
That could be the right direction to create a new similar device and the use the command option
--transfer-old=idx --transfer-new=idx

Was it already a dummy device in the past or related to a normal hardware gateway? Because when connected to an existing hardware gateway it could automatically be recreated after a restart of Domoticz or the hardware gateway.

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Posted: Friday 04 July 2025 12:42
by andrehj
Sorry, should have mentioned that. It was a dummy device in which I track the energy consumption of my heatpump. It gets its data once a minute from a script that reads the values from an ABB energy meter via Modbus.

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Posted: Friday 04 July 2025 12:46
by waltervl
Then create a new dummy device and do the transfer/merge.
Make a backup before you start the transfer/merge!!!!

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Posted: Friday 04 July 2025 15:10
by andrehj
No luck after an hour or so of trying.
Starting Domoticz with the backup of June 2 shows this device:
2025-07-04 olddevice.png
2025-07-04 olddevice.png (6.08 KiB) Viewed 196 times
So I created a new device of the same type:
2025-07-04 newdevice.png
2025-07-04 newdevice.png (9.96 KiB) Viewed 196 times
However, when I run the command:
DomoticzRestore\Werk>DomoticzDBMerger.exe --inputdb=domoticz_backup2-6.db --outputdb=domoticz.db --transfer-old=137 --transfer-new=504

I get the output:
Both specified devices should be of the same type !

But of course they are... :( The only difference I see is that the new device somehow has a signal strength indicator, but I cannot imagine that that is the issue...

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Posted: Friday 04 July 2025 16:17
by waltervl
Another option now is to use "DB Browser for SQLite". it can be downloaded from sqlitebrowser.org.
You can export the device history data from the backup database to excel, modify the idx and import it into the current database (stop domoticz first!). The data is in the table Calendar_Meter.

Re: Help! Device gone in Domoticz, how to restore that device's historic data from old backup?

Posted: Friday 04 July 2025 16:22
by andrehj
Thanks, but I already gave up on this device in Domoticz. Maybe after my holiday I will fiddle with the SQL tool.
Just made a new device "Electric instant + Counter", for both the power en energy data of the heat pump.
Luckily I have an export of the daily counters to Excel (never trust one single database!), so most of my data is still retained, only one month is missing.