Skip to content

Instantly share code, notes, and snippets.

@natanlao
Last active August 14, 2024 16:29
Show Gist options
  • Save natanlao/04aba3245aeff4d01a0a5a77e71353c1 to your computer and use it in GitHub Desktop.
Save natanlao/04aba3245aeff4d01a0a5a77e71353c1 to your computer and use it in GitHub Desktop.
Syncing iPhone photos with Syncthing

For those who prefer to avoid solutions like iCloud Photos and Dropbox for backing up photos, you can sync your iPhone photos with Syncthing. To do this, you'll need two things:

  • Möbius Sync is, to my knowledge, the only actively-maintained Syncthing client for iOS. It's free to sync up to 20 MB, and only $4.99 (one-time) to remove that limit.

  • PhotoSync is a nifty iOS app for syncing photos to a number of different destinations. It's free for low-quality transfers, and $6.49 annually for full-quality, background transfers.

First, configure Möbius Sync so that you're syncing a local folder somewhere. The key here is that we can add files to a folder exposed in Files.app, and changes to that folder will (eventually) be picked up by Möbius Sync and synced to whatever destination you've configured.

Second, configure PhotoSync to automatically transfer your photos to said folder. As I noted above, you can use the Autotransfer feature to automate this. Now you're done!

This setup is pretty simple, but I've been looking for it for a while and haven't seen it documented anywhere.

There are some caveats to this approach:

  • Unless you configure PhotoSync to delete photos after transfer, storage space consumed by photos on your device will double.

  • Synchronization is not instant; there's delay between (1) when PhotoSync copies your photos/videos to your Syncthing folder and (2) when Möbius Sync picks up changes to said folder.

  • Neither PhotoSync nor Möbius Sync are fully open source.

That being said, I think this approach still makes a lot of sense if you're concerned about your privacy or want to keep your data out of the cloud. Plus, the PhotoSync team says they're planning on adding an optional pre-sync encryption feature, which is neat if that's something you're interested in.

It's worth noting that the Möbius Sync team is working on getting photo upload working in the app eventually.

Update, 3 Feb 2024: When the backup on my phone gets too large, I move the backups out of the synced folder and configure PhotoSync to only back up photos newer than the current day. This has worked well enough so far.

@natanlao
Copy link
Author

natanlao commented Jan 4, 2022

@Valcyclovir Definitely a valid approach. This guide assumes that you already want to use Syncthing, which upon a reread wasn't clear. Using a NAS is great, but is a little more overhead than I'm comfortable with for my use case.

@Flachzange
Copy link

@Valcyclovir Last year I had to switch to iOS and since then I was looking for a solution to get my photos transferred to my privately owned cloud as I do not want to use iCloud at all. However, there is no way to have a two-way sync between my cloud and the phone. Similiar to iCloud, I organize and delete photos on other systems. This needs to be reflected on the phone as well. syncthing / MöbiusSync seems to be the only proper twoway-sync client for iOS. Hence, I was quite disappointed when I noticed it is not able to sync photos.

Therefore, thanks for the idea @natanlao. I was already experimenting with PhotoSync before. In case you decided to delete files after transfer you would need to think about an additional app to view your photos in the Möbius Sync folder.

In my opinion, this is the only solution Möbius Sync can implement, i.e.

  1. get/convert/delete photos from iOS
  2. stores them in a regular folder in the desired format
  3. Let's Möbious do the syncing
  4. Use an an alternative app to view files/movies on phone

@Valcyclovir
Copy link

I'll let you guys in my little setup, and it's working great so far after 2 weeks.

Requirements:

  1. Google pixel 1 or XL (Unlimited original quality video and original cloud backup)
  2. NAS storage system on a raspberry pi (for physical backup on top of cloud backup)
  3. Alternatively to requirement #2, you can set up a RAID system, but I find the rasp pi NAS storage much more versatile.
  4. Your current Android / iPhone
  5. PhotoSync
  6. Syncthing

Again, I am trying to not rely on Mobius as this is a third party app using Syncthing and can discontinue updates anytime. iOS can also find ways to screw with it so no thanks, Photosync is much more established and popular on iOS and I doubt Apple will do anything to shaft them, so rely on them instead.

My setup :

  • NAS storage with one separate folder for each phone acting as the middleware. Trash can file versioning on. This is the actual backup in case something happens with Google Cloud. Syncthing is mainly a sync, not a backup, so having this trash versioning allows you to have a physical backup of your photos / videos in case your Google Cloud account gets.. banned ?
  • My Pixel 6 has Syncthing on it running like a champ linked to my rpi NAS storage.
  • my iPhone 13 has Photosync with delete after sync turned on. It is synced to my other folder on my rpi NAS storage.
  • My Pixel 1 is plugged to my wall, has every single app disabled / deleted aside from Google photos and Syncthing. Google photos is set to auto delete backed up photos / videos after 30 days, and Syncthing on it is set to sync to NAS storage.
  • Every phone / storage medium is both send & receive.

Result :
Easy access to all photos and videos across the Google photos website or Google photos apps on all phones.

