expaso / hassos-addon-timescaledb

A HomeAssistant add-on containing PostgreSQL, psql client and TimeScaleDb
Apache License 2.0
50 stars 14 forks source link

Explain how to upgrade from 2.11 to 4.0 - and make it less precious! #44

Open mgg1010 opened 5 months ago

mgg1010 commented 5 months ago

Hi

I tried upgrading from 2.11 to 4.0. It upgraded, then I got an error saying "can't upgrade postgres 14, please update first" - and then the add-in shut down!

I'm technical, but not a deep expert in HA - so I was lost. I found instructions saying to upgrade PG I needed to use pgadmin - but I couldn't because the addin shut down.

I've managed to downgrade back to 2.11, so my setup is working. But

  1. Can you give me a route to upgrade? Home Assistant doesn't support upgrading to 3.0, which might do it. I might be able to use portainer to do it, but any guidainces would be great

  2. A thought for the future: make it so the addin doesn't shut down so completely - or check for this condition sooner!

Thanks

Martin Green

expaso commented 5 months ago

Hi Martin!

Wow! Upgrading from 2.11 is quite a step! Let me explain:

Within the addon, I had to manage not only upgrades of different timescale versions, but also different versions of Postgres. This means that each addon contains 2 postgres versions: The 'previous major version', and the 'current version'. Within a version you need to upgrade timescale first, and eventually postgres. So the addon has to run 2 postgres versions simultaneously during upgrades between major versions. When I started the addon, we were on Postgres 12. Then came 14, then 15 and now 16. This means that if I would make the upgrade possible from 12, I need to build-in Postgres 12,14,15 and 16. That would make the addon huge! (Apart form the fact that the base-image doesn't support all the older version anymore).

Unfortunately, I don't have any other means for checking earlier in the process or continue without quitting... But.. maybe I could help with upgrading step by step..

Is it possible to connect on discord? https://discord.gg/ccBjsZC8 I could help you perform the upgrade in a few intermediate steps.

expaso commented 5 months ago

Hi Martin, do you still need some assistance with this?

JeppeBoetkjaer commented 4 months ago

I al also facing an issue going from 2.0.1 to 4.0.1

i just updated core and os and wanted to update all add-ons.

after this update no history was found, my enery dashboard is gone(maybe not related).

But also I cannot log into the database.

Tried downgrading using the backup but still no luck. Its been years since I set this up also the reason for the huge jump in versions.

I could do with any assistance maybe over Discord?

expaso commented 4 months ago

Hi @JeppeBoetkjaer , sure I can try helping you out... Discord invite: https://discord.gg/JktdYKhE

LaMiyu commented 2 months ago

Unfortunately, I have the same problem. I was never shown that there was an update of LTSS, with the last HA update there was now a note that the setup config is missing. After I added the source again the note: From 1.1.6 to 4.0.1

;(

Unfortunately the same problem, the update hangs with the note, cant upgrade postgres ...

Is there an "easy" way to export the database, delete LTSS completely, reinstall 4.0.1. and then just import the old data? ...

Even when importing a backup, my old data is back, but the recorder no longer works correctly and no new data (e.g. energy) is recorded ... I would like to simply save the database with the backup and then set up LTSS completely new ... Is there a way to do this?

Thank you

skank01 commented 2 months ago

Argh i got the same problem. I'm on 4.0.1 Failed to start cause i need to upgrade. My entire energy dashboard is gone. How do i downgrade the addon and upgrade the db ?

skank01 commented 2 months ago

Hi

I tried upgrading from 2.11 to 4.0. It upgraded, then I got an error saying "can't upgrade postgres 14, please update first" - and then the add-in shut down!

I'm technical, but not a deep expert in HA - so I was lost. I found instructions saying to upgrade PG I needed to use pgadmin - but I couldn't because the addin shut down.

I've managed to downgrade back to 2.11, so my setup is working. But

  1. Can you give me a route to upgrade? Home Assistant doesn't support upgrading to 3.0, which might do it. I might be able to use portainer to do it, but any guidainces would be great
  2. A thought for the future: make it so the addin doesn't shut down so completely - or check for this condition sooner!

Thanks

Martin Green

Hi, how did u downgrade the addon?

skank01 commented 2 months ago

@Expaso can you help me please? Thx in advance

LaMiyu commented 2 months ago

Hi I tried upgrading from 2.11 to 4.0. It upgraded, then I got an error saying "can't upgrade postgres 14, please update first" - and then the add-in shut down! I'm technical, but not a deep expert in HA - so I was lost. I found instructions saying to upgrade PG I needed to use pgadmin - but I couldn't because the addin shut down. I've managed to downgrade back to 2.11, so my setup is working. But

  1. Can you give me a route to upgrade? Home Assistant doesn't support upgrading to 3.0, which might do it. I might be able to use portainer to do it, but any guidainces would be great
  2. A thought for the future: make it so the addin doesn't shut down so completely - or check for this condition sooner!

Thanks Martin Green

Hi, how did u downgrade the addon?

Hello,

I was able to restore the backup of HA. This was created automatically during the upgrade. System -> Backup -> Select TimeScaleDB -> Restore

skank01 commented 2 months ago

Hi Good idea, will try that. After reverting to old one, did you succeed in upgrading to new one too?

Op zo 23 jun. 2024 16:47 schreef LaMiyu @.***>:

Hi I tried upgrading from 2.11 to 4.0. It upgraded, then I got an error saying "can't upgrade postgres 14, please update first" - and then the add-in shut down! I'm technical, but not a deep expert in HA - so I was lost. I found instructions saying to upgrade PG I needed to use pgadmin - but I couldn't because the addin shut down. I've managed to downgrade back to 2.11, so my setup is working. But

  1. Can you give me a route to upgrade? Home Assistant doesn't support upgrading to 3.0, which might do it. I might be able to use portainer to do it, but any guidainces would be great
  2. A thought for the future: make it so the addin doesn't shut down so completely - or check for this condition sooner!

Thanks Martin Green

Hi, how did u downgrade the addon?

Hello,

I was able to restore the backup of HA. This was created automatically during the upgrade. System -> Backup -> Select TimeScaleDB -> Restore

— Reply to this email directly, view it on GitHub https://github.com/Expaso/hassos-addon-timescaledb/issues/44#issuecomment-2185018825, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMXFMVXVQO2L7KFABRRJKPDZI3NWPAVCNFSM6AAAAABFQX52HSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBVGAYTQOBSGU . You are receiving this because you commented.Message ID: @.***>

skank01 commented 2 months ago

OK managed to revert back and all is working again. Can you explain me now how to properly update?

mgg1010 commented 2 months ago

Expanso

Very, very sorry for the slow reply. I appreciate your offer, and it's very useful - I'll connect on Discord. The problem is that this is a home activity for me, and work is crazy...

If there's a route where I can backup the DB, and install the newest version and then just copy the tables - maybe that's the best option? I'm a developer by background, so very technical but not very experienced in this environment.

Thanks

Martin

mgg1010 commented 2 months ago

Oops - discord invite expired too!

skank01 commented 2 months ago

Hi I tried upgrading from 2.11 to 4.0. It upgraded, then I got an error saying "can't upgrade postgres 14, please update first" - and then the add-in shut down! I'm technical, but not a deep expert in HA - so I was lost. I found instructions saying to upgrade PG I needed to use pgadmin - but I couldn't because the addin shut down. I've managed to downgrade back to 2.11, so my setup is working. But

  1. Can you give me a route to upgrade? Home Assistant doesn't support upgrading to 3.0, which might do it. I might be able to use portainer to do it, but any guidainces would be great
  2. A thought for the future: make it so the addin doesn't shut down so completely - or check for this condition sooner!

Thanks Martin Green

Hi, how did u downgrade the addon?

Hello,

I was able to restore the backup of HA. This was created automatically during the upgrade. System -> Backup -> Select TimeScaleDB -> Restore

Hi , do you know how to properly update now?

LaMiyu commented 2 months ago

Hi I tried upgrading from 2.11 to 4.0. It upgraded, then I got an error saying "can't upgrade postgres 14, please update first" - and then the add-in shut down! I'm technical, but not a deep expert in HA - so I was lost. I found instructions saying to upgrade PG I needed to use pgadmin - but I couldn't because the addin shut down. I've managed to downgrade back to 2.11, so my setup is working. But

  1. Can you give me a route to upgrade? Home Assistant doesn't support upgrading to 3.0, which might do it. I might be able to use portainer to do it, but any guidainces would be great
  2. A thought for the future: make it so the addin doesn't shut down so completely - or check for this condition sooner!

Thanks Martin Green

Hi, how did u downgrade the addon?

Hello, I was able to restore the backup of HA. This was created automatically during the upgrade. System -> Backup -> Select TimeScaleDB -> Restore

Hi , do you know how to properly update now?

i haven't find a solution until now ... i have a backup of my 1.1.6 timescale DB with all the Data and make some csv exports from pgadmin also a backup as sql from the database. But i cannot import anything in the 4.x Version - At the moment i have no solution. ;( All my historical Data are lost ...

skank01 commented 2 months ago

@Expaso how do we update from 2.0.1?

skank01 commented 2 months ago

@Expaso is it possible to please reply? We are stuck on how to update

skank01 commented 1 month ago

I al also facing an issue going from 2.0.1 to 4.0.1

i just updated core and os and wanted to update all add-ons.

after this update no history was found, my enery dashboard is gone(maybe not related).

But also I cannot log into the database.

Tried downgrading using the backup but still no luck. Its been years since I set this up also the reason for the huge jump in versions.

I could do with any assistance maybe over Discord?

Hi @JeppeBoetkjaer did you manage to upgrade correctly? Can you help me, cause @Expaso isnt replying anymore and i cant update the addon cause of this problem

expaso commented 4 weeks ago

Hi all! Back again!

Sorry for the delay, I was on the other side of the world for a project for quite some time, so I did not had a change to look into this, but I'm currently testing a possibility..

Stay close, Im on it right now.

Edit: New Discord invote link: https://discord.gg/wScb9jjr

expaso commented 4 weeks ago

@skank01 , @JeppeBoetkjaer , @mgg1010

I have found a way of upgrading the intermediate steps of the addon manually.

Here are the instructions:

1) Make sure you have a backup of your timescale addon!

2) Obtain SSH root access to your home-assistant installation, using this method: https://developers.home-assistant.io/docs/operating-system/debugging/

3) Stop the timescale-db addon.

4)

Important! Replace aarch64 with amd64 if you are on a x64 machine. If you are on a raspberry PI or other embedded board, mostly you'll have to use aarch64

To upgrade from 1.x.x, run the 2.1.1 version using this command:

docker run --rm --name timescaledb-upgrade -v /mnt/data/supervisor/addons/data/77b2833f_timescaledb/:/data:rw husselhans/hassos-addon-timescaledb-aarch64:2.1.1

To upgrade from 2.x.x, run the 3.0.2 version using this command:

docker run --rm --name timescaledb-upgrade -v /mnt/data/supervisor/addons/data/77b2833f_timescaledb/:/data:rw husselhans/hassos-addon-timescaledb-aarch64:3.0.2

To upgrade from 3.x.x, run the 4.0.1 version using this command:

docker run --rm --name timescaledb-upgrade -v /mnt/data/supervisor/addons/data/77b2833f_timescaledb/:/data:rw husselhans/hassos-addon-timescaledb-aarch64:4.0.1

After the last step, you should see something like:

[15:47:28] INFO: Starting PgAgent.. curl: (6) Could not resolve host: supervisor [15:47:29] ERROR: Something went wrong contacting the API [15:47:29] NOTICE: TimescaleDb is running!

Stop this process by using Crtrl-C, and let the database shut down

From here, the normal home-assistant upgrade should be back on track again.

5) Start the addon again in Home Assistant. You should be good to go.

expaso commented 4 weeks ago

ion - At the moment i have no solution. ;( All my historical Data are lost ...

Probably your data is still there, as it's just moved to another folder internally. Reach out on discord, so I can help you: https://discord.gg/wScb9jjr

skank01 commented 4 weeks ago

5. e Assistant. You should be good to go.

Hi,

No need to excuse yourself... You are doing this all in your free time. Thx a lot for all your work, and keeping this alive. Much appreciated !

I just tested your solution ,and i can confirm i could easily upgrade now from 2.0.1 to 4.0.1 All is working fine now, a big thanks !!!

For me this can be closed!

expaso commented 4 weeks ago

Great to hear!!

And thank you for using the addon! Enjoy!!