alexbelgium / hassio-addons

My homeassistant addons
MIT License
1.48k stars 213 forks source link

❓ [Immich] Backup way too large #1213

Open Scags104 opened 7 months ago

Scags104 commented 7 months ago

Immich

name: Question

about: Why is the backup of my immich addon 5GB+ on its own? This is making my nightly backup to GDrive max out on storage as it jumped from 1gb to 7gb per backup.

Initial investigation of backup files for immich addon arent helpful as they all wont extract or open the image and cause an unknown error.


Which addon? Immich

Addon or app? Addon

Describe the solution you'd like Smaller backup size or knowledge that what its backing up can be skipped in the backup since my images are saved and read from NAS. What i dont want is should i need to restore HA, that the link between immich and my NAS no longer functions and i lose my mappings.

alexbelgium commented 7 months ago

Hi, I can exclude them such as machine-learning data but not sure about the impact on restoring a backup!

Scags104 commented 7 months ago

surprised this doesnt live in the postgres db actually. rather lives in the container itself?

see you pushed a commit through already - thank you!

What are your thoughts about the ML directory/db being offset to network storage as well?

alexbelgium commented 7 months ago

I'll push this update once I'll have sorted the upgraded postgresql needed for recent versions

Indeed this lives in the container... Not fully sure why but I don't use the app so can't say for sure ;-) I could check to offset it but then it could add other complexities so I'm not rushing for that either ;-)

Scags104 commented 7 months ago

Updated today. Think there is an issue with the postgres vector version The pgvecto.rs extension version is 0.1.13 instead of 0.1.11. Please run 'DROP EXTENSION IF EXISTS vectors' and switch to 0.1.11, such as with the docker image

alexbelgium commented 7 months ago

Argh… i'll change the postgres add-on but it seems a recipe for failure in the future to have strict version dependencies

Scags104 commented 7 months ago

I hear you.

Unfortunately the issue persists after the update...

alexbelgium commented 7 months ago

No error messages in the add-on log ? This exact command is run in the startup script in the vector.sh script ; thanks!

Scags104 commented 7 months ago

These are my logs. Typically hangs at setting permissions for a bit because I am using the NAS but once it passes that all I see is the following:

` at async NestApplication.init (/app/immich/server/node_modules/@nestjs/core/nest-application.js:100:9) at async NestApplication.listen (/app/immich/server/node_modules/@nestjs/core/nest-application.js:169:33) at async bootstrap (/app/immich/server/dist/immich/main.js:34:20)

Node.js v20.11.0 /app/immich/server/dist/domain/database/database.service.js:47 throw new Error(` ^

