Docker一键部署Immich:自建私有云相册,照片视频备份无忧

Docker一键部署Immich:自建私有云相册,照片视频备份无忧

开源地址:immich-app/immich: High performance self-hosted photo and video management solution.

1.下载部署文件

前往分支Release v2.4.1 · immich-app/immich下载.envdocker-compose.yml文件

2.修改配置文件

将下载的文件上传到服务器,并将example.env重命名成 .env, 然后修改参数

yml 复制代码
# You can find documentation for all the supported env variables at https://docs.immich.app/install/environment-variables

# The location where your uploaded files are stored
UPLOAD_LOCATION=./library  

# The location where your database files are stored. Network shares are not supported for the database
DB_DATA_LOCATION=./postgres

# To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
TZ=Asia/Shanghai  #将时区改成上海
# The Immich version to use. You can pin this to a specific version like "v2.1.0"
IMMICH_VERSION=v2

# Connection secret for postgres. You should change it to a random password
# Please use only the characters `A-Za-z0-9`, without special characters or spaces
DB_PASSWORD=postgres

# The values below this line do not need to be changed
###################################################################################
DB_USERNAME=postgres
DB_DATABASE_NAME=immich
3.运行docker容器
bash 复制代码
docker compose up -d


CONTAINER ID   IMAGE                                                            COMMAND                  CREATED        STATUS                  PORTS                                         NAMES
9270c9a4484b   ghcr.io/immich-app/immich-server:v2                              "tini -- /bin/bash -..."   24 hours ago   Up 24 hours (healthy)   0.0.0.0:2283->2283/tcp, [::]:2283->2283/tcp   immich_server
c00b25a11b5c   ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0   "/usr/local/bin/immi..."   24 hours ago   Up 24 hours (healthy)   5432/tcp                                      immich_postgres
1b4d31449404   ghcr.io/immich-app/immich-machine-learning:v2                    "tini -- python -m i..."   24 hours ago   Up 24 hours (healthy)                                                 immich_machine_learning
33d4dded710d   valkey/valkey:9                                                  "docker-entrypoint.s..."   24 hours ago   Up 24 hours (healthy)   6379/tcp                                      immich_redis
4.浏览器打开

在浏览器打开:IP:2283 就可以创建用户进入 Immich 了。

5.数据备份

为防止数据丢失,建议定期备份数据库和存储文件夹(即.env文件中定义的文件存储路径中的librarypostgres 文件夹)

备份脚本参考
sh 复制代码
#!/bin/bash

# ========================
# Immich 备份脚本
# ========================

BACKUP_DIR="/data/immich-backup"
mkdir -p "$BACKUP_DIR"

# 使用精确时间戳命名(避免冲突)
DATE=$(date +%Y%m%d_%H%M%S)

# 1. 停止 Immich 服务
echo "[$(date)] 停止 Immich 服务..."
docker compose -f /immich/docker-compose.yml down

# 2. 备份 library
echo "[$(date)] 备份 library..."
tar -czf "$BACKUP_DIR/.library.tmp.tar.gz" -C /immich library

# 3. 备份 postgres
echo "[$(date)] 备份 postgres..."
tar -czf "$BACKUP_DIR/.postgres.tmp.tar.gz" -C /immich postgres

# 4. 启动 Immich 服务
echo "[$(date)] 启动 Immich 服务..."
docker compose -f /immich/docker-compose.yml up -d

# 5. 删除所有旧备份(只保留最新一份)
echo "[$(date)] 清理旧备份,仅保留最新..."
rm -f "$BACKUP_DIR"/library_*.tar.gz
rm -f "$BACKUP_DIR"/postgres_*.tar.gz

# 6. 重命名临时文件为正式备份
mv "$BACKUP_DIR/.library.tmp.tar.gz" "$BACKUP_DIR/library_$DATE.tar.gz"
mv "$BACKUP_DIR/.postgres.tmp.tar.gz" "$BACKUP_DIR/postgres_$DATE.tar.gz"

echo "[$(date)] 备份完成!"
相关推荐
养海绵宝宝的小蜗16 小时前
LVS(Linux Virtual Server)项目知识点总结
linux·运维·lvs
发量惊人的中年网工17 小时前
工业视觉云边 AI 推理总是卡顿?SD-WAN 打通边缘算力互联
网络·人工智能·网络安全·云计算
AC赳赳老秦17 小时前
软著公开信息批量采集:OpenClaw 抓取软件著作权公开数据,分析企业技术布局方向
大数据·网络·人工智能·python·php·deepseek·openclaw
ShiXZ21317 小时前
Docker 安装 Elasticsearch 7.17.6 完整教程
elasticsearch·docker·容器
liuyunshengsir17 小时前
perftest 工具集ib_write_bw中的 RDMA Write 带宽测试工具手册
网络·rdma
阿黎021417 小时前
Linux驱动
linux
tjjingpan17 小时前
HCIP-Datacom Core Technology V1.0_20 IPv6概述
linux·服务器·网络
我命由我1234517 小时前
Android 开发 - 广播组件(标准广播、有序广播、静态注册广播、分钟到达广播、网络变更广播...)
android·java·开发语言·网络·java-ee·android studio·android-studio
MartinYeung517 小时前
[论文学习]WASP:面向提示注入攻击的Web代理安全性基准测试
前端·网络·学习
数字融合18 小时前
透明化时空联合无缝追踪,构筑无断点全域态势感知网络专项技术
网络·人工智能·virtualenv