From e7d6a066f89fadc42ae44bdb8e3e87c402688742 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 17 Oct 2025 16:38:37 +0100 Subject: [PATCH] docs: update backup-and-restore.md (#21065) * Update backup-and-restore.md Added, and consolidated messaging across the md file in relation to updating the username when running scripts. * chore: formatting --------- Co-authored-by: Jason Rasmussen --- docs/docs/administration/backup-and-restore.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/docs/administration/backup-and-restore.md b/docs/docs/administration/backup-and-restore.md index f9c00c7df7..fbb4cd8c23 100644 --- a/docs/docs/administration/backup-and-restore.md +++ b/docs/docs/administration/backup-and-restore.md @@ -57,6 +57,7 @@ Then please follow the steps in the following section for restoring the database ```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" ``` @@ -69,16 +70,18 @@ docker compose create # Create Docker containers for Immich apps witho 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. 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 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=)) ``` @@ -92,13 +95,15 @@ docker compose create # Create Docker containers for docker start immich_postgres # Start Postgres server sleep 10 # Wait for Postgres server to start up docker exec -it immich_postgres bash # Enter the Docker shell and run the following command -# Check the database user if you deviated from the default. If your backup ends in `.gz`, replace `cat` with `gunzip --stdout` +# If your backup ends in `.gz`, replace `cat` with `gunzip --stdout` +# Replace with the database username - usually postgres 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= exit # Exit the Docker shell docker compose up -d # Start remainder of Immich apps ``` - + Note that 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, Postgres conflicts may be encountered upon database restoration (relation already exists, violated foreign key constraints, multiple primary keys, etc.), in which case you need to delete the `DB_DATA_LOCATION` folder to reset the database.