Database already huge

Then what happens???

Ha should create a new, automatically / same as it does if it for some reason get corrupted, or are ā€œlockedā€ by an external-connection

PS: i did asked you several times about your Backup-files ā€¦ Do you know where they are, if they are on your SD-card, how much space they take ? etc. ?

hey sorry, i missed that abojt my back up files

i only backed up to my sd card on the pi :frowning:

pretty new to all thisā€¦

anyway i have deleted the database. now to try and make things better!

1 Like

Anyway, the Back-up files HA does during ā€œUpdatesā€ would probably only give you a few GB free ā€¦ But donā€™t forget to order that SSD, ā€¦ now you have some time, when your DB starts from scratch

i found one actually, just need to format it, thank you sooooo much!

all this is way over my head, but fun and painful lol

Great discussion. This should be required reading for all new users. You need to wrap your mind around the Recorder and backups or youā€™ll shoot yourself in the foot. The recorder, left at the defaults, will quickly consume all the disk space available. Backups are useless if they only reside on the same drive (be it SD, SSD or whatever) as HA.

And then thereā€™s that repack option in the UI. Itā€™s easy to miss the fact that you need to take TWO actions in order to perform that operation:
image

Anyway, deleting the database and starting over is a good strategy. And of course you need to re-start HA to get the new Recorder exclusions recognized.

2 Likes

The ā€œDays to keepā€ option, does this purge the Energy data also? I guess that data is something one wants to keep! So one should know what he/she is doing.

No, energy dashboard data if correctly configured are kept despite the number of days configured for recorder purgeā€¦

I can confirm that the data are kept even if you donā€™t correctly configure the energy dashboard. My Statistics table continues to grow without regard to the Recorder purge days. Since I never set up any Energy stuff, I donā€™t use these data. Deleting old statistics records is one of the steps I perform during my routine database clean-up. Last time I did this, I deleted over 12,000 rows from the Statistics table (this was about a month after the previous clean-up.)

Hi Tom,

yeah you really should try my strategy, its working really well.
I did a lot of reading in forums and redit, and i find this way really efficient.
At 27 december 2021 i lost my db, so i started over, and iā€™m impressed how less space it takes now.

for the back-ups iā€™m using this add-on

It works well, i create daily backups to my nas, and i only need to delete them manually in HASS after a week.

regards

Iā€™m glad youā€™ve got a Recorder exclude strategy and a backup strategy that work for you. I think those are the two most important things to get right for a reliable HA implementation.

A couple of minor points for anyone reading this:

The Samba backup add-on and the Google Drive backup add-on are fantastic tools. Theyā€™re well written, well documented and well supported. BUTā€¦ neither one will create a backup on another platform. Both use the native HA process to create the backup on the media HA is running on, then copy it elsewhere.

This distinction is important if youā€™re concerned with space (or I/O) on the media, for example, if youā€™re running HA from an SD card.

Deleting the HA database is something every new user should experience. It sounds scary, but all you lose is a few days of history about when entities changed state. Unless youā€™re using long-term statistics (which I donā€™t believe HA is the best tool for anyway) you should be comfortable doing this.

The good news is, once your HA environment starts to mature you shouldnā€™t need to delete the database. You can keep it lean and efficient, you can back it up, and you can purge and repack it. Again with the exception of long-term statistics, which Iā€™m hoping some day will be added to the Recorder: Purge service so we wonā€™t need to off-load the database and manually run SQL against it.

