文章目录

  • 一、背景与需求
  • 二、部署方法
    • 2.1 我的环境
    • 2.2 准备工作
      • 2.2.1 检查docker环境是否运行正常
      • 2.2.2 查询宿主系统用户id和组id
      • 2.2.3 规划挂载目录
      • 2.2.4 编写启动参数
      • 2.2.5 解决OpenWrt下docker容器桥接模式容器内无法连接公网的问题
      • 2.2.6 解决OpenWrt重启后,docker无法启动的问题
    • 2.3 正式操作
      • 2.3.1 拉取镜像
      • 2.3.2 创建容器
      • 2.3.3 创建.mounted文件
      • 2.3.4 启动容器
      • 2.3.5 初始化容器
      • 2.3.6 拷贝与修改cookies文件名
      • 2.3.7 检查与验证
  • 三、结束语
  • FAQ

一、背景与需求

大概2018年前后折腾过黑群,玩nas做电脑资料的备份,当时也玩的不亦乐乎,但是一年多板子就坏掉了(点背),再加上黑裙的风扇声实在忍不了,2020年初又迷上了J4125工控机软路由方案,因为他小巧,性能强,完全静音无风扇,用到现在2年多了,期间也折腾了不少方案,hyper-v,esxi。最后还是选择了pve,不得不说属实稳,性能也直接拉满。

折腾党,nas还是必须要有的,但我并没有大量的电影资源需要存储,只是用来存储学习资源和电影、家庭全部照片,对内网传输nas的速度并没有极致跑满的要求;能够支持smb、webdav、FTP文件共享,结合ddns,可以随时在任何终端查看和下载,Transmission、Aria2等工具可以将各种所需资源远程直接下载到nas中,这些就足够了。

因为我和媳妇用的都是iPhone,日常给孩子拍照、录视频,实在占用手机存储空间实在太大了,并且只能在自己的手机上看,如果选择iCloud备份和共享,5G根本不够用,扩容的价格实在太高了,我就琢磨有没有办法能够把我和我媳妇的iPhone上照片自动传输到nas上,iPhone上可以删除照片释放空间,实现统一集中存储,通过第三方软件连接到nas,随时远程查看。

有人可能会说了,你这是脱裤子放屁,直接在iphone上安装个FE浏览器、ES浏览器、photosync之类的备份到nas不香吗?对不起,我全部实测过,自动备份都比较扯,苹果杀后台时,什么自动备份也不好使,必须要打开app。听说google photos 和群晖的 photos如果不杀后台时,能够实现无感备份,但google需要魔法,并且备份速度堪忧,群晖nas对我来说太臃肿,不想搭建。百度云盘、阿里云盘的相册备份应用层虽然做的比较好,但同样需要打开app才能自动备份,另外,公有云服务厂商,对视频、图片都是有审核的,虽然是AI审核,充分保密,但把我私人照片去过一遍他们服务器过滤一遍,存在他们的服务器上,时不时的给你丢掉几张,我可不想这样。

查了很多方案,测试了很多软件,都没有达到预期,终于在偶然的一个帖子评论下,看到了icloudpd同步方案,经过测试,效果很令我满意。

几乎完美的方案是:
通过icloudpd这个开源程序实现iPhone照片→iCloud→OpenWrt中的docker(icloudpd)→nas的无感、无缝、无痛、无损、带元数据信息的自动备份。

iCloud 能无感自动后台备份相册到iCloud云端,然后 icloudpd 支持很多环境变量配置参数,自动将源文件从云端同步到 nas !同时 iPhome 上还能保留低像素的缩略图,充分释放iPhone空间。

二、部署方法

网上几乎所有的教程都是在群晖NAS上部署docker的icloudpd容器来实现备份到群晖。所以理论上如果你没有群晖,只要你有docker环境,都是可以部署和使用的,只是不能完全照搬群晖上部署的教程,需要你真正的理解这篇文章中docker使用方法,做一些微调,都是可以的。
下面我讲的方法就是在openwrt的docker环境下部署icloudpd,将数据存储在openwrt挂载的4T机械硬盘上。其中遇到的几个坑,我已经淌过来了,只要按照我说的方法,你一定可以部署成功。

2.1 我的环境

硬件:1台J4125工控机+1根16G内存+1块16G ssd+1块480G ssd+1块4T hdd
虚拟化平台:pve-manager/6.3-2/22f57405

OpenWrt:使用lean大雕源码,自编译带docker-ce插件的x86固件,固件版本:R22.3.13 内核版本:5.15.31

