You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat(backup): Add Restic backup service and configuration
* feat(backup): Enhance Rclone backup instructions and clarify usage for various storage backends
* feat(backup): Update immich-backup service image to use mazzolino/restic
* feat(backup): Add pre and post commands for PostgreSQL database backup in immich-backup service
* fix: Rename CRON variable to BACKUP_CRON for clarity in backup schedule configuration
* feat(backup): Simplify backup commands in README and update retention policy usage
Copy file name to clipboardExpand all lines: immich/README.md
+215Lines changed: 215 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,3 +18,218 @@ Add the necessary DNS records in your domain.
18
18
|`IMMICH_UPLOAD_LOCATION`| Path where the assets will be stored |`/mnt/data/photos`|
19
19
|`IMMICH_API_KEY`| Immich API key to show information in the homepage |`1000`|
20
20
|`IMMICH_DB_PASSWORD`| Postgres database password, change for more security |`postgres`|
21
+
22
+
## Backup
23
+
24
+
Immich's database and media files can be backed up to any cloud storage product using [Restic](https://restic.readthedocs.io/) via [resticker](https://github.com/djmaze/resticker).
25
+
26
+
Restic provides:
27
+
-**Incremental backups**: Only changed data is backed up
28
+
-**Deduplication**: Identical content across snapshots uses minimal space
29
+
-**Encryption**: All data encrypted with your repository password
30
+
-**Compression**: Optional, doesn't interfere with deduplication
31
+
-**Remote backends**: S3, B2, SFTP, Rclone remotes, and more
32
+
33
+
### What Gets Backed Up
34
+
35
+
-**Upload directory** (`${IMMICH_UPLOAD_LOCATION}`): All original photos and videos uploaded by users
36
+
-**PostgreSQL database**: Dumped as SQL before each backup
37
+
-**Library data**: Library-stored assets (if enabled in Immich settings)
38
+
-**User profiles**: User profile images
39
+
40
+
### What Is Excluded
41
+
42
+
To save space, the following non-critical data is excluded and can be regenerated if needed:
43
+
-**Thumbnails** (`/data/thumbs/`): ~20-30% space savings
Rclone is optional. Use this only if your `RESTIC_REPOSITORY` URI starts with `rclone:`. If you prefer to use Rclone, it allows you to back up to any service supported by Rclone (S3, B2, SFTP, Google Drive, OneDrive, Dropbox, etc.) without direct Restic support, or if you want to reuse existing Rclone configurations.
74
+
75
+
First, configure your rclone remote destination:
76
+
77
+
```bash
78
+
docker compose run --rm -it immich-backup rclone config
79
+
```
80
+
81
+
This interactive command will guide you through:
82
+
1. Creating a new remote (choose `n`)
83
+
2. Naming your remote (e.g., `backup-s3`, `backup-b2`, `backup-sftp`, etc.)
84
+
3. Selecting your storage type (S3, B2, SFTP, etc.)
85
+
4. Entering credentials and configuration
86
+
87
+
The configuration will be saved to `immich/.rclone/rclone.conf`. Do not manually edit this file; use the `rclone config` command above to modify it.
**Azure Blob Storage** (Direct - no Rclone needed):
151
+
```bash
152
+
# Set in backup.env:
153
+
RESTIC_REPOSITORY=azure://immich-container/immich
154
+
155
+
# And provide credentials:
156
+
AZURE_ACCOUNT_NAME=myaccount
157
+
AZURE_ACCOUNT_KEY=mykey
158
+
```
159
+
160
+
#### 3. Generate a Secure Password
161
+
162
+
```bash
163
+
# Generate a strong random password
164
+
openssl rand -base64 32
165
+
166
+
# Copy the output and paste it into backup.env as RESTIC_PASSWORD
167
+
```
168
+
169
+
**Important**: Store this password securely. You'll need it to restore backups. If lost, your backup data becomes inaccessible.
170
+
171
+
### Testing the Backup
172
+
173
+
#### List Existing Snapshots
174
+
175
+
```bash
176
+
docker compose run --rm immich-backup snapshots
177
+
```
178
+
179
+
This will list all backup snapshots. If the repository doesn't exist yet, it will be initialized automatically on the first scheduled backup.
180
+
181
+
#### Manually Trigger a Backup
182
+
183
+
Perform a one-time backup:
184
+
185
+
```bash
186
+
docker compose run --rm immich-backup backup /data
187
+
```
188
+
189
+
Then apply the retention policy to clean up old snapshots:
190
+
191
+
```bash
192
+
docker compose run --rm immich-backup c forget --prune --keep-last 7 --keep-daily 7 --keep-weekly 4 --keep-monthly 3
193
+
```
194
+
195
+
(Note: Replace the `--keep-*` arguments with your configured `RESTIC_FORGET_ARGS` from `backup.env`)
196
+
197
+
#### Check Repository Status
198
+
199
+
```bash
200
+
docker compose run --rm immich-backup check
201
+
```
202
+
203
+
#### Monitor Scheduled Backups
204
+
205
+
Start the Immich service with the backup profile enabled:
206
+
207
+
```bash
208
+
COMPOSE_PROFILES=immich-backup docker compose up -d
209
+
```
210
+
211
+
Then monitor backup logs:
212
+
213
+
```bash
214
+
docker compose logs -f immich-backup
215
+
```
216
+
217
+
The backup will run automatically according to the schedule in `backup.env` (default: 3:30 AM daily).
218
+
219
+
### Restoration
220
+
221
+
For detailed instructions on restoring Immich from backups, see the [Immich Restore Documentation](https://docs.immich.app/administration/backup-and-restore/).
222
+
223
+
**Quick restore overview**:
224
+
1. Stop the Immich service
225
+
2. Restore the database dump: `psql -U postgres < db-dump.sql`
226
+
3. Restore the upload directory from the Restic snapshot
227
+
4. Start Immich again
228
+
229
+
To restore a specific snapshot:
230
+
231
+
```bash
232
+
docker compose run --rm immich-backup restore <snapshot-id> --target /restored
233
+
```
234
+
235
+
Then copy the files and database from `/restored` back to their original locations.
0 commit comments