Unable to restore server
For some reason, my Immich server won't restore from my db.gz backup, I was running on a different server but have moved my install to a new server.
The command I am using to restore the database is:
docker compose down -v
rm -rf /srv/dev-disk-by-uuid-a914a7e5-3822-4cdb-a5e8-e8c7e3d13883/Immich-docker/pgdata/ docker compose create
docker start immich_postgres
sleep 10
gunzip --stdout "/srv/dev-disk-by-uuid-a914a7e5-3822-4cdb-a5e8-e8c7e3d13883/Immich-docker/upload/backups/immich-db-backup-1742176800009.sql.gz" | sed "s/SELECT pg_catalog.set_config('search_path', '', false);/SELECT pg_catalog.set_config('search_path', 'public, pg_catalog', true);/g" \ | docker exec -i immich_postgres psql –dbname=immich --username=postgres docker compose up -d -------------------------------------------- The command appears to work but when I visit my container at it's ip, it takes me to a landing page to create a new user. When I do so, it takes me to a new install with no assets or images. It does not seem to detect my files at all even though they are on the drive and mounted via my compose file at /srv/dev-disk-by-uuid-a914a7e5-3822-4cdb-a5e8-e8c7e3d13883/Immich-docker/upload Here is a copy of my env, any help would be greatly appreciated. ----------------------------------------------- The location where your uploaded files are stored UPLOAD_LOCATION=/srv/dev-disk-by-uuid-a914a7e5-3822-4cdb-a5e8-e8c7e3d13883/Immich-docker/upload The Immich version to use. You can pin this to a specific version like "v1.71.0" IMMICH_VERSION=release Connection secret for postgres. You should change it to a random password DB_PASSWORD=redacted The values below this line do not need to be changed ################################################################################### DB_HOSTNAME=immich_postgres DB_USERNAME=postgres DB_DATABASE_NAME=immich REDIS_HOSTNAME=immich_redis -------------------------------------------
rm -rf /srv/dev-disk-by-uuid-a914a7e5-3822-4cdb-a5e8-e8c7e3d13883/Immich-docker/pgdata/ docker compose create
docker start immich_postgres
sleep 10
gunzip --stdout "/srv/dev-disk-by-uuid-a914a7e5-3822-4cdb-a5e8-e8c7e3d13883/Immich-docker/upload/backups/immich-db-backup-1742176800009.sql.gz" | sed "s/SELECT pg_catalog.set_config('search_path', '', false);/SELECT pg_catalog.set_config('search_path', 'public, pg_catalog', true);/g" \ | docker exec -i immich_postgres psql –dbname=immich --username=postgres docker compose up -d -------------------------------------------- The command appears to work but when I visit my container at it's ip, it takes me to a landing page to create a new user. When I do so, it takes me to a new install with no assets or images. It does not seem to detect my files at all even though they are on the drive and mounted via my compose file at /srv/dev-disk-by-uuid-a914a7e5-3822-4cdb-a5e8-e8c7e3d13883/Immich-docker/upload Here is a copy of my env, any help would be greatly appreciated. ----------------------------------------------- The location where your uploaded files are stored UPLOAD_LOCATION=/srv/dev-disk-by-uuid-a914a7e5-3822-4cdb-a5e8-e8c7e3d13883/Immich-docker/upload The Immich version to use. You can pin this to a specific version like "v1.71.0" IMMICH_VERSION=release Connection secret for postgres. You should change it to a random password DB_PASSWORD=redacted The values below this line do not need to be changed ################################################################################### DB_HOSTNAME=immich_postgres DB_USERNAME=postgres DB_DATABASE_NAME=immich REDIS_HOSTNAME=immich_redis -------------------------------------------
12 Replies
:wave: Hey @autonomous5096,
Thanks for reaching out to us. Please carefully read this message and follow the recommended actions. This will help us be more effective in our support effort and leave more time for building Immich :immich:.
References
- Container Logs:
docker compose logs
docs
- Container Status: docker ps -a
docs
- Reverse Proxy: https://immich.app/docs/administration/reverse-proxy
- Code Formatting https://support.discord.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline#h_01GY0DAKGXDEHE263BCAYEGFJA
Checklist
I have...
1. :ballot_box_with_check: verified I'm on the latest release(note that mobile app releases may take some time).
2. :ballot_box_with_check: read applicable release notes.
3. :ballot_box_with_check: reviewed the FAQs for known issues.
4. :ballot_box_with_check: reviewed Github for known issues.
5. :blue_square: tried accessing Immich via local ip (without a custom reverse proxy).
6. :blue_square: uploaded the relevant information (see below).
7. :ballot_box_with_check: tried an incognito window, disabled extensions, cleared mobile app cache, logged out and back in, different browsers, etc. as applicable
(an item can be marked as "complete" by reacting with the appropriate number)
Information
In order to be able to effectively help you, we need you to provide clear information to show what the problem is. The exact details needed vary per case, but here is a list of things to consider:
- Your docker-compose.yml and .env files.
- Logs from all the containers and their status (see above).
- All the troubleshooting steps you've tried so far.
- Any recent changes you've made to Immich or your system.
- Details about your system (both software/OS and hardware).
- Details about your storage (filesystems, type of disks, output of commands like fdisk -l
and df -h
).
- The version of the Immich server, mobile app, and other relevant pieces.
- Any other information that you think might be relevant.
Please paste files and logs with proper code formatting, and especially avoid blurry screenshots.
Without the right information we can't work out what the problem is. Help us help you ;)
If this ticket can be closed you can use the /close
command, and re-open it later if needed.Are you sure there are no errors on the restore, and are you sure you're trying to restore the right file (and not one from an empty instance)?
Yes the file should be correct as it is dated a week before I attempted to transfer to my new server from a known working setup. My database was however originally set to the default provided by the Immich Docker Compose file prior to me changing to a mapped volume. I wonder if residual data is causing an issue here, but I cannot seem to find the expected data at the default UPLOAD_LOCATION (var/lib/docker or var/lib/postgres). I have run docker image prune to remove any leftover files.
The logs for my postgres container look okay.
the default UPLOAD_LOCATION (var/lib/docker or var/lib/postresql)That doesn't sound right
Apologies, I mean DB_DATA_LOCATION rather than UPLOAD_Location.
I figured, but that still seems a bit odd. You also don't have DB_DATA_LOCATION in your .env
Can you post your compose file too, for completeness?
Sure, here is my compose file:
version: "3.8"
name: immich
services:
immich-server:
container_name: immich_server
image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
volumes:
- ${UPLOAD_LOCATION}:/usr/src/app/upload
- /etc/localtime:/etc/localtime:ro
- /srv/dev-disk-by-uuid-a914a7e5-3822-4cdb-a5e8-e8c7e3d13883/Immich-docker/upload:/usr/src/app/external
env_file:
- .env
ports:
- 2283:2283
depends_on:
- redis
- database
restart: always
immich-machine-learning:
container_name: immich_machine_learning
# For hardware acceleration, add one of -[armnn, cuda, openvino] to the image tag.
# Example tag: ${IMMICH_VERSION:-release}-cuda
image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
# extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/ml-hardware-acceleration
# file: hwaccel.ml.yml
# service: cpu # set to one of [armnn, cuda, openvino, openvino-wsl] for accelerated inference - use the
-wsl
version for WSL2 where applicable
volumes:
- model-cache:/cache
env_file:
- .env
restart: always
redis:
container_name: immich_redis
image: redis:6.2-alpine@sha256:afb290a0a0d0b2bd7537b62ebff1eb84d045c757c1c31ca2ca48c79536c0de82
restart: always
database:
container_name: immich_postgres
image: tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0
env_file:
- .env
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_DB: ${DB_DATABASE_NAME}
volumes:
- /srv/dev-disk-by-uuid-a914a7e5-3822-4cdb-a5e8-e8c7e3d13883/Immich-docker/pgdata:/var/lib/postgresql/data
restart: always
volumes:
pgdata:
model-cache:/srv/dev-disk-by-uuid-a914a7e5-3822-4cdb-a5e8-e8c7e3d13883/Immich-docker/pgdataSo this is where the postgres data is being stored Have you cleared that out before restoring?
Yes with the command rm -rf /srv/dev-disk-by-uuid-a914a7e5-3822-4cdb-a5e8-e8c7e3d13883/Immich-docker/pgdata/
But my compose used to point towards ${DB_DATA_LOCATION}:/var/lib/postgresql/data before I changed it in the compose after my first attempt at restoring failed and I could not find the expected data in var/lib.
Please post the full commands you ran to do the restore as well as the full output
I don’t want to see copy paste from the docs we need to see exactly what you ran with the output from each
Here is the output with the full command I ran, it is my full output excluding a section I shortened that I assume is GPS co-ordinates for readability. Thanks for your time.
It looks like you have a dollar sign in one of your variables. This should be changed