From 5ba985da86e82bce98693d5afc270b3b59a25ca4 Mon Sep 17 00:00:00 2001 From: izzy Date: Thu, 5 Feb 2026 12:21:26 +0000 Subject: [PATCH] docs: update manual backup/restore to match automatic process closes #25772 --- .../docs/administration/backup-and-restore.md | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/docs/administration/backup-and-restore.md b/docs/docs/administration/backup-and-restore.md index 111a39ac8d..99eb5828d5 100644 --- a/docs/docs/administration/backup-and-restore.md +++ b/docs/docs/administration/backup-and-restore.md @@ -140,7 +140,8 @@ For advanced users or automated recovery scenarios, you can restore a database b ```bash title='Backup' # Replace with the database username - usually postgres unless you have changed it. -docker exec -t immich_postgres pg_dumpall --clean --if-exists --username= | gzip > "/path/to/backup/dump.sql.gz" +# Replace with the database name - usually immich unless you have changed it. +docker exec -t immich_postgres pg_dump --clean --if-exists --dbname= --username= | gzip > "/path/to/backup/dump.sql.gz" ``` ```bash title='Restore' @@ -153,9 +154,10 @@ docker start immich_postgres # Start Postgres server sleep 10 # Wait for Postgres server to start up # Check the database user if you deviated from the default # Replace with the database username - usually postgres unless you have changed it. +# Replace with the database name - usually immich unless you have changed it. gunzip --stdout "/path/to/backup/dump.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=postgres --username= # Restore Backup +| docker exec -i immich_postgres psql --dbname= --username= --single-transaction --set ON_ERROR_STOP=on # Restore Backup docker compose up -d # Start remainder of Immich apps ``` @@ -164,7 +166,8 @@ docker compose up -d # Start remainder of Immich apps ```powershell title='Backup' # Replace with the database username - usually postgres unless you have changed it. -[System.IO.File]::WriteAllLines("C:\absolute\path\to\backup\dump.sql", (docker exec -t immich_postgres pg_dumpall --clean --if-exists --username=)) +# Replace with the database name - usually immich unless you have changed it. +[System.IO.File]::WriteAllLines("C:\absolute\path\to\backup\dump.sql", (docker exec -t immich_postgres pg_dump --clean --if-exists --dbname= --username=)) ``` ```powershell title='Restore' @@ -179,8 +182,9 @@ sleep 10 # Wait for Postgres server to docker exec -it immich_postgres bash # Enter the Docker shell and run the following command # If your backup ends in `.gz`, replace `cat` with `gunzip --stdout` # Replace with the database username - usually postgres unless you have changed it. +# Replace with the database name - usually immich unless you have changed it. -cat "/dump.sql" | sed "s/SELECT pg_catalog.set_config('search_path', '', false);/SELECT pg_catalog.set_config('search_path', 'public, pg_catalog', true);/g" | psql --dbname=postgres --username= +cat "/dump.sql" | sed "s/SELECT pg_catalog.set_config('search_path', '', false);/SELECT pg_catalog.set_config('search_path', 'public, pg_catalog', true);/g" | psql --dbname= --username= --single-transaction --set ON_ERROR_STOP=on exit # Exit the Docker shell docker compose up -d # Start remainder of Immich apps ``` @@ -188,6 +192,10 @@ docker compose up -d # Start remainder of Immich ap +:::warning +The backup and restore process changed in v2.5.0, if you have a backup created with an older version of Immich, use the documentation version selector to find manual restore instructions for your backup. +::: + :::note For the database restore to proceed properly, it requires a completely fresh install (i.e., the Immich server has never run since creating the Docker containers). If the Immich app has run, you may encounter Postgres conflicts (relation already exists, violated foreign key constraints, etc.). In this case, delete the `DB_DATA_LOCATION` folder to reset the database. ::: @@ -196,6 +204,10 @@ For the database restore to proceed properly, it requires a completely fresh ins Some deployment methods make it difficult to start the database without also starting the server. In these cases, set the environment variable `DB_SKIP_MIGRATIONS=true` before starting the services. This prevents the server from running migrations that interfere with the restore process. Remove this variable and restart services after the database is restored. ::: +:::tip +The provided restore process ensures your database is never in a broken state by committing all changes in one transaction. This may be undesirable behaviour in some circumstances, you can disable it by removing `--single-transaction --set ON_ERROR_STOP=on` from the command. +::: + ## Filesystem Immich stores two types of content in the filesystem: (a) original, unmodified assets (photos and videos), and (b) generated content. We recommend backing up the entire contents of `UPLOAD_LOCATION`, but only the original content is critical, which is stored in the following folders: