Setting up icloudpd on Synology NAS

Last Updated on 12/11/2024

In this article I document how I setup backups for iCloud library in a Synology NAS (ds923+ to be precise).

Out of all the solutions out there, I opted to have a copy in my NAS rather than moving everything to it. And I wanted a way that needs minimal recurring effort. So went with icloudpd docker container which would directly download stuff from iCloud. I don't have to keep originals on my phone and wait to get home to have the backed up.

This was a lot figure out.

The repo - https://github.com/boredazfcuk/docker-icloudpd

Setting up the filesystem

Initially, we need to create 2 directories. One for the container settings and one for the location of downloads.

In /docker, the default directory Container Manager creates, I create icloudpd/config directory so that the container can create the settings.

For the download path, I use volume1/homes/<user>/Photos/icloud so Synology Photos has access to the downloaded media.

Setting up the docker image

We need to create a new project with the path as the /docker/icloudpd and the following docker-compose

yml
1version: '3.3'
2services:
3 icloudpd:
4 container_name: icloudpd
5 restart: always
6 environment:
7 - user=username
8 - user_id=1026 # default
9 - group=users # default
10 - group_id=100 #default
11 - apple_id=apple-user@icloud.com
12 - authentication_type=2FA
13 - 'folder_structure={:%Y/%m}'
14 - notification_days=3
15 - synchronisation_interval=21600
16 - TZ=Asia/Calcutta
17 - 'download_path=/icloud'
18 - skip_check=false
19 network_mode: host
20 healthcheck:
21 test: ["CMD", "/usr/local/bin/healthcheck.sh"]
22 interval: 10m
23 timeout: 10s
24 retries: 3
25 start_period: 2m
26 volumes:
27 - '/volume1/docker/icloudpd/config:/config'
28 - '/volume1/homes/user/Photos/icloud:/icloud'
29 image: boredazfcuk/icloudpd:latest
30

Figuring out user_id and group details was a chore. It would not get proper permissions to download without this. After some debugging here's what worked

  • SSH into your NAS
  • Run id username

As soon as, you setup the docker container, you would need to setup a few things like the failsafe file and authentication. This was convenient to setup from the terminal as I was ssh-ed into it already.

  • SSH into your NAS (if you already haven't)
  • touch <download-path>/.mounted - this is the failsafe file
  • docker exec -it icloudpd sync-icloud.sh --Initialise - this would initiate the iCloud authentication

Ran into few issues and one of the error messages suggested I login in icloud.com and see if there are any popups on screen. After clicking them away and re-running the container, it seems to download the icloud library.

Aravind Balla

By Aravind Balla, a Javascript Developer building things to solve problems faced by him & his friends. You should hit him up on Twitter!

Get letters from me 🙌

Get a behind-the-scenes look on the stuff I build, articles I write and podcast episodes which make you a more effective builder.

Read the archive 📬

One email every Tuesday. No more. Maybe less.