OpenWrt-Lean大源码:https://github.com/coolsnowwolf/lede
icloudpd源码:https://github.com/boredazfcuk/docker-icloudpd

2.2 准备工作

2.2.1 检查docker环境是否运行正常

使用命令:docker version
正确的回显如下:

root@OpenWrt:~# docker version
Client:Version:           20.10.12API version:       1.41Go version:        go1.17.8Git commit:        e91ed57Built:             Sun Apr 10 10:43:41 2022OS/Arch:           linux/amd64Context:           defaultExperimental:      trueServer:Engine:Version:          20.10.12API version:      1.41 (minimum version 1.12)Go version:       go1.17.8Git commit:       459d0dfBuilt:            Sat Mar 26 01:36:39 2022OS/Arch:          linux/amd64Experimental:     falsecontainerd:Version:          1.4.12GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5drunc:Version:          1.0.2GitCommit:        52b36a2dd837e8462de8e01458bf02cf9eea47dddocker-init:Version:          0.19.0GitCommit:        de40ad0

2.2.2 查询宿主系统用户id和组id

命令:id 用户名
openwrt下查询出来root用户名和组id如下:

root@OpenWrt:~# id root
uid=0(root) gid=0(root) groups=0(root)

2.2.3 规划挂载目录

icloudpd程序需要挂载2个目录,1个用于存储配置文件(cookies),1个用储存储下载的照片。
openwrt下,推荐把配置文件存入/root目录下即可,重启不丢失,我的配置文件目录设置为/root/icloudpddjz_config,照片的下载目录我设置到成了通过usb到J4125工控机的4T机械盘上,4T机械盘的挂载目录是/mnt/sdb1,我设置的下载目录就是/mnt/sdb1/back_photos/jiangzhuangdeiphone。
此步骤只是规划挂载路径,你自己心中有数就行了,规划的路径用于后面配置icloudpd容器的启动参数。
为了你更好的理解上面两个挂载路径,贴一张我的lsblk截图:

root@OpenWrt:# lsblk
NAME     MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda        8:0    0 10.2G  0 disk
├─sda1     8:1    0   16M  0 part /boot
│                                 /boot
├─sda2     8:2    0  160M  0 part /rom
├─sda3     8:3    0    2G  0 part /overlay
├─sda4     8:4    0    8G  0 part /opt
└─sda128 259:0    0  239K  0 part
sdb        8:16   0  3.6T  0 disk
└─sdb1     8:17   0  3.6T  0 part /mnt/sdb1

2.2.4 编写启动参数

icloudpd作者在github上已经对每项启动参数做了细致的备注和描述,你可以根据自己的需求,设置所需要的启动参数,作者是国外的大神,如果你看不懂英文,google浏览器自带翻译,你可以直接鼠标右键翻译此网页。
推荐使用notepad++这种纯文本工具编写好,格式不会有误,看着也清楚,我的启动参数如下:

docker create \      #不要改
--name icloudpddjz \        #可以改,只是容器的名字,部署多个容器时,必须要改,不能一致
--hostname icloudpd_boredazfcuk \       #不用改
--network bridge \      #openwrt环境下,用bridge桥接即可
--restart=always \     #不用改
--env user=root \      #openwrt环境下,默认只有root用户,作者建议与宿主系统用户名一致,避免权限问题
--env user_id=0 \      #openwrt环境下,root用户的id是0
--env group=root \     #openwrt环境下,root用户的用户组也是root
--env group_id=0 \     #openwrt环境下,root组id也是0
--env apple_id="xxxxxxx@icloud.com" \       #填写你的iCloud账号
--env authentication_type=2FA \        #身份验证类型,如果你启用了两步验证,则为2FA,否则为Web
--env folder_structure={:%Y/%m} \      #下载目录的文件夹结构,我设置的是/年/月结构
--env auto_delete=True \       #扫描iCloud中“最近删除”的照片和视频,并在本地下载目录中也删除对应的照片和视频。(如果您在iCloud中恢复照片,它将再次下载)
--env synchronisation_interval=43200 \     #同步间隔时间,可设置为以下时段:21600(6 小时)、43200(12 小时)、86400(24 小时)、129600(36 小时)、172800(48 小时)和 604800(7 天)。默认为 86400 秒。设置较短的同步周期时要小心,Apple倾向于限制过于频繁地访问其服务器的连接。设置小于 12 小时的值将显示警告,因为 Apple 可能会限制您。我设置的是每12小时同步一次。
--env icloud_china=True \      #如果设置了这个变量,它将使用云上贵州icloud.com.cn,而不是icloud.com 作为下载源。推荐设置上这个参数。
--env TZ=CST-8 \       #设置容器时间为东八区时间
--env download_path=/home/root/iCloud \        #容器中的目录,此变量设置上比较好,不设定的话,默认也是这个
--volume /root/icloudpddjz_config:/config \     #配置文件挂载路径。冒号前面是openwrt环境的绝对路径,冒号后面是映射到容器里的路径,你需要修改的就是冒号前面的。
--volume /mnt/sdb1/back_photos/jiangzhuangdeiphone:/home/root/iCloud \      #照片下载路径。冒号前面是openwrt环境的绝对路径,冒号后面是映射到容器里的路径,你需要修改的就是冒号前面的。
boredazfcuk/icloudpd        #不要改

