Backup your iCloud photos to your Synology NAS (and even convert to .jpg) automatically with icloudpd via docker

You recently posted a video about syncing google drive / dropbox

Sync Google Drive / Dropbox to your Synology NAS - Cloud Sync Tutorial

Loved it, as usual. I made a comment about the inability to sync iCloud photos which was my #1 wish. You replied it is possible to do somehow with an iPhone, but I went looking and found icloudpd, which can be run in docker on a Synology NAS.

It’s excellent. I found it via a reddit post by onestix made a year ago. How come I haven’t heard about it (and you haven’t made a video about it) before?

There’s not that much about it on YouTube, and there’s not even that much written about it on forums, especially for use with a Synology NAS.

It can regularly backup your icloud photos to your Synology NAS, and then you can use your NAS to index them (great that it now does objects as well as people BTW).

My workflow was:

(Install Portainer on the NAS if you don’t have it)
Create a directory in your docker directory for the config file
Create a directory in your photo folder for icloud photos
Create a .mounted file in that photo folder (easy to miss that in the git instructions)
Create a stack in Portainer (see below for mine)
Deploy the stack
Log into the container console (/bin/sh) via Portainer and run the authorisation
/usr/local/bin/sync-icloud.sh --Initialise
Then it starts downloading!
It will even convert .heic to .jpg if you tell it to!

You can find your user ID by SSHing into the NAS and typing “id”.

version: '3.3'
services:
    icloudpd:
        container_name: icloudpd
        restart: always
        environment:
            - user=xxxxx
            - user_id=1026
            - group=users
            - group_id=100
            - [email protected]
            - authentication_type=2FA
            - 'folder_structure={:%Y/%m}'
            - notification_days=7
            - synchronisation_interval=86400
            - TZ=Europe/London
            - 'download_path=/icloud'
            - skip_check=false
            - convert_heic_to_jpeg=true
            - auto_delete=true
        network_mode: host
        volumes:
            - '/volume1/docker/icloudpd:/config'
            - '/volume1/photo/icloud:/icloud'
        image: boredazfcuk/icloudpd:latest
1 Like

And if you have two accounts, one for you and one for your wife, you just create two docker containers!

1 Like

This is great info! Will have to look at it!

Thanks for sharing this! I think I almost got it but don’t fully understand the .mounted line. Can you explain how I created and upload that file into the folder?

The instructions say:

“I have added a failsafe feature to this container so that it doesn’t make any changes to the filesystem unless it can verify the volume it is writing to is mounted correctly. The container will look for a file called “/home/${user}/iCloud/.mounted” (please note the capitalisation of iCloud) in the download destination directory inside the container. If this file is not present, it will not download anything from iCloud. This way, if underlying disk/volume/whatever gets unmounted, sync will not occur and this prevents the script from filling up the root volume of the host. This file MUST be created manually and sync will not start without it.”

Create the file using a text editor or touch. It just has to exist. If it doesn’t then it won’t work and the log file will tell you that the .mounted file is missing.

Thanks for getting back to me. I’m in the container console (using portainer) and I’m getting a file directory not found error when I try to use touch and pasting what the instructions for.

Any idea what I’m doing wrong? Sorry I’m new to all this.

My personal volume mappings include:

        volumes:
            - '/volume1/docker/icloudpd-myname:/config'
            - '/volume1/photo/icloud/myname:/icloud'

(I run several icloudpd containers, one for each family member - I also ignored the capitalisation of iCloud when I set my path and hence my volume mounts)

My .mounted file is /volume1/photo/icloud/myname/.mounted on the NAS. Create a .txt file on the NAS and then rename it to .mounted. That’s probably the easiest way to create it and doesn’t need you to go into docker at all.

1 Like

Thanks! I ended up getting this working. Appreciate the reply to the one year post haha.

Can you make a YouTube on this please

works great on my synology ! Great writeup ! I`ve used container manager to build the docker-compose however I still had to use portainer (agent) in my case to access the /bin/sh for the auth process …

I hope this project will be maintained !

Hello, I have a problem when Im trying to initialise I get error Keyring file does not exist. Please try again.
I dont want to authenticate with Keyring.