Files
immich/README.md
2025-10-28 12:04:28 -05:00

76 lines
3.5 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Immich
> [!Note]
> The official backup and restore documentation for Immich is located here - https://immich.app/docs/administration/backup-and-restore/. The steps below were taken from the official documentation and adapted to our local installation.
# Backup Immich
> [!Warning]
> Do not backup the db_data_location folder while Immich is running. This will lead to a corrupt and unusable backup. Instead, use the following pg_dumpall command to get a clean and usable backup.
## Database Backup
Run the following command to backup the Immich database
``` bash
sudo docker exec -t immich_postgres pg_dumpall --clean --if-exists --username=postgres | gzip > "/mnt/5TB-Disk1/backup/server/immich/dump.sql.gz"
```
## Photo / Filesystem Backup
Run the following command to backup the photos stored in Immich. This command will place a full copy of all photos into /mnt/5TB-Disk1/backup/server/immich/photos/library. Modify the destination if you want to copy them to a different destination.
``` bash
sudo rsync -avz /photos/library /mnt/5TB-Disk1/backup/server/immich/photos/library
sudo rsync -avz /photos/upload /mnt/5TB-Disk1/backup/server/immich/photos/upload
sudo rsync -avz /photos/profile /mnt/5TB-Disk1/backup/server/immich/photos/profile
```
## Immich Config Backup
Immich configuration backup is performed in the admin web interface.
> [!note]
> This is not mentioned in the official immich documentation so it may not be necessary.
1. Click "Export as JSON" link in the top header of the page to download
2. Move the backup file to your network backup folder.
# Restore Immich
## Restore Photos / Filesystem
> [!note]
> The source path below assumes the photos are located in on the backup media and that it is mounted on `/mnt/5TB-Disk1`. Replace the rsync source if needed.
``` bash
sudo rsync -avz /mnt/5TB-Disk1/backup/server/immich/photos/library /photos/library
sudo rsync -avz /mnt/5TB-Disk1/backup/server/immich/photos/upload /photos/upload
sudo rsync -avz /mnt/5TB-Disk1/backup/server/immich/photos/profile /photos/profile
```
## Database Restore
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.
> [!warning]
> 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.).
``` bash
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 < "mnt/5TB-Disk1/backup/server/immich/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
```
## Authors and acknowledgment
See https://immich.app and https://github.com/immich-app/immich