2.2.5 解决OpenWrt下docker容器桥接模式容器内无法连接公网的问题

这是我遇到的第1个坑,启动完容器后,程序始终无法运行到登录那步,经过排查后才发现,从容器里是无法ping通百度的,能返回百度的ip,但不通。google后才发现,据说是固件的bug。按照如下步骤修改:
1、Luci -> 网络 -> 防火墙 -> 转发:接受
2、添加如下防火墙规则

iptables -t nat -A POSTROUTING -s 172.31.0.0/16 ! -o docker0 -j MASQUERADE

备注:172.17.0.0/16 根据你的docker环境的bridge网络情况设置
3、删除 docker0 并重启

ip link del docker0
reboot

2.2.6 解决OpenWrt重启后,docker无法启动的问题

这是另一个坑,是我跑起来icloudpd以为大工告成时发现的,但我特意做了一个鲁棒性测试,就是路由器在重启后,程序是否会自动启动并正常运行。结果发现,docker起不来了,报错:unix:///var/run/docker.sock. Is the docker daemon running?
尝试了很多方法,最终有效的方法是:
a) 修改daemon.json文件。
使用命令:vi /etc/docker/daemon.json
增加"registry-mirrors": ["https://registry.docker-cn.com"]参数,修改后的文件内容如下:

{"data-root": "/opt/",
"log-level": "warn",
"registry-mirrors": ["https://registry.docker-cn.com"]
}

b) 修改cgroupfs-mount文件。
使用命令:vi /etc/init.d/cgroupfs-mount
注释掉其中的这三行:

#    if mountpoint -q /sys/fs/cgroup; then
#       umount /sys/fs/cgroup/
#   fi

c) 修改dockerd文件。
/etc/init.d/dockerd这个文件,将里面的START参数从25改为60,修改后的文件内容如下:

#!/bin/sh /etc/rc.commonUSE_PROCD=1
START=60start_service() {local nofile=$(cat /proc/sys/fs/nr_open)local wanmode=$(uci get dockerd.@docker[0].wan_mode)if [ $wanmode = "1" ] ;thendockerwan=" "elsedockerwan="--iptables=false"fiprocd_open_instanceprocd_set_param stderr 1procd_set_param command /usr/bin/dockerd $dockerwanprocd_set_param limits nofile="${nofile} ${nofile}"procd_close_instance}

2.3 正式操作

2.3.1 拉取镜像

拉取命令:docker pull boredazfcuk/icloudpd:latest
检查是否拉取成功,命令:docker images
正确的回显应包含icloudpd的镜像已被拉取回来,如下:

root@OpenWrt:~# docker images
REPOSITORY               TAG       IMAGE ID       CREATED        SIZE
boredazfcuk/icloudpd     latest    91aba32e5f75   5 weeks ago    249MB
portainer/portainer-ce   latest    ed396c816a75   2 months ago   280MB

2.3.2 创建容器

使用上面准备好的启动参数,创建容器,创建成功后,默认是不启动的,使用命令docker ps -a查看容器是否已创建成功。
正确的回显如下:

root@OpenWrt:~# docker ps -a
CONTAINER ID   IMAGE                    COMMAND                  CREATED        STATUS                       PORTS                                                           NAMES
1d65bdc40bef   boredazfcuk/icloudpd     "/bin/sh -c /usr/loc…"   23 hours ago   Exited (137) 7 seconds ago                                                                   icloudpddjz
aad39ffd5f90   portainer/portainer-ce   "/portainer"             3 days ago     Up 2 days                    8000/tcp, 9443/tcp, 0.0.0.0:9999->9000/tcp, :::9999->9000/tcp   portainer

