替代群晖相册的工具:immich

一直以来,我都用群晖自带的 Photos 来备份手机照片,因为除了群晖相册之外,还没用过其他好用的相册工具,自从上次群晖文件系统都变成只读之后就有了用Ubuntu替换群晖的想法。然后就在网络中发现了Immich,immich有Android手机客户端,可以直接从f-droid安装。

官方部署教程

下面简要记录部署教程:

下载安装部署必要文件

我们使用docker-compose部署,首先创建一个存储docker-compose.yml.env 文件的目录.

1
2
mkdir ./immich-app
cd ./immich-app

下载docker-compose.ymlexample.env文件

下载docker-compose.yml文件

1
wget https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml

下载.env文件

1
wget -O .env https://github.com/immich-app/immich/releases/latest/download/example.env

或者用浏览器下载这两个文件,然后放到刚刚创建的目录中。

Note: If you downloaded the files from your browser, also ensure that you rename example.env to .env.

修改.env文件中的变量值

  • Populate custom database information if necessary.
  • UPLOAD_LOCATION 设置成你的照片存储路径.
  • DB_PASSWORD 设置数据库的密码
  • TYPESENSE_API_KEY 设置成随机字符串。

可以修改docker-compose.yml文件,在Postgres数据库那里增加5432端口映射,把Postgres容器的5432端口映射到本地,这样后期本地安装应用的时候可以用到docker的数据库。

创建容器

From the directory you created in Step 1, (which should now contain your customized docker-compose.yml and .env files) run docker-compose up -d.

Start the containers using docker compose command

1
docker-compose up -d     # or `docker compose up -d` based on your docker-compose version

现在可以访问http://<machine-ip-address>:2283开始创建你的管理员账户了。

设置Nginx反向代理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
server {
listen 618 default_server;
listen [::]:618 default_server;

# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;

#root /var/www/start;

# Add index.php to the list if you are using PHP
#index index.html index.htm index.nginx-debian.html;

server_name www.redtux.cn;

client_max_body_size 50000M;

location / {
proxy_pass http://127.0.0.1:2283;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

# http://nginx.org/en/docs/http/websocket.html
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
}
}

升级

Immich的版本迭代速度相当快,如果有新版本发布,可以切换到docker-compose.yml文件存放到目录,然后执行如下命令:

1
docker-compose pull && docker-compose up -d     # Or `docker compose up -d`

备份数据库

The recommended way to backup and restore the Immich database is to use the pg_dumpall command.

备份

1
docker exec -t immich_postgres pg_dumpall -c -U postgres | gzip > "/path/to/backup/dump.sql.gz"

恢复

1
2
3
4
5
6
7
docker-compose down -v  # 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 -U postgres -d immich # Restore Backup
docker-compose up -d # Start remainder of Immich apps

桌面系统上传工具

依赖 Node.js 16以上版本和npm

安装node.js后执行如下命令安装immich桌面端上传工具:

1
npm i -g immich

把本地目录~/toUpload中的照片上传到服务器:

1
immich upload --key sikjo7P3o5jLddv3pfiDjH3RVfj4yIuptOti8SetM --server http://192.168.0.6:2283/api --recursive ~/toUpload

把本地目录~/toUpload中的照片上传到服务器,并加入到AlbumName相册中:

1
immich upload --key sikjo7P3o5jLddv3pfiDjH3RVfj4yIuptOti8SetM --server http://192.168.0.6:2283/api --recursive --album AlbumName ~/toUpload

选项:

Parameter Description
–yes / -y Assume yes on all interactive prompts
–recursive / -r Include subfolders
–delete / -da Delete local assets after upload
–key / -k User’s API key
–server / -s Immich’s server address
–threads / -t Number of threads to use (Default 5)
–album/ -al Create albums for assets based on the parent folder or a given name
–import/ -i Import gallery (assets are not uploaded)

号外

还有一个相册工具 PhotoPrism,这是一个优秀的成熟的相册,唯一缺憾就是没有手机客户端。

替代群晖相册的工具:immich

http://tux.red/2023/08/05/Nas/immich/

作者

redtux

发布于

2023-08-05

更新于

2023-08-20

许可协议

You need to set install_url to use ShareThis. Please set it in _config.yml.
You forgot to set the business or currency_code for Paypal. Please set it in _config.yml.

评论

You forgot to set the shortname for Disqus. Please set it in _config.yml.