Issue restoring a database backup
I recently move from Windows server to Debian 11. I took a backup following this documentation:
https://documentation.immich.app/docs/administration/backup-and-restore
I've setup Immich again using docker compose and now want to restore the database from my previous installation. However, I get the following error:
ERROR: cannot drop the currently open database
ERROR: current user cannot be dropped
ERROR: role "postgres" already exists
ERROR: relation "albums" already exists
ALTER TABLE
COMMENT
ERROR: relation "albums_assets_assets" already exists
ALTER TABLE
ERROR: relation "albums_shared_users_users" already exists
ALTER TABLE
ERROR: relation "api_keys" already exists
ALTER TABLE
ERROR: relation "assets" already exists
ALTER TABLE
ERROR: relation "exif" already exists
ALTER TABLE
ERROR: relation "migrations" already exists
ALTER TABLE
ERROR: relation "migrations_id_seq" already exists
ALTER TABLE
ALTER SEQUENCE
ERROR: relation "shared_link__asset" already exists
ALTER TABLE
ERROR: relation "shared_links" already exists
ALTER TABLE
ERROR: relation "smart_info" already exists
ALTER TABLE
ERROR: relation "system_config" already exists
ALTER TABLE
ERROR: relation "tag_asset" already exists
ALTER TABLE
ERROR: relation "tags" already exists
ALTER TABLE
COMMENT
ERROR: relation "typeorm_metadata" already exists
ALTER TABLE
ERROR: relation "user_token" already exists
ALTER TABLE
ERROR: relation "users" already exists
ALTER TABLE
ALTER TABLE
ERROR: insert or update on table "assets" violates foreign key constraint "FK_2c5ac0d6fb58b238fd2068de67d"
...
...
...
I'm relatively new to Linux so any help would be appreciated 🙂
Backup and Restore | Immich
Database
9 Replies
That looks like some database data has already been created. Make sure to start with an empty database and don't start any of the immich containers yet before restoring
The step would be take down the database container, the remove the curernt volume
After that start only the database container
and then perform the restoration
and then start the whole stack
Thank you! I'll see if that works and report back
I managed to restore the database, but I'm getting a 500 error:
Running docker logs immich_server shows:
password authentication failed for user "postgres"
Got it working by removing the password from the backup
A few people have asked this same question. We should add a note to the docs about this - start with a clean db, do restore, then start other services.
I'm getting an issue after restoring a database, can't log in with my email & password from before..
[Nest] 1 - 06/04/2023, 2:48:57 AM LOG [ImmichServer] Running Immich Server in PRODUCTION environment - version 1.59.1 - Listening on port: 3001
[Nest] 1 - 06/04/2023, 2:48:57 AM WARN [ImmichServer] Machine learning is enabled
[Nest] 1 - 06/04/2023, 2:48:57 AM WARN [ImmichServer] Search is enabled
[Nest] 1 - 06/04/2023, 2:49:16 AM WARN [AuthService] Failed login attempt for user [email protected] from ip address undefined
Have you started with a clean DB before starting other services like the comment directly above?
sorry just figured it out my wife changed the password without updating lastpass lol
Ah
Is it all good now?
Thanks alex, yes following the steps above helped me transition today from my Rpi to a new truenas build
And everything's coming up great!