From c92c4423569b767dc23e504456c69046b0f0a276 Mon Sep 17 00:00:00 2001 From: wittymap <119261743+wittymap@users.noreply.github.com> Date: Mon, 5 Jun 2023 06:56:39 -0700 Subject: [PATCH] Update restore example to address SQL errors on database import. (#2663) --- docs/docs/administration/backup-and-restore.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/docs/administration/backup-and-restore.md b/docs/docs/administration/backup-and-restore.md index 2902487a90..1f8d2077f2 100644 --- a/docs/docs/administration/backup-and-restore.md +++ b/docs/docs/administration/backup-and-restore.md @@ -13,9 +13,17 @@ docker exec -t immich_postgres pg_dumpall -c -U postgres | gzip > "/path/to/back ``` ```bash title='Restore' -gunzip < /path/to/backup/dump.sql.gz | docker exec -i immich_postgres psql -U postgres -d immich +docker-compose down -v # CAUTION! Deletes all Immich data to start from scratch. +docker-compose pull # Update to latest version of Immich (if desired) +docker-compose create # Create Docker containers for Immich apps without running them. +docker start immich_postgres # Start Postgres server +sleep 10 # Wait for Postgres server to start up +gunzip < "/path/to/backup/dump.sql.gz" | docker exec -i immich_postgres psql -U postgres -d immich # Restore Backup +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.). + The database dumps can also be automated (using [this image](https://github.com/prodrigestivill/docker-postgres-backup-local)) by editing the docker compose file to match the following: ```yaml