Build the backup before you trust the library.
Immich backup planning has two jobs: protect the uploaded media and protect the database that explains what those files mean. A copied photo folder without a matching database is not a complete recovery plan.
UPLOAD_LOCATION when practical, keep at least one independent off-site copy, and run a restore drill into a separate location before you call the system protected.What must be protected
Immich says a comprehensive backup needs uploaded photos/videos plus the Immich database. Automatic database backups are stored under UPLOAD_LOCATION/backups, but they contain metadata only, not the photos or videos themselves.
The safest simple scope is the entire UPLOAD_LOCATION. If storage cost forces a smaller scope, Immich identifies the original asset folders as critical: library, upload and profile. Generated previews and encoded videos can be recreated, but rebuilding them takes time and compute.
Implementation sequence
- Record the live paths. Save the current
UPLOAD_LOCATION,DB_DATA_LOCATION, Docker Compose file and relevant environment values before changing anything. - Trigger or confirm database dumps. Immich can create automatic database backups and lets administrators trigger one manually through job queues.
- Pause writes if possible. Immich says stopping the server during backup keeps database and files in sync. If you cannot stop it, back up the database first and the filesystem second.
- Copy protected folders with a real backup tool. Use a tool that supports encryption, retention and verification. Do not treat a one-time file sync as a tested backup.
- Keep credentials separate. Backup repository passwords and object-storage keys should not live only on the Immich host they are meant to recover.
- Schedule checks. Alert on failed jobs, missing recent snapshots and unexpectedly small backup sizes.
Example layout using restic
Restic is one reasonable backup tool because it supports encrypted repositories, snapshots and restore commands. This site has not performed hands-on compatibility testing with your provider or host. Treat the commands below as a pattern to adapt, not a pasted production script.
| Step | Purpose | Planning note |
|---|---|---|
restic init | Create an encrypted repository. | Store the repository password outside the Immich machine. |
restic backup /path/to/upload-location | Capture media, generated files and database dumps under UPLOAD_LOCATION. | Use your real path and tags so snapshots are easy to filter. |
restic snapshots and restic ls latest | Confirm recent snapshots and inspect contents. | Check that backups, upload, library or profile appear as expected. |
restic restore latest --target /restore-test | Restore into a separate test directory. | Do not restore over the live library during a routine drill. |
Restore drill checklist
- Restore the latest backup to a separate disk or directory.
- Confirm the database dump exists and has a plausible timestamp.
- Confirm representative photos, videos and profile assets exist in the restored tree.
- Start a temporary Immich install only if you are prepared to keep it isolated from production paths and credentials.
- Use Immich's restore flow or documented command-line restore process for the database, matching the backup version when possible.
- Review Immich's integrity checks and sample several original photos, videos, albums and user accounts.
- Record the restore duration, missing steps, storage downloaded and any permission fixes.
Common failure modes
| Failure | Why it matters | Preventive control |
|---|---|---|
| Database-only backup | Metadata survives but original assets are gone. | Back up UPLOAD_LOCATION or at least the critical asset folders. |
| Filesystem-only backup | Files exist, but albums, users and metadata may not recover correctly. | Keep current database dumps with the file backup. |
| Wrong order while live | The restored database can reference files that were not captured. | Stop Immich or back up database first, filesystem second. |
| No restore test | A backup job can look green while credentials, paths or versions are unusable. | Run a scheduled restore drill into a separate location. |
Commercial and source note
This guide does not contain affiliate links, paid placement or provider recommendations. Provider choice should come after you know the protected capacity, retention period, restore size and egress policy.
Calculate protected Immich capacity before sizing backup storage →
先做好备份,再相信媒体库。
Immich 备份有两个核心任务:保护上传的照片和视频,也要保护解释这些文件含义的数据库。只有照片文件夹、没有匹配数据库,并不等于完整恢复方案。
UPLOAD_LOCATION;至少保留一份独立异地副本;在独立位置完成恢复演练后,才把系统视为已受保护。必须保护什么
Immich 官方说明,完整备份需要同时包含上传的照片/视频和 Immich 数据库。自动数据库备份位于 UPLOAD_LOCATION/backups,但只包含元数据,不包含照片或视频本身。
最稳妥的简单范围是整个 UPLOAD_LOCATION。如果存储成本迫使你缩小范围,Immich 标明关键原始资产目录是 library、upload 和 profile。预览图与转码视频可以重建,但会消耗时间和算力。
实施顺序
- 记录当前路径。在改动前保存
UPLOAD_LOCATION、DB_DATA_LOCATION、Docker Compose 文件和相关环境变量。 - 触发或确认数据库备份。Immich 可以自动创建数据库备份,管理员也可以在任务队列中手动触发。
- 尽量暂停写入。Immich 指出,备份时停止服务器可以保持数据库和文件同步。若无法停止,应先备份数据库,再备份文件系统。
- 用真正的备份工具复制受保护目录。选择支持加密、保留策略和校验的工具;不要把一次性同步当成已验证备份。
- 分开保存凭据。备份仓库密码和对象存储密钥,不应只保存在需要被恢复的 Immich 主机上。
- 安排检查。对失败任务、缺失的新快照和异常偏小的备份大小设置提醒。
使用 restic 的示例结构
restic 是一种可行的备份工具,因为它支持加密仓库、快照和恢复命令。本站没有对你的具体服务商或主机做兼容性实测。下面命令只是需要改造的模式,不是可直接粘贴的生产脚本。
| 步骤 | 目的 | 规划说明 |
|---|---|---|
restic init | 创建加密仓库。 | 把仓库密码保存在 Immich 主机之外。 |
restic backup /path/to/upload-location | 备份 UPLOAD_LOCATION 下的媒体、生成文件和数据库备份。 | 使用真实路径和标签,方便筛选快照。 |
restic snapshots 和 restic ls latest | 确认近期快照并检查内容。 | 确认 backups、upload、library 或 profile 按预期出现。 |
restic restore latest --target /restore-test | 恢复到独立测试目录。 | 日常演练不要覆盖生产媒体库。 |
恢复演练清单
- 把最新备份恢复到独立磁盘或目录。
- 确认数据库转储存在,并且时间戳合理。
- 确认恢复目录中有代表性的照片、视频和头像资产。
- 只有在能与生产路径和凭据隔离时,才启动临时 Immich 实例。
- 按 Immich 的恢复界面或官方命令行流程恢复数据库,并尽量匹配备份版本。
- 查看 Immich 完整性检查,抽查原始照片、视频、相册和用户账户。
- 记录恢复耗时、缺失步骤、下载量和权限修复。
常见失败模式
| 失败 | 影响 | 预防控制 |
|---|---|---|
| 只有数据库备份 | 元数据还在,但原始资产丢失。 | 备份 UPLOAD_LOCATION,或至少备份关键资产目录。 |
| 只有文件系统备份 | 文件存在,但相册、用户和元数据可能无法正确恢复。 | 让当前数据库备份与文件备份一起保存。 |
| 在线备份顺序错误 | 恢复后的数据库可能引用未被捕获的文件。 | 停止 Immich,或先备份数据库、再备份文件系统。 |
| 没有恢复测试 | 备份任务可能显示成功,但凭据、路径或版本不可用。 | 定期恢复到独立位置进行演练。 |
商业与来源说明
本指南不包含联盟链接、付费展示或服务商推荐。应先明确受保护容量、保留周期、恢复规模和出站流量政策,再选择供应商。