Self sustainable system other than the Pixel 1 wear and tear over time, I have bought 2 spare batteries and a spare Pixel XL in case the first one breaks :)

Amount of free and unlimited original quality photos and videos updated so far in the past 5 years : 10TB. With 4k 60fps videos on our new phone, I expect this number to grow exponentially !

@Flachzange
Copy link

Thanks for sharing. What I do not get from your description: How do you sync photos back to your iphone that you have added or deleted on your NAS or Android?

@dm9tr0
Copy link

dm9tr0 commented Jan 13, 2022

I found better and free solution - Nextcloud.
Deployed it in docker container on my NAS server, got DNS name from any free service, forward ports via Nginx Proxy Manager and access from iOS with SSL + 2FA, iOS application has settings for automatically upload photos and videos to Nextcloud with original HEIC format or automatically convert it to jpeg.
The end of story. Free, unlimited, good app, possibility to share files.

@Valcyclovir
Copy link

@Flachzange I don't, the photos don't get sync'ed back to my phones at all, the photos are directly sent to my NAS storage and deleted locally, and then my NAS storage syncs to my Pixel 1 with google photos backup. My only 2 copies of my photos/videos are my NAS storage and google cloud.

@13Dima13 Thanks for the write up, definitely did not know about the Nextcloud which is a GREAT open source solution to de-Google. I read up a bit on r/unRAID and a few more forums, people seem rather divided between a few solutions, namely PhotoSync and Nextcloud, which are great solutions for iOS photos / videos backups.
The few complaints about Nextcloud were security (which you seem to have taken care of with 2FA and Nginx Proxy Manager), more complicated to set up than say PhotoSync or any centralized solutions like Amazon and Google Cloud, slightly less convenient to access photos and videos (Nextcloud app available but not ideal, workarounds possible with another app to view photos), takes up a lot more space (during the NextCloud sync it also creates another folder apparently). NextCloud requiring more apps and is slower to sync than another contender Seafile (Unlike Nextcloud, Seafile doesn't store flat files, it stuffs everything into data chunks for various reasons, including speed).

These are only small downsides for being able to 100% own your own data. However, I think it's a bit missleading to say this is "the end of story" since there are many other solutions out there and NextCloud alone isn't without flaws !

I personally love FOSS but I am still not ready to abandon Google backup just yet because of this Pixel 1 hack with literally free storage. I always believe a local physical backup should always accompany a cloud solution in case a fire takes place or something happens to your hardware. NextCloud is free but still needs to be hosted somewhere and be supported by drives. If you host it on a VPS such as DigitalOcean then you have monthly fees to pay as well. If you host it locally, then you won't have a cloud backup in case something does happen.

Let me know if I missed anything, really liking our discussions so far !

@dm9tr0
Copy link

dm9tr0 commented Jan 13, 2022

@Valcyclovir you can build your own home server, many tutorials you can find on youtube. You have to pay just electricity bill and you are limited only your free space on HDD.
Also, I used Photosync, but for destination I (again) took webdav docker image and deployed it on my NAS, forwarded ports via Nginx, used public DNS, created SSL certificate for https access, but Nextcloud is much better - you have more security access, more flexibility to manage your files etc.

Honestly, when I had Oneplus (probably all models) I have never thought about such cases and even had no idea have to implement it, thanks iOS I raised my skills 😀

@Flachzange
Copy link

@13Dima13 My own setup completely relies on Owncloud (origin of Nextcloud). On Android or other systems your are able to implement a complete two-way-sync solution and having your data in your own hands at the same time. This is not easily possible on iOS. While the Owncloud and Nextcloud apps transfer images and videos into your cloud space, any changes done in the cloud (respectively on other devices), are not synced back to your Apple device. It is one-way only.

My requirement is to have a two-way-sync implementation between all devices (@Valcyclovir). Owncloud is my main back-end system used for all users and across all devices. I rely on Möbius Sync / Syncthing as this seems to be the only way to sync back and forth from and to iOS.

Consequently I have to do everything outside Apple Photos using three different tools to achieve this. In my opinion this is completely ridiculous.

@dm9tr0
Copy link

dm9tr0 commented Jan 16, 2022

@Flachzange one way sync is what I need from iOS, all sorting/removing I prefer do on PC.
I agree that on android it was much easier and flexible, but after many years on android I do not want to return again, I like CarPlay, animation and camera on iOS, even apps have another actions in menu on iOS.

@ferbulous
Copy link

@Valcyclovir how do you handle live photos backup?
I noticed I get a picture and a 2-3 sec video instead of a single photo like in ios.

@SupaTWC
Copy link

SupaTWC commented Mar 20, 2022

I'll let you guys in my little setup, and it's working great so far after 2 weeks.

Requirements:

  1. Google pixel 1 or XL (Unlimited original quality video and original cloud backup)
  2. NAS storage system on a raspberry pi (for physical backup on top of cloud backup)
  3. Alternatively to requirement #2, you can set up a RAID system, but I find the rasp pi NAS storage much more versatile.
  4. Your current Android / iPhone
  5. PhotoSync
  6. Syncthing
  • my iPhone 13 has Photosync with delete after sync turned on. It is synced to my other folder on my rpi NAS storage.

Amount of free and unlimited original quality photos and videos updated so far in the past 5 years : 10TB. With 4k 60fps videos on our new phone, I expect this number to grow exponentially !

I'm trying to switch to iOS. Does your method auto transfer photos from iphone to your pi without any manual interaction? I've read background sync is very slow and doesn't work on large video files.

@Valcyclovir
Copy link

@Valcyclovir how do you handle live photos backup? I noticed I get a picture and a 2-3 sec video instead of a single photo like in ios.

photosync has a way to convert live photos, unfortunately I don't have my phone with me but check the settings.

@Valcyclovir
Copy link

I'll let you guys in my little setup, and it's working great so far after 2 weeks.
Requirements:

  1. Google pixel 1 or XL (Unlimited original quality video and original cloud backup)
  2. NAS storage system on a raspberry pi (for physical backup on top of cloud backup)
  3. Alternatively to requirement #2, you can set up a RAID system, but I find the rasp pi NAS storage much more versatile.
  4. Your current Android / iPhone
  5. PhotoSync
  6. Syncthing
  • my iPhone 13 has Photosync with delete after sync turned on. It is synced to my other folder on my rpi NAS storage.

Amount of free and unlimited original quality photos and videos updated so far in the past 5 years : 10TB. With 4k 60fps videos on our new phone, I expect this number to grow exponentially !

I'm trying to switch to iOS. Does your method auto transfer photos from iphone to your pi without any manual interaction? I've read background sync is very slow and doesn't work on large video files.

After trying photosync on my iPhone 13 for a few months, it is semi reliable when it comes to syncing. It uses geofencing and when charging at a certain time to sync photos so it isn't really reliable unfortunately. The person would have to have the phone charging at that specific time, or he would need to be at a certain location to trigger the sync, and even so, doesn't work most of the time. I have given up on looking for alternatives and will keep trying to change settings on photosync to make things a bit more reliable.
However, syncing manually is as easy as pressing 2 buttons and leaving it run in the background. Unfortunately, Apple doesn't really allow background processes and photosync so far hasn't been half bad despite the trouble of auto syncing.
Sidenote: if you have an amazon prime membership, it comes with unlimited original quality photo storage to up to 6 people. The amazon photo app is VERY reliable but it still requires you to open the app to trigger the backup. It's the easiest method by far to backup pictures and I'm running both photosync and amazon photos.

@SupaTWC
Copy link

SupaTWC commented Mar 20, 2022 via email

@Valcyclovir
Copy link

Thanks for your quick reply. Any way to download Amazon photos and get it synced to Pi? I still want to use Google Photos and already have pixel setup for uploading. Message ID: @.***>

unfortunately, I don't think so, I treat amazon photos as a completely separate entity and since I already pay for prime (which I probably will for the rest of my life), I might as well use their included features.

If you want to use google photos I totally understand ya, I have a bunch of Nesthubs at home and being able to access photos from literally anywhere is just amazing. Just keep using your google pixel 1 for as long as you can. Syncthing will not fail and the only problem is apple products not allowing background syncing and there is absolutely no way around it. Photosync makes it super easy to with 2 buttons so I totally recommend it. Don't use Mobius sync as this is a third party app of someone forking syncthing and can be discontinued anytime.

@badbob001
Copy link

@Valcyclovir

  • My Pixel 1 is plugged to my wall, has every single app disabled / deleted aside from Google photos and Syncthing. Google photos is set to auto delete backed up photos / videos after 30 days, and Syncthing on it is set to sync to NAS storage.

So does the Pixel 1 download and store all photos from the nas? One concern is that the phone will not have enough storage for all photos, but syncthing should pause the download if free space is too low and continue once google photos frees up space.

But a more important issue is: if google photos uploads/deletes older photos, then won't syncthing re-download those deleted photos again? Then the phone will always have the same photos, there won't be enough free space for the rest of the nas photos, and thus not all nas photos will be uploaded to google. I wonder if setting pixel's syncthing to be receive-only and to ignore deletes would make it not resync photos deleted by google photos. I'm guessing that In order for ignore deletes to work, syncthing must have a database to keep track of what was already synced. If that is the case, then replacing the phone or re-installing the syncthing client will lose the database and it'll try to sync the same photos already backed up to google. Ideally, google photos can recognize those local files are duplicates of what has already be backed up and delete them locally.

@mrioan
Copy link

mrioan commented Nov 13, 2022

I want to share how I managed to do this myself. This is the most automatic way I found:

  1. Install "LAN drive SAMBA Server Client" in your iPhone
  2. Start the SAMBA server
  3. Mount the SAMBA share in your machine. Something like:
mount -t cifs -o "domain=WORKGROUP,username=test,password=test,sec=ntlm,vers=1.0" \\\\192.168.1.100\\DCIM /mnt/smb_iphone
  1. Use rsync to sync your photos (your iPhone is the source):
rsync --info=progress2 -azv --delete /mnt/smb_iphone/ /mnt/my_drive/backup/iphone/photos/

BTW, LAN drive SAMBA Server Client limits the transfer speed for the free version. If you want full speed you have to buy the pro version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment