Photo backup from my iPhone to my Linux computer has long been a source of frustration for me.
Up till now, my efforts had been mainly focused on cloud backup (to self-hosted services), but now I have a nice, offline solution.
the old way
I guess my brain was addled by iCloud, since I assumed the only way to get files off my iPhone would be through the internet?
First I tried Nextcloud, but sadly the photo backup from iOS is… well to put it kindly, really terrible. Also I didn’t need any of their other stuff so it felt like a very bloated solution.
Next I went for Immich, which felt better since it was a solution dedicated to photos. Also very bloated, but less so than Nextcloud, and it worked pretty seamlessly from iOS, though I never got the background sync working well.
I’d sync from my phone to Immich on my home server, then syncthing would sync that over to my laptop, which would back everything up to Borgbase.
Too many moving pieces for my taste.
enter ifuse
A couple weeks ago, I decided to consolidate everything I host onto one dedicated server from OVHCloud. Really great deal, great price to performance, etc. In the process, I pared down some of the unnecessary things I hosted, and Immich was on the chopping block.
The ideal solution would be able to transfer my photos over a USB cable (I refuse to say “Lightning Cable” because that gives it more dignity than it deserves) to my computer, no network required.
After some looking around, I discovered iFuse by libimobiledevice which lets you mount your Apple Device’s root filesystem onto your Linux computer, brilliant stuff.
After a lot of playing around with it to see what it could do, I finally settled on this shell script to run when my phone is connected to sync things over:
#!/bin/sh
mountpoint="/home/amin/.local/share/iphone"
target_location="/home/amin/pictures/camera-roll/"
mkdir -p "$mountpoint"
ifuse "$mountpoint"
rsync -r --update --progress "$mountpoint/DCIM/" "$target_location"
fusermount -u "$mountpoint"
You’ll wanna change mountpoint and target_location to match your setup. mountpoint doesn’t matter a ton, it’s where the root filesystem of your phone will be mounted and then very quickly unmounted again.
Why such a quick mount/unmount? Well, I had an accident.
While playing around I accidentally did a misguided rm -r that… deleted all photos from my phone. Before you panic, I still have all those photos (I am a meticulous backup maker), they’re just no longer on my phone.
So, now, to give myself no time to make those stupid mistakes I always inevitably do, everything is quickly mounted, copied, then unmounted as soon as possible.
conclusion
I’d still ideally like to do a few more things with this, like sort the photos into date-based folders (not sure if that’s something I can do with plain rsync or if I’d need a custom solution), but this works for now and is a great user experience.
Hope it helps you! If you have a solution of your own, I’d love to hear about it, my email is below.