Error: The pgvecto.rs extension version is 0.1.13 instead of 0.1.11. Please run 'DROP EXTENSION IF EXISTS vectors' and switch to 0.1.11, such as with the docker image 'tensorchord/pgvecto-rs:pg15-v0.1.11'. at DatabaseService.assertVectors (/app/immich/server/dist/domain/database/database.service.js:47:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async DatabaseService.init (/app/immich/server/dist/domain/database/database.service.js:32:9) at async AppService.init (/app/immich/server/dist/immich/app.service.js:56:9) at async AppModule.onModuleInit (/app/immich/server/dist/immich/app.module.js:32:9) at async callModuleInitHook (/app/immich/server/node_modules/@nestjs/core/hooks/on-module-init.hook.js:51:9) at async NestApplication.callInitHook (/app/immich/server/node_modules/@nestjs/core/nest-application-context.js:223:13) at async NestApplication.init (/app/immich/server/node_modules/@nestjs/core/nest-application.js:100:9) at async NestApplication.listen (/app/immich/server/node_modules/@nestjs/core/nest-application.js:169:33) at async bootstrap (/app/immich/server/dist/immich/main.js:34:20)

Node.js v20.11.0 /app/immich/server/dist/domain/database/database.service.js:47 throw new Error(` ^

Error: The pgvecto.rs extension version is 0.1.13 instead of 0.1.11. Please run 'DROP EXTENSION IF EXISTS vectors' and switch to 0.1.11, such as with the docker image 'tensorchord/pgvecto-rs:pg15-v0.1.11'. at DatabaseService.assertVectors (/app/immich/server/dist/domain/database/database.service.js:47:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async DatabaseService.init (/app/immich/server/dist/domain/database/database.service.js:32:9) at async AppService.init (/app/immich/server/dist/immich/app.service.js:56:9) at async AppModule.onModuleInit (/app/immich/server/dist/immich/app.module.js:32:9) at async callModuleInitHook (/app/immich/server/node_modules/@nestjs/core/hooks/on-module-init.hook.js:51:9) at async NestApplication.callInitHook (/app/immich/server/node_modules/@nestjs/core/nest-application-context.js:223:13) at async NestApplication.init (/app/immich/server/node_modules/@nestjs/core/nest-application.js:100:9) at async NestApplication.listen (/app/immich/server/node_modules/@nestjs/core/nest-application.js:169:33) at async bootstrap (/app/immich/server/dist/immich/main.js:34:20)

Node.js v20.11.0 /app/immich/server/dist/domain/database/database.service.js:47 throw new Error(` ^

Error: The pgvecto.rs extension version is 0.1.13 instead of 0.1.11. Please run 'DROP EXTENSION IF EXISTS vectors' and switch to 0.1.11, such as with the docker image 'tensorchord/pgvecto-rs:pg15-v0.1.11'. at DatabaseService.assertVectors (/app/immich/server/dist/domain/database/database.service.js:47:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async DatabaseService.init (/app/immich/server/dist/domain/database/database.service.js:32:9) at async AppService.init (/app/immich/server/dist/immich/app.service.js:56:9) at async AppModule.onModuleInit (/app/immich/server/dist/immich/app.module.js:32:9) at async callModuleInitHook (/app/immich/server/node_modules/@nestjs/core/hooks/on-module-init.hook.js:51:9) at async NestApplication.callInitHook (/app/immich/server/node_modules/@nestjs/core/nest-application-context.js:223:13) at async NestApplication.init (/app/immich/server/node_modules/@nestjs/core/nest-application.js:100:9) at async NestApplication.listen (/app/immich/server/node_modules/@nestjs/core/nest-application.js:169:33) at async bootstrap (/app/immich/server/dist/immich/main.js:34:20)

Node.js v20.11.0 /app/immich/server/dist/domain/database/database.service.js:47 throw new Error(` ^

Error: The pgvecto.rs extension version is 0.1.13 instead of 0.1.11. Please run 'DROP EXTENSION IF EXISTS vectors' and switch to 0.1.11, such as with the docker image 'tensorchord/pgvecto-rs:pg15-v0.1.11'. at DatabaseService.assertVectors (/app/immich/server/dist/domain/database/database.service.js:47:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async DatabaseService.init (/app/immich/server/dist/domain/database/database.service.js:32:9) at async AppService.init (/app/immich/server/dist/immich/app.service.js:56:9) at async AppModule.onModuleInit (/app/immich/server/dist/immich/app.module.js:32:9) at async callModuleInitHook (/app/immich/server/node_modules/@nestjs/core/hooks/on-module-init.hook.js:51:9) at async NestApplication.callInitHook (/app/immich/server/node_modules/@nestjs/core/nest-application-context.js:223:13) at async NestApplication.init (/app/immich/server/node_modules/@nestjs/core/nest-application.js:100:9) at async NestApplication.listen (/app/immich/server/node_modules/@nestjs/core/nest-application.js:169:33) at async bootstrap (/app/immich/server/dist/immich/main.js:34:20)

Node.js v20.11.0 /app/immich/server/dist/domain/database/database.service.js:47 throw new Error(` ^

Error: The pgvecto.rs extension version is 0.1.13 instead of 0.1.11. Please run 'DROP EXTENSION IF EXISTS vectors' and switch to 0.1.11, such as with the docker image 'tensorchord/pgvecto-rs:pg15-v0.1.11'. at DatabaseService.assertVectors (/app/immich/server/dist/domain/database/database.service.js:47:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async DatabaseService.init (/app/immich/server/dist/domain/database/database.service.js:32:9) at async AppService.init (/app/immich/server/dist/immich/app.service.js:56:9) at async AppModule.onModuleInit (/app/immich/server/dist/immich/app.module.js:32:9) at async callModuleInitHook (/app/immich/server/node_modules/@nestjs/core/hooks/on-module-init.hook.js:51:9) at async NestApplication.callInitHook (/app/immich/server/node_modules/@nestjs/core/nest-application-context.js:223:13) at async NestApplication.init (/app/immich/server/node_modules/@nestjs/core/nest-application.js:100:9) at async NestApplication.listen (/app/immich/server/node_modules/@nestjs/core/nest-application.js:169:33) at async bootstrap (/app/immich/server/dist/immich/main.js:34:20)

Node.js v20.11.0`

alexbelgium commented 7 months ago

Thanks, and what is your log when starting the postgres add-on?

Scags104 commented 7 months ago

Postgres:

` Starting... /etc/cont-init.d/00-banner.sh: executing


Add-on: Postgres 15 Postgres 15 with pgvecto.rs support

Add-on version: 15.5-5 You are running the latest version of this add-on. System: Home Assistant OS 11.5.rc2 (amd64 / generic-x86-64) Home Assistant Core: 2024.2.0b3 Home Assistant Supervisor: 2024.01.1

Please, share the above information when looking for help or support in, e.g., GitHub, forums

Provided by: https://github.com/alexbelgium/hassio-addons

/etc/cont-init.d/00-global_var.sh: executing POSTGRES_DB='immich_db' POSTGRES_PASSWORD=redacted POSTGRES_USER= redacted Timezone set from Etc/UTC to America/New_York /etc/cont-init.d/01-config_yaml.sh: executing Setting permissions for the config.yaml directory

Load environment variables from /config/config.yaml if existing If accessing the file with filebrowser it should be mapped to /addon_configs/db21ed7f-postgres/config.yaml

Wiki here on how to use : github.com/alexbelgium/hassio-addons/wiki/Add‐ons-feature-:-add-env-variables

... no env variables found, exiting /etc/cont-init.d/01-custom_script.sh: executing Execute /addon_configs/db21ed7f-postgres/postgres.sh if existing Wiki here : github.com/alexbelgium/hassio-addons/wiki/Add-ons-feature-:-customisation /etc/cont-init.d/20-folders.sh: executing /etc/cont-init.d/99-run.sh: executing [12:36:40] WARNING: The config.env file found in /config will be used (mapped to /addonconfigs/xxx-postgres when accessing from Filebrowser). Please customize according to https://hub.docker.com//postgres and restart the add-on

[12:36:40] INFO: Starting the app

[12:36:40] INFO: Waiting for port 5432 to open...

PostgreSQL Database directory appears to contain a database; Skipping initialization

2024-02-03 12:36:41.006 EST [244] LOG: starting PostgreSQL 15.5 (Debian 15.5-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit 2024-02-03 12:36:41.006 EST [244] LOG: listening on IPv4 address "0.0.0.0", port 5432 2024-02-03 12:36:41.006 EST [244] LOG: listening on IPv6 address "::", port 5432 2024-02-03 12:36:41.008 EST [244] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2024-02-03 12:36:41.011 EST [274] LOG: database system was interrupted; last known up at 2024-02-03 12:31:43 EST 2024-02-03 12:36:41.050 EST [274] LOG: database system was not properly shut down; automatic recovery in progress 2024-02-03 12:36:41.052 EST [274] LOG: redo starts at 0/9755A900 2024-02-03 12:36:41.052 EST [274] LOG: invalid record length at 0/9755BEA0: wanted 24, got 0 2024-02-03 12:36:41.052 EST [274] LOG: redo done at 0/9755BE78 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s 2024-02-03 12:36:41.055 EST [272] LOG: checkpoint starting: end-of-recovery immediate wait 2024-02-03 12:36:41.061 EST [272] LOG: checkpoint complete: wrote 2 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.002 s, total=0.007 s; sync files=3, longest=0.001 s, average=0.001 s; distance=5 kB, estimate=5 kB 2024-02-03 12:36:41.064 EST [244] LOG: database system is ready to accept connections 2024-02-03 12:36:41.484 EST [281] LOG: incomplete startup packet [12:36:41] INFO: Enabling vector.rs 2024-02-03 12:36:41.648 EST [296] FATAL: role "postgres" does not exist psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: role "postgres" does not exist`

alexbelgium commented 7 months ago

Perfect thanks I've pushed a new version that will be built soon that will fix using custom username as you have on postgres

Scags104 commented 7 months ago

Sorry to be a pain. Same issue. Logs for immich identical to the above.

bougs93 commented 7 months ago

I am also getting the same error.. Logs for immich identical to the above.

alexbelgium commented 7 months ago

Hi, actually the critical element is the log of postgres add-on. Immich is now depending on a very specific version of a postgres extension. if it is not properly enabled then immich won't work. could you please post a copy of your latest logs for postgres and immich addons (= not from the app but my own code starting the add-on)? thanks

Scags104 commented 7 months ago

There is another error in the postgres logs but it didn't seem important at the time as immich used to work while displaying this error

[10:43:04] INFO: Enabling vector.rs 2024-02-04 10:43:04.327 EST [297] FATAL: role "postgres" does not exist psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: role "postgres" does not exist

Where "postgres" mirrors the database_user from the config of the addon

alexbelgium commented 7 months ago

Hi, this is the true issue : since the last version immich is dependent on a specific extension enabled in postgres. This code is supposed to enable it ; which seems to be not working

Scags104 commented 7 months ago

Just confirming, this is waiting on debugging on your end? do you need any more information from this side?

Find it odd that its using the value from the DB_User in the config and complaining about the Role in the errors.... Is something mismatched on the backend?

alexbelgium commented 7 months ago

Hi, it was mismatched in version 15.5-5 but I corrected the user in version 15.5-6 so the error message about the "postgres" role should not appear if you have set a custom user

Scags104 commented 7 months ago

the issue provided above was from the 15.5-6 update though

Scags104 commented 7 months ago

Other odd issues randomly.... now it thinks my username is the database and says it cant find it.

`Starting... /etc/cont-init.d/00-banner.sh: executing


Add-on: Postgres 15 Postgres 15 with pgvecto.rs support

Add-on version: 15.5-6 You are running the latest version of this add-on. System: Home Assistant OS 11.5 (amd64 / generic-x86-64) Home Assistant Core: 2024.2.0b7 Home Assistant Supervisor: 2024.01.1

Please, share the above information when looking for help or support in, e.g., GitHub, forums

Provided by: https://github.com/alexbelgium/hassio-addons

/etc/cont-init.d/00-global_var.sh: executing POSTGRES_DB='immich_db' POSTGRES_PASSWORD=** POSTGRES_USER='MY_REDACTED_CUSTOM_USERNAME' Timezone set from Etc/UTC to America/New_York /etc/cont-init.d/01-config_yaml.sh: executing Setting permissions for the config.yaml directory

Load environment variables from /config/config.yaml if existing If accessing the file with filebrowser it should be mapped to /addon_configs/db21ed7f-postgres/config.yaml

Wiki here on how to use : github.com/alexbelgium/hassio-addons/wiki/Add‐ons-feature-:-add-env-variables

... no env variables found, exiting /etc/cont-init.d/01-custom_script.sh: executing Execute /addon_configs/db21ed7f-postgres/postgres.sh if existing Wiki here : github.com/alexbelgium/hassio-addons/wiki/Add-ons-feature-:-customisation /etc/cont-init.d/20-folders.sh: executing /etc/cont-init.d/99-run.sh: executing [12:29:36] WARNING: The config.env file found in /config will be used (mapped to /addonconfigs/xxx-postgres when accessing from Filebrowser). Please customize according to https://hub.docker.com//postgres and restart the add-on

[12:29:36] INFO: Starting the app

[12:29:36] INFO: Waiting for port 5432 to open...

PostgreSQL Database directory appears to contain a database; Skipping initialization

2024-02-06 12:29:36.232 EST [244] LOG: starting PostgreSQL 15.5 (Debian 15.5-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit 2024-02-06 12:29:36.232 EST [244] LOG: listening on IPv4 address "0.0.0.0", port 5432 2024-02-06 12:29:36.233 EST [244] LOG: listening on IPv6 address "::", port 5432 2024-02-06 12:29:36.234 EST [244] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2024-02-06 12:29:36.237 EST [274] LOG: database system was interrupted; last known up at 2024-02-06 12:25:40 EST 2024-02-06 12:29:36.277 EST [274] LOG: database system was not properly shut down; automatic recovery in progress 2024-02-06 12:29:36.278 EST [274] LOG: redo starts at 0/979935C8 2024-02-06 12:29:36.278 EST [274] LOG: invalid record length at 0/97994718: wanted 24, got 0 2024-02-06 12:29:36.278 EST [274] LOG: redo done at 0/979946F0 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s 2024-02-06 12:29:36.282 EST [272] LOG: checkpoint starting: end-of-recovery immediate wait 2024-02-06 12:29:36.286 EST [272] LOG: checkpoint complete: wrote 2 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.001 s, total=0.006 s; sync files=3, longest=0.001 s, average=0.001 s; distance=4 kB, estimate=4 kB 2024-02-06 12:29:36.289 EST [244] LOG: database system is ready to accept connections 2024-02-06 12:29:36.711 EST [281] LOG: incomplete startup packet [12:29:36] INFO: Enabling vector.rs 2024-02-06 12:29:36.883 EST [296] FATAL: database "MY_REDACTED_CUSTOM_USERNAME" does not exist psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: database "MY_REDACTED_CUSTOM_USERNAME" does not exist`