Page 1 of 1
how to restore my 'generated_scripts'?
Posted: Monday 20 January 2025 8:16
by renerene
I managed to save my generated_scripts from a corrupt database. How can i restore them?
As i remember the scripts are stored in the database and therefor it is not simple a matter of logging in with SSH and placing the files back in the 'generated_scripts' folder
I could copy/paste everything in the web browser, but I assume there is a better way
Re: how to restore my 'generated_scripts'?
Posted: Monday 20 January 2025 10:03
by waltervl
I dont think there is another way. Perhaps store them directly in the database but it is probably as much as work as using the web interface. I have no clue how to do it. How many scripts do you have?
Re: how to restore my 'generated_scripts'?
Posted: Monday 20 January 2025 11:15
by renerene
ok, thanks for the reply.
I have about 50 scripts, will take me an hour.
Re: how to restore my 'generated_scripts'?
Posted: Monday 20 January 2025 11:32
by gizmocuz
You could open both databases in a editor (like SQLite Expert Personal Edition) and copy/paste, but in the web interface is a good option.
50 scripts! Maybe you could simplify this a bit...
Re: how to restore my 'generated_scripts'?
Posted: Monday 20 January 2025 12:02
by lost
renerene wrote: ↑Monday 20 January 2025 11:15
I have about 50 scripts, will take me an hour.
To avoid such issue in the future, you may also save your scripts as regular files in the right ~/domoticz/scripts subdir, using the right name convention for the script type (time, device...)? Some also experienced (never myself, Lua looks quite robust) script errors that hangs domoticz, so when such script is in DB loaded at domoticz startup getting it back to work is not as simple as moving/renaming a faulty script file!
Just don't forget scripts no more embedded in DB => need to also save theses script files if a full domoticz reinstall is needed someday.
50 scripts is also huge! On my side, complex scripts are dedicated to a function (like alarm) per file but I merged all very small ones in a common file per type (I have a script_time_allChecks.lua that merged several small Lua scripts for time triggered checks in a single file for instance): As Domoticz must load each files for a trigger type this is more efficient.
Re: how to restore my 'generated_scripts'?
Posted: Monday 20 January 2025 15:56
by Kedi
I never store my scripts in the database, my dzVents script are ALL in the ~/domoticz/scripts/dzVents/scripts directory and there are 114 dzVents scripts totaling to 587Kb of scripts. My house is now almost autonomous, but still work (scripts) to do. My Raspberry is running fine. Am I way off now?
Re: how to restore my 'generated_scripts'?
Posted: Monday 20 January 2025 17:13
by zicht
gizmocuz wrote: ↑Monday 20 January 2025 11:32
You could open both databases in a editor (like SQLite Expert Personal Edition) and copy/paste, but in the web interface is a good option.
50 scripts! Maybe you could simplify this a bit...
This .... as your db grows and you have that many scripts expect at some point to have the experience that domoticz will become slow.
I have one lua file containing all basic functions thats loaded at start of the script before opening the commandArrayPP{}
(into 5 time scripts and 5 device scripts) --> I am below 0.3 sec for all timescripts to finisch and 0.2 sec for the device scripts ...
I also started once with a separate script for every different purpose they are now together, when you smart combine them in functions its also easier to trouble shoot
Re: how to restore my 'generated_scripts'?
Posted: Tuesday 21 January 2025 3:22
by solarboy
119 dzVents scripts(828kb), in the dB (35mB) , 864 used devices(1419 total). Slowed down a bit my old rpi3b but sits at 10-20% cpu these days with about 400mb memory use. I make sure to turn on full logging on occasion to check for loops and race conditions. I use monitorix to check overall status.
This is still my original dB from 2018 when I first started, I never had to rebuild.
Runs well, minimal lag these days.