[Feature]: iOS Background Backup #99

Closed
opened 2026-02-04 17:36:02 +03:00 by OVERLORD · 19 comments
Owner

Originally created by @indieOR on GitHub (Jun 20, 2022).

Feature Details:

  • iOS App will backup photos when the app is not open
  • Background backup will have configurable options like android (only on Wi-Fi, only when charging)
  • Background backup can be enabled or disabled entirely.
  • Notifications on repeated failures, configurable in the settings page

Screenshot of Android Implementation

Left: Backup Settings Screen
Right: Main Settings Page

Platform

Mobile App

Originally created by @indieOR on GitHub (Jun 20, 2022). ### Feature Details: - [ ] iOS App will backup photos when the app is not open - [ ] Background backup will have configurable options like android (only on Wi-Fi, only when charging) - [ ] Background backup can be enabled or disabled entirely. - [ ] Notifications on repeated failures, configurable in the settings page ### Screenshot of Android Implementation **Left**: Backup Settings Screen **Right**: Main Settings Page <img src="https://user-images.githubusercontent.com/1313578/193362559-3162afbd-b64d-4c11-b541-fef113a8660a.jpg" width="400"><img src="https://user-images.githubusercontent.com/1313578/193362715-5146e379-6ac9-48b1-9163-9c0f254b8620.jpg" width="400"> ### Platform Mobile App
Author
Owner

@xpwmaosldk commented on GitHub (Jun 21, 2022):

It seems to be one of the important factors.

In my case.
I take a lot of pictures at once when traveling with my family.

@xpwmaosldk commented on GitHub (Jun 21, 2022): It seems to be one of the important factors. In my case. I take a lot of pictures at once when traveling with my family.
Author
Owner

@saket1999 commented on GitHub (Jul 3, 2022):

One more thing that can be added is "background services" that can run at periodic intervals to scans for new images and upload them without the need to open the app.

@saket1999 commented on GitHub (Jul 3, 2022): One more thing that can be added is "background services" that can run at periodic intervals to scans for new images and upload them without the need to open the app.
Author
Owner

@docfactory37 commented on GitHub (Jul 11, 2022):

Just switch over to Immich, and notise that the you need to have the app open fof it to backup images as soon as i close it backup stops.

would love to have a background services that scans for new photos and auto backs them up when im home and on wifi.

@docfactory37 commented on GitHub (Jul 11, 2022): Just switch over to Immich, and notise that the you need to have the app open fof it to backup images as soon as i close it backup stops. would love to have a background services that scans for new photos and auto backs them up when im home and on wifi.
Author
Owner

@danielyrovas commented on GitHub (Jul 30, 2022):

Also the ability to only allow auto upload/backup of photos when on a specific WiFi network.

@danielyrovas commented on GitHub (Jul 30, 2022): Also the ability to only allow auto upload/backup of photos when on a specific WiFi network.
Author
Owner

@alextran1502 commented on GitHub (Aug 19, 2022):

Implemented in https://github.com/immich-app/immich/pull/382 for Android.

We still need to implement the counterpart on iOS

@alextran1502 commented on GitHub (Aug 19, 2022): Implemented in https://github.com/immich-app/immich/pull/382 for Android. We still need to implement the counterpart on iOS
Author
Owner

@marouamghar commented on GitHub (Sep 3, 2022):

Is there any ETA for the feature on iOS?

@marouamghar commented on GitHub (Sep 3, 2022): Is there any ETA for the feature on iOS?
Author
Owner

@ark- commented on GitHub (Sep 5, 2022):

iOS is a massive pain for closing apps in the background. I've yet to see an app which backs up in the background that works 100% of the time on iOS. Best I've seen is https://www.photosync-app.com/home.html and they just accept it will only trigger backups on events such as AC power applied, or location based.

@ark- commented on GitHub (Sep 5, 2022): iOS is a massive pain for closing apps in the background. I've yet to see an app which backs up in the background that works 100% of the time on iOS. Best I've seen is https://www.photosync-app.com/home.html and they just accept it will only trigger backups on events such as AC power applied, or location based.
Author
Owner

@ikoyhn commented on GitHub (Sep 8, 2022):

iOS is a massive pain for closing apps in the background. I've yet to see an app which backs up in the background that works 100% of the time on iOS. Best I've seen is https://www.photosync-app.com/home.html and they just accept it will only trigger backups on events such as AC power applied, or location based.

Honestly I'd love to have what photosync does in immich. I used photosync before switching over to immich and it would auto backup all my photos at night (AC trigger), with immich I always have to remember to open the app and keep it open till its done.

