HA venv manager

Hello there,

I wanted to present you a tool I did to manage my HA Core (in venv) installation.
You can find it on my Github repo:

I hope that it is enough customizable to fulfill one’s needs, but if I did not think about one special configuration that would prevent the script to run in your environment, please advise.
It has no release yet, it is in an early beta stage but this what it allows:

  1. Upgrade to stable or pre-release (at the end of the process, the release note is shown)

  1. Check logs / configuration (after upgrade, always a good practice)
Info: Checking configuration...
Testing configuration at /home/homeassistant/.homeassistant
Press any key to continue . . .
  1. Various command to stop/start and restart Home Assistant
  2. A backup/restore tool, creating tar.gz files of both venv and configuration directory
    image

image
image

I strongly recommend to have a look at this post, that was an inspiration to do something suiting my needs.

P.S.: The environment is thoroughly checked at startup. Especially it will require some capabilities of sudo for backup/restore. If something is blocking, it will fail with a meaningful error. Otherwise, it is possible that a warning will show and prevent some functionalities of the script.

P.S.: Even if backup is working, I’m still working on the restore part.

  1. I believe I should stop/start HA but I’m not sure to force it in the script or let the user do it.
  2. I’m also aware that the DB is a moving object but on the other hand, I’m not using the DB in the HA directory anymore.
  3. Should I do a specific procedure for that? Exclude the db file, and add 2 menus to do a mysql/sqlite/postgres/… “real” backup/restore?
4 Likes

Hi
just updated my test system using the script. works fine for me.
Remarks:

  • changed LOG_DIR to “.” , my user on the Pi does not have access to /var/log
  • dos2unix is required to display HA change log, but was not installed here and is not checked on startup like for example jq
  • I think prior to updating it should stop HA and start it after the update finishes

Armin

Thx for the feedback.

I’m checking it now.

I could, but it is working without stoping/starting HA, it is to minimize the downtime of HA.
Moreover it is allowing to check the config before doing a restart.

Yes, this is the reason why I’ve put all these in environment variables. Do you think that I should put “.” as default in the Github repo? /var/log is “the place to be” for logs but it is not writable by anyone indeed.

ok with me

I would suggest to use “.” as default for LOG_DIR and keep the log where the script is, I wouldn’t run such a script as root and /var/log/ is only writetable to root here

Armin

That’s the reason why I’m using a subdirectory. It is not /var/log but /var/log/homeassistant, in my setup, I’ve created the homeassistant directory with root and gave the write access to “pi”.

Versions are improving as much as I have free time, not so often.

Backup/Restore is still a work in progress.
Now, there is a possibility to downgrade to the last version of the last 5 month, for exemple, run today, the list of target versions is:

2023.4.6
2023.3.6
2023.2.5
2023.1.7
2022.12.9

What’s new is window sizes are now adapted to terminal’s size.
And the configuration is no longer in the script but in a json file, to allow update of the script from github without loosing the configuration.