群晖NAS自动同步iCloud照片详解icloudpd
一。打开群晖文件管理File Station,新建所需文件夹及文件
docker/icloudpd/mine
文件/iCloud
文件/iCloud/.mounted
第1个在dockers文件夹下
第2个iCloud文件夹是用于储存下载照片的文件夹,存放位置根据你自己的来,我是在名为“文件”的文件夹下面
第3个.mounted文件可以在电脑上新建一个TXT文本,然后把文件名改成.mounted,然后上传到/iCloud文件夹下面
二。创建容器
1.打开Container Manager在镜像仓库中搜索boredazfcuk/icloudpd,然后双击下载

2.生成容器
在映像里点击运行下载好的docker


3.储存空间设置里映射文件夹
docker/icloudpd/mine --> /config
文件/iCloud --> /iCloud

4.添加环境变量

修改环境变量:
TZ:UTC 中UTC改为Asia/Shanghai
注意:apple_id后面涂黑的是你自己的苹果ID号,
user中wsfun改为你群晖登陆的id号
user_id后面为你自己的(查询群晖用户的id,主要就是打开群晖的SSH,然后用putty或其他终端登录上去,用你的群晖用户名和密码,然后输入id这个指令看一下)下面图中uid=1026(wsfun)其中1026就是我的群晖id为wsfun的值

convert_heic_to_jpeg为设置是否下载时将HEIC文件转换为JPEG格式,同时保留原始文件,如设置此变量convert_heic_to_jpeg设置此选项为True,以将下载的HEIC文件转换为JPEG,同时保留原始文件。
jpeg_quality为设置HEIC文件到JPEG转换的质量,可设置变量jpeg_quality,数值为0(最低质量)到100(最高质量),不添加这个变量则默认为90
还有其他变量自己选择添加:
1.设置同步时间周期,默认为86400秒(24小时),自动运行同步iCloud上新增的 内容,如需修改,可在创建容器时,新增一下变量download_interval,并设置相应的值,例如43200(12小时)、129600(36小时)等,理论上设置为1秒也是可以的,但是苹果倾向于限制过于频繁的访问其服务器链接,默认设置个人认为是最佳值,iPhone会立即将文件上传到iCloud,如果手机丢失,当天拍摄的内容在iCloud也是安全的,容器会在晚上运行时下载这些内容。
download_interval:43200
2.设置多个容器同步的分钟数,默认为0,如果需要自动同步过多AppleID的iCloud内容,可以进行设置,新增变量download_delay,例如30分钟,避免多账户同时访问遭到苹果的风控限制。
download_delay:30
3.设置iCloud账户身份验证类型,默认为2FA,如果启用了双重认证,则有效值为2FA,否则为Web,如iCloud账户未启用双重认证,则必须新增变量authentication_type,设置为Web,如下所示:
authentication_type:Web
4.设置下载目标目录的文件夹结构,变量folder_structure,默认为 {:%Y/%m/%d}(年/月/日),可按需进行调整,例如:年/月
folder_structure:{:%Y/%m}
5.设置是否跳过已下载检查(增量同步),默认为False(不跳过),也就是默认为每次启动只同步新增内容,如果要重新完全同步,可设置变量skip_check的值为True
skip_check:True
6.设置扫描“最近删除”文件夹,并删除其中找到的所有文件,意思是,你手机上删除的照片,是否同步删除,默认为不扫描,也就是不同步删除,如果你想同步删除或恢复,可设置变量auto_delete的值为True
auto_delete:True
5.设置完成后点击完成
三。回到Docker界面,双击刚刚创建好的icloudpd容器,选择操作,选择打开终端机

选择新增,选择通过命令启动

输入命令/bin/sh 点击确定

选择sh输入初始化命令:sync-icloud.sh --Initialise

开始进行苹果账号的双重认证了,创建cookie文件,有效期默认为90天,到期后需再进行一次认证:
如下图所示,按提示输入你的AppleID密码,盲输,这里不会显示你输入的内容,输入完成后回车;
Enter iCloud password for email@wsfun1@139.com:
.如密码正确,会提示询问你是否保存,输入“y”后回车
Save password in keyring? [y/N]: y
这时候你登录了AppleID的设备上会提示是否允许登录的弹窗,点击【允许】登录,获取弹窗验证码,将该验证码按提示输入后回车;
校验通过后,Apple会发送二次验证码,这时候你设备上再有弹窗点击【允许】即可,弹窗验证码验证码收到后,按提示输入6位数字的短信验证码,回车后完成二次验证文件的创建
所有配置到此结束,然后重启容器,查看日志,看到以下内容,说明运行成功,在iCloud中生成文件列表,等着自动下载iCloud照片即可,默认为24小时增量下载一次,默认下载原始尺寸文件。

作者声明本文无利益相关,欢迎值友理性交流,和谐讨论~

找骨头的狗
File "pyicloud_ipd/cmdline.py", line 114, in main
File "pyicloud_ipd/base.py", line 278, in __init__
File "pyicloud_ipd/base.py", line 327, in authenticate
File "pyicloud_ipd/base.py", line 375, in _authenticate_with_token
pyicloud_ipd.exceptions.PyiCloudConnectionException: Apple insists on using iClo
ud.com.cn for your request. Please use --domain parameter
[PYI-591:ERROR] Failed to execute script 'icloud' due to unhandled exception!
2025-11-16 13:25:56 ERROR Keyring file does not exist. Please try again
输入密码后提示这里,然后手机会收到二次验证码。但是无法继续。不知道哪里操作有问题
校验提示文案
meggal
does not exist
2025-11-24 15:47:27 ERROR - Please add the your password to the system keyrin
g using the --Initialise script command line option
2025-11-24 15:47:27 ERROR - Syntax: docker exec -it sync-icl
oud.sh --Initialise
2025-11-24 15:47:27 ERROR - Example: docker exec -it icloudpd sync-icloud.sh
--Initialise
2025-11-24 15:47:27 ERROR Waiting for keyring file to be created...
不知道哪里做错了。
2025-11-24 15:47:27 ERROR - Please add the your password to the system keyrin
g using the --Initialise script command line option
怎么添加这个密码信息呢?
校验提示文案
meggal
does not exist
2025-11-24 15:47:27 ERROR - Please add the your password to the system keyrin
g using the --Initialise script command line option
2025-11-24 15:47:27 ERROR - Syntax: docker exec -it sync-icl
oud.sh --Initialise
2025-11-24 15:47:27 ERROR - Example: docker exec -it icloudpd sync-icloud.sh
--Initialise
2025-11-24 15:47:27 ERROR Waiting for keyring file to be created...
不知道哪里做错了。
2025-11-24 15:47:27 ERROR - Please add the your password to the system keyrin
g using the --Initialise script command line option
怎么添加这个密码信息呢?
校验提示文案
找骨头的狗
File "pyicloud_ipd/cmdline.py", line 114, in main
File "pyicloud_ipd/base.py", line 278, in __init__
File "pyicloud_ipd/base.py", line 327, in authenticate
File "pyicloud_ipd/base.py", line 375, in _authenticate_with_token
pyicloud_ipd.exceptions.PyiCloudConnectionException: Apple insists on using iClo
ud.com.cn for your request. Please use --domain parameter
[PYI-591:ERROR] Failed to execute script 'icloud' due to unhandled exception!
2025-11-16 13:25:56 ERROR Keyring file does not exist. Please try again
输入密码后提示这里,然后手机会收到二次验证码。但是无法继续。不知道哪里操作有问题
校验提示文案