@ikoyhn commented on GitHub (Sep 8, 2022): > iOS is a massive pain for closing apps in the background. I've yet to see an app which backs up in the background that works 100% of the time on iOS. Best I've seen is https://www.photosync-app.com/home.html and they just accept it will only trigger backups on events such as AC power applied, or location based. Honestly I'd love to have what photosync does in immich. I used photosync before switching over to immich and it would auto backup all my photos at night (AC trigger), with immich I always have to remember to open the app and keep it open till its done.
Author
Owner

@alex3305 commented on GitHub (Sep 9, 2022):

I'm just trying Immich for the first time tonight and everything looks really great and polished. But I cannot seem to get background sync to work at all. I seem to encounter #64 where I have to keep my screen on within Immich to get Immich to upload anything.

Environment information

  • Device Samsung Galaxy S21+
  • Android version 12
  • Immich app version 1.28.0
  • Immich server version 1.28.0

Server log

[Nest] 7  - 09/08/2022, 9:56:02 PM     LOG [WebsocketConnectionEvent] New websocket connection: syi41aAIXjL77ZR3AAA5
[Nest] 7  - 09/08/2022, 9:57:11 PM     LOG [WebsocketConnectionEvent] Client syi41aAIXjL77ZR3AAA5 disconnected from Websocket
[Nest] 7  - 09/08/2022, 9:58:05 PM     LOG [WebsocketConnectionEvent] New websocket connection: BVjcJRUAWlMgOSbRAAA7
[Nest] 7  - 09/08/2022, 9:58:17 PM     LOG [WebsocketConnectionEvent] Client BVjcJRUAWlMgOSbRAAA7 disconnected from Websocket
[Nest] 7  - 09/08/2022, 9:58:37 PM     LOG [WebsocketConnectionEvent] New websocket connection: 8retqFRIPHj9JapiAAA9
[Nest] 7  - 09/08/2022, 10:01:56 PM     LOG [WebsocketConnectionEvent] Client 8retqFRIPHj9JapiAAA9 disconnected from Websocket
[Nest] 7  - 09/08/2022, 10:02:08 PM     LOG [WebsocketConnectionEvent] New websocket connection: avZZCOzmsKlm2uWpAAA_

I've already disabled all battery optimizations and pinned the app according to Don't Kill My App. Of course I've enabled background sync on wifi. Is this behavior still to be expected?

