From a91fd772e48fd5b68da4a336c096c21cece50b0b Mon Sep 17 00:00:00 2001 From: Matthew Momjian <50788000+mmomjian@users.noreply.github.com> Date: Mon, 22 Apr 2024 15:40:19 -0700 Subject: [PATCH] docs: default to sed pg_catalog for Linux, document restore/reset for PG bind mount (#9021) * Update FAQ.mdx * Update FAQ.mdx * Update FAQ.mdx * Update FAQ.mdx * Update FAQ.mdx * Update FAQ.mdx * Update backup-and-restore.md * Update backup-and-restore.md * linting * Update backup-and-restore.md * Update FAQ.mdx * Update backup-and-restore.md * Update docs/docs/administration/backup-and-restore.md Co-authored-by: Mert <101130780+mertalev@users.noreply.github.com> * Update FAQ.mdx --------- Co-authored-by: Mert <101130780+mertalev@users.noreply.github.com> --- docs/docs/FAQ.mdx | 41 +++++++++++++------ .../docs/administration/backup-and-restore.md | 12 ++++-- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/docs/docs/FAQ.mdx b/docs/docs/FAQ.mdx index 508f543983..10c7bbf424 100644 --- a/docs/docs/FAQ.mdx +++ b/docs/docs/FAQ.mdx @@ -131,6 +131,7 @@ This is not officially supported but can be accomplished with some database upda 3. Four tables need to be updated: ```sql +BEGIN; -- reassign albums UPDATE albums SET "ownerId" = '' WHERE "ownerId" = ''; @@ -143,6 +144,7 @@ UPDATE assets SET "ownerId" = '' WHERE "ownerId" = '' -- reassign external libraries UPDATE libraries SET "ownerId" = '' WHERE "ownerId" = ''; +COMMIT; ``` 4. There might be left-over assets in the 'source' user's library if they are skipped by the last query because of duplicate checksums. These are probably duplicates anyway, and can probably be removed. @@ -230,14 +232,19 @@ to increase the bar for what the algorithm considers a "core face" for that pers ### The immich_model-cache volume takes up a lot of space, what could be the problem? -If you installed several models and chose not to use some of them, it might be worth deleting the old models that are in immich_model-cache. +If you installed several models and chose not to use some of them, it might be worth deleting the old models that are in immich_model-cache. To do this you can mount the model cache and remove the undesired models. -To do this you can run: +
+Steps -- `docker run -it --rm -v immich_model-cache:/mnt ubuntu bash` -- `cd mnt` -- `ls` -- and delete unused models with `rm -r `. +```bash +docker run -it --rm -v immich_model-cache:/mnt-models alpine sh +cd /mnt-models +ls clip/ facial-recognition/ +# rm -r clip/ABC facial-recognition/DEF # delete unused models +``` + +
--- @@ -261,6 +268,9 @@ The initial backup is the most intensive due to the number of jobs running. The By default, a container has no resource constraints and can use as much of a given resource as the host's kernel scheduler allows. To limit this, you can add the following to the `docker-compose.yml` block of any containers that you want to have limited resources. +
+docker-compose.yml + ```yaml deploy: resources: @@ -271,6 +281,7 @@ deploy: memory: '1G' ``` +
For more details, you can look at the [original docker docs](https://docs.docker.com/config/containers/resource_constraints/) or use this [guide](https://www.baeldung.com/ops/docker-memory-limit). ### How can I boost machine learning speed? @@ -319,6 +330,9 @@ The non-root user/group needs read/write access to the volume mounts, including For a further hardened system, you can add the following block to every container except for `immich_postgres`. +
+docker-compose.yml + ```yaml security_opt: # Prevent escalation of privileges after the container is started @@ -328,15 +342,15 @@ cap_drop: - NET_RAW ``` -### How can I **purge** data from Immich? +
+ +### How can I purge data from Immich? Data for Immich comes in two forms: -1. **Metadata** stored in a Postgres database, persisted via the `pg_data` volume +1. **Metadata** stored in a Postgres database, stored in the `DB_DATA_LOCATION` folder (previously `pg_data` Docker volume). 2. **Files** (originals, thumbs, profile, etc.), stored in the `UPLOAD_LOCATION` folder, more [info](/docs/administration/backup-and-restore#asset-types-and-storage-locations). -To remove the **Metadata** you can stop Immich and delete the volume. - :::warning This will destroy your database and reset your instance, meaning that you start from scratch. ::: @@ -345,13 +359,16 @@ This will destroy your database and reset your instance, meaning that you start docker compose down -v ``` +After removing the containers and volumes, there are a few directories that need to be deleted to reset Immich to a new installation. Once they are deleted, Immich can be started back up and will be a fresh installation. + +- `DB_DATA_LOCATION` contains the database, media info, and settings. +- `UPLOAD_LOCATION` contains all the media uploaded to Immich. + :::note Portainer If you use portainer, bring down the stack in portainer. Go into the volumes section and remove all the volumes related to immich then restart the stack. ::: -After removing the containers and volumes, the **Files** should be removed from the `UPLOAD_LOCATION` to provide a clean start. - ### Why does the machine learning service report workers crashing? :::note diff --git a/docs/docs/administration/backup-and-restore.md b/docs/docs/administration/backup-and-restore.md index e949f8d998..2b847fc4b5 100644 --- a/docs/docs/administration/backup-and-restore.md +++ b/docs/docs/administration/backup-and-restore.md @@ -15,7 +15,7 @@ Immich saves [file paths in the database](https://github.com/immich-app/immich/d Refer to the official [postgres documentation](https://www.postgresql.org/docs/current/backup.html) for details about backing up and restoring a postgres database. ::: -The recommended way to backup and restore the Immich database is to use the `pg_dumpall` command. +The recommended way to backup and restore the Immich database is to use the `pg_dumpall` command. When restoring, you need to delete the `DB_DATA_LOCATION` folder (if it exists) to reset the database. @@ -26,11 +26,14 @@ docker exec -t immich_postgres pg_dumpall --clean --if-exists --username=postgre ```bash title='Restore' docker compose down -v # CAUTION! Deletes all Immich data to start from scratch. +# rm -rf DB_DATA_LOCATION # 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 --username=postgres # Restore Backup +gunzip < "/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 --username=postgres # Restore Backup docker compose up -d # Start remainder of Immich apps ``` @@ -43,6 +46,7 @@ docker exec -t immich_postgres pg_dumpall --clean --if-exists --username=postgre ```powershell title='Restore' docker compose down -v # CAUTION! Deletes all Immich data to start from scratch. +# Remove-Item -Recurse -Force DB_DATA_LOCATION # 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 @@ -83,7 +87,9 @@ services: Then you can restore with the same command but pointed at the latest dump. ```bash title='Automated Restore' -gunzip < db_dumps/last/immich-latest.sql.gz | docker exec -i immich_postgres psql --username=postgres +gunzip < db_dumps/last/immich-latest.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 --username=postgres ``` :::note