Immich upgrade fails and the pre-upgrade backup restore also fails

I have also trouble to restore a immich backup: https://paste.yunohost.org/raw/ejagigisaj

I come from the problem of different postgres cluster versions, here: Paperless doesn't start - #16 by jedie

Restore by immich web GUI doens’t work. It ends with:


Restoring Database

Error: /usr/lib/postgresql/17/bin/psql non-zero exit code (2)
ERROR:  current user cannot be dropped
ERROR:  cannot drop role postgres because it is required by the database system
ERROR:  role "immich" already exists
ERROR:  role "postgres" already exists
\connect: connection to server at "127.0.0.1", port 5433 failed: FATAL:  password authentication failed for user "immich"
connection to server at "127.0.0.1", port 5433 failed: FATAL:  password authentication failed for user "immich"

I tried now the /home/yunohost.app/immich/backups/restore_immich_db_backup.sh script…

EDIT: No success, the server doesn’t start and the logs are full of errors like:

[Nest] 71014  - 03/14/2026, 3:55:32 PM     LOG [Microservices:WebsocketRepository] Initialized websocket server
[Nest] 71014  - 03/14/2026, 3:55:32 PM     LOG [Microservices:DatabaseRepository] targetLists=1, current=1 for clip_index of 36803 rows
[Nest] 71014  - 03/14/2026, 3:55:32 PM     LOG [Microservices:DatabaseRepository] targetLists=256, current=256 for face_index of 186407 rows
[Nest] 71014  - 03/14/2026, 3:55:32 PM     LOG [Microservices:DatabaseRepository] Running migrations
Query failed : {
  durationMs: 1.393764999999803,
  error: PostgresError: constraint "album_asset_albumsId_fkey" for table "album_asset" does not exist
      at ErrorResponse (/var/www/immich/immich/app/node_modules/.pnpm/postgres@3.4.8/node_modules/postgres/cjs/src/connection.js:815:30)
      at handle (/var/www/immich/immich/app/node_modules/.pnpm/postgres@3.4.8/node_modules/postgres/cjs/src/connection.js:489:6)
      at Socket.data (/var/www/immich/immich/app/node_modules/.pnpm/postgres@3.4.8/node_modules/postgres/cjs/src/connection.js:324:9)
      at Socket.emit (node:events:508:28)
      at addChunk (node:internal/streams/readable:559:12)
      at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
      at Readable.push (node:internal/streams/readable:390:5)
      at TCP.onStreamRead (node:internal/stream_base_commons:189:23) {
    severity_local: 'ERROR',
    severity: 'ERROR',
    code: '42704',
    file: 'pg_constraint.c',
    line: '931',
    routine: 'get_relation_constraint_oid'
  },
  sql: 'ALTER TABLE "album_asset" RENAME CONSTRAINT "album_asset_albumsId_fkey" TO "album_asset_albumId_fkey";',
  params: []
}
[Nest] 71014  - 03/14/2026, 3:55:33 PM    WARN [Microservices:DatabaseRepository] Migration "1761755618862-FixColumnNames" failed
[Nest] 71014  - 03/14/2026, 3:55:33 PM   ERROR [Microservices:DatabaseRepository] Migrations failed: PostgresError: constraint "album_asset_albumsId_fkey" for table "album_asset" does not exist
PostgresError: constraint "album_asset_albumsId_fkey" for table "album_asset" does not exist
    at ErrorResponse (/var/www/immich/immich/app/node_modules/.pnpm/postgres@3.4.8/node_modules/postgres/cjs/src/connection.js:815:30)
    at handle (/var/www/immich/immich/app/node_modules/.pnpm/postgres@3.4.8/node_modules/postgres/cjs/src/connection.js:489:6)
    at Socket.data (/var/www/immich/immich/app/node_modules/.pnpm/postgres@3.4.8/node_modules/postgres/cjs/src/connection.js:324:9)
    at Socket.emit (node:events:508:28)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:189:23) {
  severity_local: 'ERROR',
  severity: 'ERROR',
  code: '42704',
  file: 'pg_constraint.c',
  line: '931',
  routine: 'get_relation_constraint_oid'
}
microservices worker error: PostgresError: constraint "album_asset_albumsId_fkey" for table "album_asset" does not exist, stack: PostgresError: constraint "album_asset_albumsId_fkey" for table "album_asset" does not exist
    at ErrorResponse (/var/www/immich/immich/app/node_modules/.pnpm/postgres@3.4.8/node_modules/postgres/cjs/src/connection.js:815:30)
    at handle (/var/www/immich/immich/app/node_modules/.pnpm/postgres@3.4.8/node_modules/postgres/cjs/src/connection.js:489:6)
    at Socket.data (/var/www/immich/immich/app/node_modules/.pnpm/postgres@3.4.8/node_modules/postgres/cjs/src/connection.js:324:9)
    at Socket.emit (node:events:508:28)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:189:23)
microservices worker exited with code 1
Killing api process