@alex3305 commented on GitHub (Sep 9, 2022): I'm just trying Immich for the first time tonight and everything looks really great and polished. But I cannot seem to get background sync to work at all. I seem to encounter #64 where I have to keep my screen on within Immich to get Immich to upload anything. ### Environment information * Device **Samsung Galaxy S21+** * Android version **12** * Immich app version **1.28.0** * Immich server version **1.28.0** ### Server log ``` [Nest] 7 - 09/08/2022, 9:56:02 PM LOG [WebsocketConnectionEvent] New websocket connection: syi41aAIXjL77ZR3AAA5 [Nest] 7 - 09/08/2022, 9:57:11 PM LOG [WebsocketConnectionEvent] Client syi41aAIXjL77ZR3AAA5 disconnected from Websocket [Nest] 7 - 09/08/2022, 9:58:05 PM LOG [WebsocketConnectionEvent] New websocket connection: BVjcJRUAWlMgOSbRAAA7 [Nest] 7 - 09/08/2022, 9:58:17 PM LOG [WebsocketConnectionEvent] Client BVjcJRUAWlMgOSbRAAA7 disconnected from Websocket [Nest] 7 - 09/08/2022, 9:58:37 PM LOG [WebsocketConnectionEvent] New websocket connection: 8retqFRIPHj9JapiAAA9 [Nest] 7 - 09/08/2022, 10:01:56 PM LOG [WebsocketConnectionEvent] Client 8retqFRIPHj9JapiAAA9 disconnected from Websocket [Nest] 7 - 09/08/2022, 10:02:08 PM LOG [WebsocketConnectionEvent] New websocket connection: avZZCOzmsKlm2uWpAAA_ ``` I've already disabled all battery optimizations and pinned the app according to [Don't Kill My App](https://dontkillmyapp.com/samsung). Of course I've enabled background sync on wifi. Is this behavior still to be expected?
Author
Owner

@ark- commented on GitHub (Sep 14, 2022):

iOS is a massive pain for closing apps in the background. I've yet to see an app which backs up in the background that works 100% of the time on iOS. Best I've seen is https://www.photosync-app.com/home.html and they just accept it will only trigger backups on events such as AC power applied, or location based.

Honestly I'd love to have what photosync does in immich. I used photosync before switching over to immich and it would auto backup all my photos at night (AC trigger), with immich I always have to remember to open the app and keep it open till its done.

To be fair, if immich exposed a webdav, samba, ftp or s3 style interface then photosync could be used on iOS. I know separate apps is not the end goal of the project but might be a good interim solution?

@ark- commented on GitHub (Sep 14, 2022): > > iOS is a massive pain for closing apps in the background. I've yet to see an app which backs up in the background that works 100% of the time on iOS. Best I've seen is https://www.photosync-app.com/home.html and they just accept it will only trigger backups on events such as AC power applied, or location based. > > Honestly I'd love to have what photosync does in immich. I used photosync before switching over to immich and it would auto backup all my photos at night (AC trigger), with immich I always have to remember to open the app and keep it open till its done. To be fair, if immich exposed a webdav, samba, ftp or s3 style interface then photosync could be used on iOS. I know separate apps is not the end goal of the project but might be a good interim solution?
Author
Owner

@zackpollard commented on GitHub (Oct 1, 2022):

I'm making some edits to the issue as this now exists on android, I'm changing the issue to be iOS specific.

@zackpollard commented on GitHub (Oct 1, 2022): I'm making some edits to the issue as this now exists on android, I'm changing the issue to be iOS specific.
Author
Owner

@ductriueh commented on GitHub (Oct 25, 2022):

Could we start a bounty on this? I am happy to contribute £10.
It's the only missing feature for me in immich.

@ductriueh commented on GitHub (Oct 25, 2022): Could we start a bounty on this? I am happy to contribute £10. It's the only missing feature for me in immich.
Author
Owner

@mplorentz commented on GitHub (Nov 16, 2022):

I am an iOS developer who has recently implemented background syncing at my day job. I have never used Flutter before and I'm not ready to dive into that right now, but I'm happy to collaborate with anyone who wants to implement this. I think I can provide a good roadmap for interacting with the iOS background mode APIs.

@mplorentz commented on GitHub (Nov 16, 2022): I am an iOS developer who has recently implemented background syncing at my day job. I have never used Flutter before and I'm not ready to dive into that right now, but I'm happy to collaborate with anyone who wants to implement this. I think I can provide a good roadmap for interacting with the iOS background mode APIs.
Author
Owner

@alextran1502 commented on GitHub (Nov 16, 2022):

I am an iOS developer who has recently implemented background syncing at my day job. I have never used Flutter before and I'm not ready to dive into that right now, but I'm happy to collaborate with anyone who wants to implement this. I think I can provide a good roadmap for interacting with the iOS background mode APIs.

Hello, your input is highly appreciated, can you layout your thoughts, I and the team can work from our side on the Flutter implementation

@alextran1502 commented on GitHub (Nov 16, 2022): > I am an iOS developer who has recently implemented background syncing at my day job. I have never used Flutter before and I'm not ready to dive into that right now, but I'm happy to collaborate with anyone who wants to implement this. I think I can provide a good roadmap for interacting with the iOS background mode APIs. Hello, your input is highly appreciated, can you layout your thoughts, I and the team can work from our side on the Flutter implementation
Author
Owner

@ark- commented on GitHub (Nov 18, 2022):

I am an iOS developer who has recently implemented background syncing at my day job. I have never used Flutter before and I'm not ready to dive into that right now, but I'm happy to collaborate with anyone who wants to implement this. I think I can provide a good roadmap for interacting with the iOS background mode APIs.

I'm interested in how well this works, even the big apps like moments (synology) and nextcloud still struggle with background backup on iOS. It's so frustrating that iOS doesn't provide an adequate API for non Apple apps.

@ark- commented on GitHub (Nov 18, 2022): > I am an iOS developer who has recently implemented background syncing at my day job. I have never used Flutter before and I'm not ready to dive into that right now, but I'm happy to collaborate with anyone who wants to implement this. I think I can provide a good roadmap for interacting with the iOS background mode APIs. I'm interested in how well this works, even the big apps like moments (synology) and nextcloud still struggle with background backup on iOS. It's so frustrating that iOS doesn't provide an adequate API for non Apple apps.
Author
Owner

@mplorentz commented on GitHub (Nov 19, 2022):

There are many ways to get background execution time on iOS. Most of them are attached to some specific kind of activity, like GPS navigation. But there are two types of generic background tasks you can ask the system to run:

  • BGAppRefreshTask - this task is expected to be very short (less than 20 seconds). You can request the system to run it as often as you like. The system may or may not execute your task depending on things like how often the user opens the app, whether they are on wifi or cellular, and how much battery they have left.
  • BGAppProcessingTask - this task is expected to do energy-intensive tasks and is allowed to run for several minutes. It will never run when the user is using the phone. In general these tasks are only executed when the phone is charging and on wifi (the middle of the night for most users).

The other background mode that might come in handy is geofencing. I haven't implemented this one before so I'm not as familiar with how the system treats these in practice. But according to the docs you should be able to execute some code in the background when the user enters a predetermined location (like their home).

If I were implementing background syncing for Immich I would do the following:

  1. Set up a BGAppProcessingTask according to this guide and schedule it to run every few hours. The task should spend as long as possible uploading photos to the Immich server. I would add some custom code to check that the user is on WiFi before uploading just to be safe. For most users this will run every night and should have enough time to upload all their photos from the day. This is probably all the background syncing most people will need.
  2. Set up a BGAppRefreshTask and schedule it to run every hour. This task can do the same thing as the BGAppProcessingTask, but it will only have <20 seconds to upload photos. If the user only takes a few photos a day this will help them get uploaded sooner. If they take a lot of photos in a day they probably won't get backed up until the BGAppProcessingTask runs. Consider letting the user turn off BGAppRefreshTasks in the settings if they want to save battery life.
  3. (Optional) Set up geofence syncing. In this case the user will need some UI to choose the location where syncing should happen. A good example of this can be found in the Downcast app in Settings (unfortunately it is not open source). Here are Apple's docs for geofencing.
@mplorentz commented on GitHub (Nov 19, 2022): There are many ways to get background execution time on iOS. Most of them are attached to some specific kind of activity, like GPS navigation. But there are two types of generic background tasks you can ask the system to run: - BGAppRefreshTask - this task is expected to be very short (less than 20 seconds). You can request the system to run it as often as you like. The system may or may not execute your task depending on things like how often the user opens the app, whether they are on wifi or cellular, and how much battery they have left. - BGAppProcessingTask - this task is expected to do energy-intensive tasks and is allowed to run for several minutes. It will never run when the user is using the phone. In general these tasks are only executed when the phone is charging and on wifi (the middle of the night for most users). The other background mode that might come in handy is geofencing. I haven't implemented this one before so I'm not as familiar with how the system treats these in practice. But according to the docs you should be able to execute some code in the background when the user enters a predetermined location (like their home). If I were implementing background syncing for Immich I would do the following: 1. Set up a BGAppProcessingTask according to [this guide](https://developer.apple.com/documentation/uikit/app_and_environment/scenes/preparing_your_ui_to_run_in_the_background/using_background_tasks_to_update_your_app) and schedule it to run every few hours. The task should spend as long as possible uploading photos to the Immich server. I would add some custom code to check that the user is on WiFi before uploading just to be safe. For most users this will run every night and should have enough time to upload all their photos from the day. This is probably all the background syncing most people will need. 2. Set up a BGAppRefreshTask and schedule it to run every hour. This task can do the same thing as the BGAppProcessingTask, but it will only have <20 seconds to upload photos. If the user only takes a few photos a day this will help them get uploaded sooner. If they take a lot of photos in a day they probably won't get backed up until the BGAppProcessingTask runs. Consider letting the user turn off BGAppRefreshTasks in the settings if they want to save battery life. 3. (Optional) Set up geofence syncing. In this case the user will need some UI to choose the location where syncing should happen. A good example of this can be found in the [Downcast](https://apps.apple.com/us/app/downcast/id393858566) app in Settings (unfortunately it is not open source). [Here](https://developer.apple.com/documentation/corelocation/monitoring_the_user_s_proximity_to_geographic_regions) are Apple's docs for geofencing.
Author
Owner

@kpx-dev commented on GitHub (Dec 4, 2022):

@mplorentz I really like your approach. Hope this get implemented soon as I think this should be core feature of this service, to backup photo to nas instead of g photo cloud. I have some free time during Christmas week if you want to collaborate on this?

@kpx-dev commented on GitHub (Dec 4, 2022): @mplorentz I really like your approach. Hope this get implemented soon as I think this should be core feature of this service, to backup photo to nas instead of g photo cloud. I have some free time during Christmas week if you want to collaborate on this?
Author
Owner

@mplorentz commented on GitHub (Dec 28, 2022):

I have some free time during Christmas week if you want to collaborate on this?

Sorry it has been a busy few weeks for me but I have some free time the rest of the week if it's something you are still interested in. Maybe we should move collaboration to a GitHub Discussion thread, or we could find another band. I am @matt:matrix.lorentz.is on Matrix if you have that.

@mplorentz commented on GitHub (Dec 28, 2022): > I have some free time during Christmas week if you want to collaborate on this? Sorry it has been a busy few weeks for me but I have some free time the rest of the week if it's something you are still interested in. Maybe we should move collaboration to a GitHub Discussion thread, or we could find another band. I am `@matt:matrix.lorentz.is` on Matrix if you have that.
Author
Owner
@veverkap commented on GitHub (Dec 31, 2022): https://github.com/fluttercommunity/flutter_workmanager/blob/main/IOS_SETUP.md looks interesting https://github.com/transistorsoft/flutter_background_fetch is another option.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#99