$timezone = 'America/Los_Angeles'; date_default_timezone_set($timezone); ?>
If you take anytime to listen to ATP, undoubtably you will hear Casey talk about his beloved Synology. While most people don’t need a NAS, I totally get why Casey has one. I do too and I’m a digital hoarder. I even have the crappy code I wrote in college, markdown notes from my physics class, and even audio recordings of some of my classes.
Also, being a security guy, I know that Apple, Google, and Facebook are one hack away from losing my data. And I mean ONE HACK. This is not to say Apple is not secure. Thy try really really really hard. But, attackers have to only be right once. Security is not a finite game, even tho most of the industry plays it like it is.
There is a slim chance, however remote, that my data can get deleted from/by Apple. Plus, I get the warm and fuzzy knowing my data is on iCloud + My NAS + Glacier backup.
Anyways, I’m not writing this post to talk about Security, I do enough of that at work. I’m writing this post for people like Casey who want backups of their data beyond just the service provider they use.
That’s probably where my favorite project comes in, iCloud Photos Downloader. Specifically, that project + Docker.
Here is how I use it.
I made my own Dockerfile
from python:2.7
RUN git clone https://github.com/ndbroadbent/icloud_photos_downloader.git && cd icloud_photos_downloader && pip install -r requirements.txt
You can use previously build Dockerfiles from a few other sources, but I found that this project is well maintained. So no harm in simply cloning the repo.
My second goal was to merge my pictures and my wife’s pictures into one folder structure. To do that, I have the following commands that I ru
# Just in case the container didn’t exit last run
docker stop icloud_$1
set -e #exit if you have an error and don’t continue (e.g. fail auth)
# Start either my container or my wifes
docker start icloud_$1
# Run the download
docker exec -w /icloud_photos_downloader icloud_$1 python icloudpd.py --username [email protected] --directory /data/ --cookie-directory /root/ --until-found 100
docker stop icloud_$1
The script above simply runs one of two containers. Mine (icloud_joubin) or my wife’s (icloud_lindsay). Both these containers were previously started manually with the following:
docker run -it --name icloud_$1 -v /media/drobo/Pictures/$1/:/data icloud_photos_downloader /bin/bash
where $1
is either my name or my wife’s. Then I simply authenticated to my (or my wife’s) iCloud.
The flow does actually let you authenticate with your MFA. For example:
$ icloud --username [email protected]
ICloud Password for [email protected]:
Save password in keyring? (y/N)
You also have to do the first download manually - I couldn’t get the Keyring to provide the password to icloud_photos_downloader.
But after the first run, I ended up with a folder like this
├── joubin
│ ├── 2000
│ ├── ...
│ └── 2020
├── lindsay
│ ├── 2000
│ ├── ...
│ └── 2020
You can chose your name structure however you like.
--folder-structure <folder_structure>
Folder structure (default: {:%Y/%m/%d})
And finally - I have a cron
that runs daily to sync my pictures to my NAS.
@daily /home/joubin/docker/icloudphoto/run joubin >> /home/joubin/docker/icloudphoto/joubin.log 2>> /home/joubin/docker/ icloudphoto/joubin.err
@daily /home/joubin/docker/icloudphoto/run lindsay >> /home/joubin/docker/icloudphoto/lindsay.log 2>> /home/joubin/docker/ icloudphoto/lindsay.err