2.3.3 创建.mounted文件

这个文件是作者加入的故障保护机制,只有这个文件存在于下载目录当中,同步才会真正开始,否则不会向下载目录写入任何文件。所以我们需要在启动容器前,在下载目录中,手动创建这个文件。使用如下命令,创建这个文件:

root@OpenWrt:/mnt/sdb1/back_photos/jiangzhuangdeiphone# touch .mounted
root@OpenWrt:/mnt/sdb1/back_photos/jiangzhuangdeiphone# ll
drwxr-x---    3 root     root          4096 Apr 14 13:13 ./
drwxrwxrwx    3 root     root          4096 Apr 11 19:39 ../
-rw-r-----    1 root     root             0 Apr 12 05:29 .mounted
drwxr-x---    3 root     root          4096 Apr 14 13:13 2022/

2.3.4 启动容器

使用命令docker start icloudpddjz启动容器,请注意修改成你自己设置的容器名。
再使用docker ps -a查看容器是否已经成功启动,我们发现icloudpddjz容器的状态已经是up,说明启动成功。

root@OpenWrt:~# docker ps -a
CONTAINER ID   IMAGE                    COMMAND                  CREATED        STATUS                        PORTS                                                           NAMES
1d65bdc40bef   boredazfcuk/icloudpd     "/bin/sh -c /usr/loc…"   23 hours ago   Up About a minute (healthy)                                                                   icloudpddjz
aad39ffd5f90   portainer/portainer-ce   "/portainer"             3 days ago     Up 2 days                     8000/tcp, 9443/tcp, 0.0.0.0:9999->9000/tcp, :::9999->9000/tcp   portainer

查看日志的命令docker logs -f --tail 100 容器名,也可以通过OpenWrt的Portainer界面的日志按钮去看,比较方便。
如果你看到如下的日志,说明程序已经正常跑起来了,但没有运行初始化程序,也就是没有登录账号的cookies

ERROR    Keyring file /config/python_keyring/keyring_pass.cfg does not exist.
INFO      - Please add the your password to the system keyring using the --Initialise script command line option.
INFO      - Syntax: docker exec -it <container name> sync-icloud.sh --Initialise
INFO      - Example: docker exec -it icloudpd sync-icloud.sh --Initialise
INFO     Restarting in 5 minutes...

恭喜你,距离成功已经走了一大半路程。

2.3.5 初始化容器

此时,你需要运行初始化脚本,在宿主机OpenWrt下运行(请注意修改容器名):
docker exec -it icloudpddjz sync-icloud.sh --Initialise
初始化脚本会引导你一步步的登录到iCloud,从而保存下来Web cookie以及两步验证的cookie,其中Web cookie有效期2个月,两步验证的cookie有效期3个月。

提示输入你的密码,请盲输,就是看不到的,输完直接回车(此时你的iPhone手机会提示是否允许登录,先忽略不管):

2022-04-14 13:07:57 INFO     Skip live photos: False
2022-04-14 13:07:57 INFO     Number of most recently added photos to download: Download All Photos
2022-04-14 13:07:57 INFO     Stop downloading when prexisiting files count is: Download All Photos
2022-04-14 13:07:57 INFO     Live photo size: original
2022-04-14 13:07:57 INFO     Skip videos: False
2022-04-14 13:07:57 INFO     Convert HEIC to JPEG: False
2022-04-14 13:07:57 INFO     JPEG conversion quality: 90
2022-04-14 13:07:57 INFO     Downloading from: icloud.com.cn
2022-04-14 13:07:57 WARNING  Downloading from icloud.com.cn is untested. Please report issues at https://github.com/boredazfcuk/docker-icloudpd/issues
2022-04-14 13:08:00 INFO     Script launch parameters: --Initialise
2022-04-14 13:08:00 INFO     Group, root:0, already created
2022-04-14 13:08:00 INFO     User, root:0, already created
2022-04-14 13:08:00 INFO     Set owner, root, on iCloud directory, if required
2022-04-14 13:08:00 INFO     Set group, root, on iCloud directory, if required
2022-04-14 13:08:00 INFO     Correct owner on icloudpd temp directory, if required
2022-04-14 13:08:00 INFO     Correct group on icloudpd temp directory, if required
2022-04-14 13:08:00 INFO     Correct owner on config directory, if required
2022-04-14 13:08:00 INFO     Correct group on config directory, if required
2022-04-14 13:08:00 INFO     Correct owner on keyring directory, if required
2022-04-14 13:08:00 INFO     Correct group on keyring directory, if required
2022-04-14 13:08:00 INFO     Set 750 permissions on iCloud directories, if required
2022-04-14 13:08:00 INFO     Set 640 permissions on iCloud files, if required
2022-04-14 13:08:00 INFO     Configure password
2022-04-14 13:08:00 INFO     Adding password to keyring file: /config/python_keyring/keyring_pass.cfg
Enter iCloud password for xxxxxx@icloud.com: 