Yes, there are some ā€œRe-fining UIā€ there needs to be done(in my opinion), for new and average users to feel ā€œcomfortableā€ in using HA ā€¦ I.E ā€œDeveloper Toolsā€ , im not a Developer(what should i do in there ?) , thou i do have some(quite more than average) IT experience, ā€¦ but still for more than few month i hardly looked in there(no descriptions, no guide, no links to guides) , at-least they could rename it to Tools, and then with a ā€œshortā€ description, and place a few ā€œotherā€ tools, that you actually find ā€œhere and thereā€ or link to same
( Call services ?, i havenā€™t set up any services ā€¦ States ? , ok thatā€™s probably just about how the system is doing right now ā€¦ Templates, GEE , get me out of here ! , % set json relative state_attrā€¦ Events: ??? ā€¦ ok at-least there are links there, last 2(if people are not already confused!, or in despair ) Statistics , ok it looks empty, what a relief :slight_smile: :joy:

I.E Tools could included an ā€œoverviewā€ of DB-size, filesystem-size logfile-size etc. + List of above ā€œToolsā€ And other ā€œeasy to useā€ tools ā€¦ i know Add-ons, backups and Supervisor, under Configuration Tab, maybe move Tools in there as well, so itā€™s not taking up ā€œspaceā€ in the side menu

I am so far out of my comfort zone here, but have you looked at an automation to call recorder.purge_entities once a day? Or just recorder.purge?

I have a flow in Node Red that purges my database every seven days using the call-service node and the home-assistant_v2.db file never goes over 1gB.

Or, I could be on a different planet altogetherā€¦

2 Likes

I have my ā€œRecorderā€ under control, and yes as it is a service, it could be called in various ways, in automation, click on a button, or what ever people like, or feel comfortable with, im not requesting anything, as i adapt to the options available, but yes eventually i might end up in a situation where i also ā€œneedā€ an automation, at-least for a ā€œrepackā€ function ā€¦ once per month, as it doesnā€™t seems like ā€œrepackā€ in sqlite, is a ā€œdefaultā€ procedure(which it should be in a ā€œin app controlled dbā€ ) in my opinion (not after every purge of single entities, but weekly/monthly, whatever) ā€¦ but your automation example is definitely something to look into, for people who have problems keeping their Recorder/DB under control
There are options to set 7days purge, in HA , calculating DB size is another story, but doable , preferably after a repack ā€¦ thou there are no options to ā€œselectā€ i.e exclude for specific entities( i actually dont know), but that means you have to include t.ex. 597 out of 600 in a script, or an " IF NOT "clause
EDIT:
Seems like im wrong, there is someone that ā€œfixedā€ this ā€¦ havenā€™t tried thou ( Maybe thatā€™s the ā€œapply_filterā€ function (with ā€œmissingā€ examples, and a weird description) for ordinary people to understand )

PS: Just did yet another manual ā€œRepackā€ , 2 days since last , gained +50MB , just for past 2 days purge(set to keep_30)

Yes, this has crossed my mind several times. In addition to the purge options, the Recorder service has Disable and Enable options. I think that means you could stop recording any new data while your automation is doing the purge and/or repack on some schedule.

I havenā€™t tried it yet, since at the rate HA updates come out, Iā€™m always shutting HA down for maintenance at least once a month, and much more often if Iā€™m making changes. I figure itā€™s safer to do the DB cleanup while Iā€™ve got HA down for some other reason anyway.

Well, i never use purge.
The thing is when i use purge does all my energy data get lost ?
Without purge my db is above the 350mb from 29th december 2021

Be careful with recorder, the energy dashboard data is stored using recorder so if you suspend the recorder and use the energy dahsboard, you could loose data I think. I discovered it because I changed my strategy for recorder data: I moved from a mix of include/exclude to include onlyā€¦

So I have in the include:

  • all the entities documented in the energy dashboard (if not included, you will have a warning in the energy dashboard configuration)
  • all my entities displayed using history or mini-graph cards
  • all my entities using the ā€œaverage sensorā€ add-on

Thatā€™s itā€¦ This represents: 32 entity and 6 glob entity (mainly from the energy dashboard where my entities are using the same pattern for naming them)ā€¦ pretty simple to maintainā€¦ and I have tons of entitiesā€¦

Using this, my database size was divided by 4ā€¦

Depends on, if your ā€œintegrationā€ comes from your grid/el-provider, or a ā€œlocalā€ device thing ā€¦ i get my consumption/pries from Electricity provider, when i installed it, i got ā€œeverythingā€ the Provider has ā€¦ it took awhile before Energy Dashboard was showing all :slight_smile: , as it was about a years consumption :slight_smile: , i can purge or dump_db, whatever i like, itā€™s still there
Thou as Didier mention, if you have added your own sensors, that will go in the bin, when purged

Aah ok, just good that i never used it

Well i need to find a way so i can store the full energy dashboard info on something else.
I donā€™t want it to delete for atleast a year.

regards

yes, im also in the loop of setting up an external DB, for same reasons, my old ā€œwebbserverā€ system, is partly manual, where i was(still) sitting and type in consumption and other ā€œBillsā€ etc( in various ā€œFormsā€, to get graphs/statistics )