The original post: /r/selfhosted by /u/OriginalPlayerHater on 2025-01-17 06:03:35.

Just sharing my experience tonight in case someone else runs into it.

The problem:

I moved computers and my Immich installation was on an external, but I lost the original folder where PostgreSQL was configured. No database means my library was showing empty.

The solution:

Luckily, the Immich main folder has a backup folder with the database SQL files. This can be used to restore the database.

Steps to fix:

  1. Dropped the existing database in PostgreSQL (immich):

Run the following command to drop the old database:

docker exec -it immich_postgres psql -U postgres -c "DROP DATABASE IF EXISTS immich;" 2. Restored from the backup using the SQL dump file:

Assuming your backup file is located at E:/immich/backups/immich-db-backup-1736676000009.sql, use this command to restore:

cat E:/immich/backups/immich-db-backup-1736676000009.sql | docker exec -i immich_postgres psql -U postgres -d immich 3. Ran into an issue with password authentication — Immich couldn’t connect to PostgreSQL:

The error was related to incorrect password authentication. To fix this, I reset the password for the postgres user:

docker exec -it immich_postgres psql -U postgres -c "ALTER USER postgres PASSWORD 'postgres';" 4. Updated the .env file with the correct password:

Ensure the .env file has the correct password:

DB_PASSWORD=postgres 5. Restarted the containers to apply the changes:

Run these commands to restart your containers:

docker-compose down

docker-compose up -d

Result:

Everything’s back up and running smoothly! No data lost, library restored, and Immich is working perfectly again.