询问你是否保存密码,必须输入y:

2022-04-14 13:08:00 INFO     Configure password
2022-04-14 13:08:00 INFO     Adding password to keyring file: /config/python_keyring/keyring_pass.cfg
Enter iCloud password for xxxxxx@icloud.com:
Save password in keyring?  [y/N]: y

提示让你选择那种验证方式,输入0,这时手机会收到短信验证码,请忽略不管。(此时点击iPhone屏幕上的允许):

2022-04-14 13:08:00 INFO     Configure password
2022-04-14 13:08:00 INFO     Adding password to keyring file: /config/python_keyring/keyring_pass.cfg
Enter iCloud password for xxxxxxx@icloud.com:
Save password in keyring?  [y/N]: y
Two-step authentication required. Your trusted devices are:0: SMS to *********61
Which device would you like to use? [0]: 0

上一步在你iPhone上点击了允许后,手机会弹出6位验证码,在这里输入弹窗验证码,记住Please enter validation code就是让你输入弹窗验证码,不是手机短信验证码:

2022-04-14 13:08:00 INFO     Adding password to keyring file: /config/python_keyring/keyring_pass.cfg
Enter iCloud password for xxxxxxx@icloud.com:
Save password in keyring?  [y/N]: y
Two-step authentication required. Your trusted devices are:0: SMS to *********61
Which device would you like to use? [0]: 0
Please enter validation code: 668428

程序会再次提醒你,选择那种验证方式,需要继续填写0,回车

Save password in keyring?  [y/N]: y
Two-step authentication required. Your trusted devices are:0: SMS to *********61
Which device would you like to use? [0]: 0
Please enter validation code: 668428
Failed to verify verification code
2022-04-14 13:10:22 INFO     Correct owner on config directory, if required
2022-04-14 13:10:22 INFO     Correct group on config directory, if required
2022-04-14 13:10:22 INFO     Generate 2FA cookie using password stored in keyring file0: SMS to *********611: Enter two-factor authentication code
Please choose an option: [0]: 0

这时,你的手机会再次收到1条短信验证码,请将短信验证码输入:

2022-04-14 13:10:22 INFO     Correct group on config directory, if required
2022-04-14 13:10:22 INFO     Generate 2FA cookie using password stored in keyring file0: SMS to *********611: Enter two-factor authentication code
Please choose an option: [0]: 0
Please enter two-factor authentication code: 934157

如果你错误的将弹窗验证码输入,这将会无法成功创建cookies文件,就会出现下面的报错,如果输错,请重新运行初始化脚本:

ERROR    2FA information missing from cookie. Authentication has failed
ERROR     - Was the correct password entered?
ERROR     - Was the 2FA code mistyped?
ERROR     - Are you based in China? You may need to set the icloud_china variable

看到这个提示,就是成功获取到cookies了:

Please enter two-factor authentication code: 934157
2022-04-14 13:11:20 INFO     Two factor authentication cookie generated. Sync should now be successful

2.3.6 拷贝与修改cookies文件名

其他人的教程是没有这个步骤的,其他人也没有在OpenWrt下运行docker版icloudpd的,这也是我淌过来的坑。
我不确定这是不是程序的bug,或者可能也是我环境的问题,总之,如果你在执行完上一步,如果看到日志和我下面的一样,仍然提示Keyring file /config/python_keyring/keyring_pass.cfg does not exist,仍然要求你运行初始化脚本,那么你大概率遇到的问题和我一样。我的日志报错如下:

2022-04-14 13:07:18 WARNING  Downloading from icloud.com.cn is untested. Please report issues at https://github.com/boredazfcuk/docker-icloudpd/issues
2022-04-14 13:07:20 INFO     Creating directory: /config/python_keyring/
2022-04-14 13:07:20 INFO     Group, root:0, already created
2022-04-14 13:07:20 INFO     User, root:0, already created
2022-04-14 13:07:20 INFO     Set owner, root, on iCloud directory, if required
2022-04-14 13:07:20 INFO     Set group, root, on iCloud directory, if required
2022-04-14 13:07:20 INFO     Correct owner on icloudpd temp directory, if required
2022-04-14 13:07:20 INFO     Correct group on icloudpd temp directory, if required
2022-04-14 13:07:20 INFO     Correct owner on config directory, if required
2022-04-14 13:07:20 INFO     Correct group on config directory, if required
2022-04-14 13:07:20 INFO     Correct owner on keyring directory, if required
2022-04-14 13:07:20 INFO     Correct group on keyring directory, if required
2022-04-14 13:07:20 INFO     Set 750 permissions on iCloud directories, if required
2022-04-14 13:07:20 INFO     Set 640 permissions on iCloud files, if required
2022-04-14 13:07:20 INFO     Configure password
2022-04-14 13:07:20 ERROR    Keyring file /config/python_keyring/keyring_pass.cfg does not exist
2022-04-14 13:07:20 INFO      - Please add the your password to the system keyring using the --Initialise script command line option
2022-04-14 13:07:20 INFO      - Syntax: docker exec -it <container name> sync-icloud.sh --Initialise
2022-04-14 13:07:20 INFO      - Example: docker exec -it icloudpd sync-icloud.sh --Initialise
2022-04-14 13:07:20 INFO     Waiting for keyring file to be created...

解决办法:
需要手动把上一步获取的cookies拷贝到python_keyring目录下一份,并修改文件名为keyring_pass.cfg,并赋予文件777权限,cookie在你启动从参数中设置的配置文件挂载目录下,我的在/root/icloudpddjz_config目录下。
操作命令如下(请注意修改你的cookies文件名):

root@OpenWrt:~/icloudpddjz_config# ls
DAYS_REMAINING        xxxxxicloudcom  python_keyring
root@OpenWrt:~/icloudpddjz_config# cp -rp xxxxxicloudcom python_keyring/
root@OpenWrt:~/icloudpddjz_config# cd python_keyring/
root@OpenWrt:~/icloudpddjz_config/python_keyring# mv xxxxxicloudcom keyring_pass.cfg
root@OpenWrt:~/icloudpddjz_config/python_keyring# chmod 777 keyring_pass.cfg
root@OpenWrt:~/icloudpddjz_config/python_keyring# ll
drwxr-xr-x    2 root     root          4096 Apr 14 13:13 ./
drwxrwxrwx    3 root     root          4096 Apr 14 13:13 ../
-rwxrwxrwx    1 root     root           838 Apr 14 13:11 keyring_pass.cfg*

2.3.7 检查与验证

当你手动创建好这个keyring_pass.cfg文件的时候,你的程序日志中,就会正常的运行下去,并且开始同步照片了,正常的日志如下:

2022-04-14 13:13:30 INFO     Keyring file exists, continuing
2022-04-14 13:13:30 INFO     Check download directory mounted correctly
2022-04-14 13:13:30 INFO     Failsafe file /home/root/iCloud/.mounted exists, continuing
2022-04-14 13:13:30 INFO     Set owner, root, on iCloud directory, if required
2022-04-14 13:13:30 INFO     Set group, root, on iCloud directory, if required
2022-04-14 13:13:30 INFO     Correct owner on icloudpd temp directory, if required
2022-04-14 13:13:30 INFO     Correct group on icloudpd temp directory, if required
2022-04-14 13:13:30 INFO     Correct owner on config directory, if required
2022-04-14 13:13:30 INFO     Correct group on config directory, if required
2022-04-14 13:13:30 INFO     Correct owner on keyring directory, if required
2022-04-14 13:13:30 INFO     Correct group on keyring directory, if required
2022-04-14 13:13:30 INFO     Set 750 permissions on iCloud directories, if required
2022-04-14 13:13:30 INFO     Set 640 permissions on iCloud files, if required
2022-04-14 13:13:30 INFO     Sync user root
2022-04-14 13:13:30 INFO     Synchronisation starting at 13:13:30
2022-04-14 13:13:30 INFO     Check 2FA Cookie
2022-04-14 13:13:30 INFO     Cookie exists, check expiry date
2022-04-14 13:13:30 INFO     Valid two factor authentication cookie found. Days until expiration: 89
2022-04-14 13:13:30 INFO     Check download directory mounted correctly
2022-04-14 13:13:30 INFO     Failsafe file /home/root/iCloud/.mounted exists, continuing
2022-04-14 13:13:30 INFO     Check for new files using password stored in keyring file
2022-04-14 13:13:30 INFO     Generating list of files in iCloud. This may take a long time if you have a large photo collection. Please be patient. Nothing is being downloaded at this time
/home/root/iCloud/2022/04/IMG_4027.MOV
/home/root/iCloud/2022/04/IMG_4025.MOV
2022-04-14 13:13:41 INFO     Check successful
2022-04-14 13:13:41 INFO     New files detected: 2
2022-04-14 13:13:41 INFO     Starting download of new files for user: root
2022-04-14 13:13:41 INFO     Downloading new files using password stored in keyring file...
2022-04-14 13:13:41 INFO     iCloudPD launch command: /usr/bin/icloudpd --directory /home/root/iCloud --cookie-directory /config --folder-structure {:%Y/%m} --username xxxxxxx@icloud.com --auto-delete  2>/tmp/icloudpd/icloudpd_download_error
2022-04-14 13:13:42 DEBUG    Authenticating...
2022-04-14 13:13:51 DEBUG    Looking up all photos and videos from album All Photos...
2022-04-14 13:13:52 INFO     Downloading 2 original photos and videos to /home/root/iCloud ...
2022-04-14 13:13:52 INFO     Downloading /home/root/iCloud/2022/04/IMG_4027.MOV
2022-04-14 13:14:24 INFO     Downloading /home/root/iCloud/2022/04/IMG_4025.MOV
2022-04-14 13:15:23 INFO     All photos have been downloaded!
2022-04-14 13:15:23 INFO     Deleting any files found in 'Recently Deleted'...
2022-04-14 13:15:24 INFO     Synchronisation complete for root
2022-04-14 13:15:24 INFO     Web cookie expires: 2022-06-13 @ 05:10:25
2022-04-14 13:15:24 INFO     Two factor authentication cookie expires: 2022-07-13 @ 05:11:11
2022-04-14 13:15:24 INFO     Days remaining until expiration: 89
2022-04-14 13:15:24 INFO     iCloud login counter = 2
2022-04-14 13:15:24 INFO     Synchronisation ended at 13:15:24
2022-04-14 13:15:24 INFO     Total time taken: 00:01:54
2022-04-14 13:15:24 INFO     Next synchronisation at 01:13:30

检查一下下载目录,确实已经同步成功了:

root@OpenWrt:~# ls /mnt/sdb1/back_photos/jiangzhuangdeiphone/2022/04/
IMG_4025.MOV  IMG_4027.MOV

三、结束语

我设置的同步间隔是12小时,如果你想手动触发同步,只需要重启容器即可,命令是docker restart <容器名>

OK,大工告成,虽然过程比较波折,但最终还是成功了,实测直接在OpenWrt下reboot系统,重启后icloudpd也是可以正常运行的。

后面有时间的时候,再搞一下PhotoPrism来规整nas上的照片。
enjoying~

FAQ

1、iCloud 空间只有 5G 怎么办?
答:满了后,可以手动删除云端 iCloud 相册(最近删除里也要删除,否则到了同步时间,会自动最近删除列表中读取到也同步删除),这个操作并不会删除 nas 上的已经备份的数据;如果不想花一分钱,只使用5G 的免费空间,无非就是云端删除频繁一些,基本能满足需求;如果是重度用户,开个每个月 6 月 50G 的 iCloud 服务;
2、家人的照片或其他人的照片怎么管理?
答:再开一个容器,登录其他iCloud账号。
3、我没有OpenWrt软路由怎么办?
答:仔细看教程,只要有docker环境和足够大的存储空间,都是可以的。
4、icloudpd的方案有哪些缺点?
答:iCloudpd 每两个月还是三个月需要重新授权访问;不过可以配置提醒服务(我的教程里没有设置,感兴趣的可以自己去作者git上看设置参数,容器创建时加入参数即可);

OpenWrt下使用docker安装icloudpd实现iPhone照片备份私有云盘nas相关推荐

  1. 贝壳如何docker安装openwrt_OpenWrt下的Docker安装jellyfin

    Jellyfin是一款媒体服务器软件,可在多个平台管理和播放流媒体文件.它是Emby和Plex之外的完美替代品,可通过多个应用程序从专用服务器向终端用户设备提供媒体.Jellyfin是Emby 3.5 ...

  2. 本地虚拟机上的docker安装mysql_linux下利用Docker安装mysql的步骤

    作为一个测试人员,在学习的过程中,可能经常需要去在linux下安装一些软件,有的软件通过搜索别人的博客教程进行安装的话,随着一些软件的升级,以及虚拟机/服务器镜像版本不一致等外部因素,都有可能导致安装 ...

  3. Ubuntu下利用docker安装微信

    Ubuntu下利用docker安装微信 一.安装docker 二.允许所有用户访问X11服务 三.拉镜像 四.启动 五.常用命令 六.启动脚本 七.微信图标 八.新建桌面图标 本次安装是基于Ubunt ...

  4. Linux下使用docker安装部署Sonar Qube

    文章目录 Linux下使用docker安装部署Sonar Qube 一.环境准备 二.部署步骤 三.使用 四.结束 Linux下使用docker安装部署Sonar Qube 一.环境准备 本文默认会使 ...

  5. Ubuntu下通过docker安装wechat

    Ubuntu下通过docker安装微信 一.安装docker sudo apt update sudo apt upgrade sudo apt full-upgrade# 安装证书 sudo apt ...

  6. Centos下的Docker安装

    Ubuntu下的docker安装请参考:Ubuntu下docker安装 本文主要演示如何在centos下安装docker环境 提示:以下安装过程必须在能够连接Internet的情况进行,先使用ping ...

  7. 本地搭建私有云盘:虚拟机安装群晖NAS 1/5

    系列文章 本地搭建私有云盘:虚拟机安装群晖NAS 1/5 本地搭建私有云盘:安装Synology Assistant 2/5 本地搭建私有云盘:群晖系统存储空间设置 3/5 本地搭建私有云盘设定:设置 ...

  8. 不买NAS搭建私有云盘:虚拟机安装群晖 1-5

    系列文章 ​​​​​​​不买NAS搭建私有云盘:虚拟机安装群晖 1-5 不买NAS搭建私有云盘:安装Synology Assistant 2-5 不买NAS搭建私有云盘:群晖系统存储空间设置 3-5 ...

  9. 不买NAS,也能用cpolar搭建私有云盘4 (设定群晖共享文件夹并安装cpolar)

    系列文章 不买NAS,也能用cpolar搭建私有云盘1 (虚拟机安装群晖) 不买NAS,也能用cpolar搭建私有云盘2 (安装Synology Assistant) 不买NAS,也能用cpolar搭 ...

最新文章

  1. Ant Design Pro 改变默认启动端口号
  2. js 区分 safari chrome iso
  3. 对学校的希望和寄语_南中医举行2020年开学典礼,校长胡刚寄语“后浪”:乘风破浪,扬帆起航...
  4. C语言isalnum函数举例,C语言中的isalnum()函数
  5. 春节回来了,你收获了什么?
  6. Ingress-nginx工作原理和实践
  7. oracle创建public链接,如何在oracle直接使用地址来创建database link
  8. 秀米复制到公众号格式变了_公众号文章下载神器!支持批量、多格式,可下载历史全部文章...
  9. 数学建模学习笔记(三十一)模糊评价法
  10. 软件测试的概括及流程
  11. 苹果CMS V10后台登录验证码错误解决方法
  12. 计算机软件工作室起名'',游戏工作室起名大全
  13. 阿里云SMS短信服务的使用
  14. 谁将成为人工智能行业的“领头羊”?
  15. fwrite php utf8,坚持通过PHP的fwrite编写UTF-8文件
  16. 谈谈我的框架设计经验
  17. 树莓派安装宝塔Linux面板教程
  18. AI:2020年6月24日北京智源大会演讲分享之知识智能专题论坛——11:30-12:00唐杰 教授《CogDL:An Extensive Research Toolkit for Deep Le》
  19. [Java]使用ArrayList类来把54张扑克牌发给3位玩家各17张,剩下3张是底牌
  20. 打开阿尔卡特511大猫路由功能

热门文章

  1. 简单的基于Tacotron2的中英文混语言合成, 包括code-switch和voice clone. 以及深入结构设计的探讨.
  2. error: #109: expression preceding parentheses of apparent call must have (pointer-to-) function typ
  3. QML实现的支持动图的编辑器(比之前要好)
  4. 用Discuz 搭建个人论坛
  5. 解决了计算机处理汉字的问题,计算机处理汉字必须解决的三个问题分别是汉字...
  6. LCD液晶屏显示接口总结
  7. 段码液晶屏驱动芯片如何选择
  8. 【保研】2021/2022复旦计算机夏令营/预推免面试
  9. 关于 uintptr_t和intptr_t 类型
  10. 泰勒公式求解极限(泰勒展不开)