Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: iOS Background Backup #235

Closed
4 tasks
indieOR opened this issue Jun 20, 2022 · 19 comments
Closed
4 tasks

[Feature]: iOS Background Backup #235

indieOR opened this issue Jun 20, 2022 · 19 comments
Milestone

Comments

@indieOR
Copy link

indieOR commented 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

@alextran1502 alextran1502 changed the title [Feature]: Enable Android app to continue backup process while phone screen is turned off or other app active. [Feature]: Background backup Jun 20, 2022
@alextran1502 alextran1502 moved this to Todo in Immich Jun 20, 2022
@alextran1502 alextran1502 removed the status in Immich Jun 20, 2022
@xpwmaosldk
Copy link
Contributor

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.

@zackpollard zackpollard added this to the First Release milestone Jun 24, 2022
@saket1999
Copy link

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.

@docfactory37
Copy link

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.

@danielyrovas
Copy link

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

@alextran1502
Copy link
Contributor

Implemented in #382 for Android.

We still need to implement the counterpart on iOS

@marouamghar
Copy link

Is there any ETA for the feature on iOS?

@ark-
Copy link

ark- commented 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.

@ikoyhn
Copy link

ikoyhn commented 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.

@alex3305
Copy link
Contributor

alex3305 commented Sep 8, 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?

@ark-
Copy link

ark- commented 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?

@zackpollard zackpollard changed the title [Feature]: Background backup [Feature]: iOS Background Backup Sep 30, 2022
@zackpollard
Copy link
Contributor

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

@ductriueh
Copy link

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

@mplorentz
Copy link

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.

@alextran1502
Copy link
Contributor

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

@ark-
Copy link

ark- commented 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.

@mplorentz
Copy link

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.

@kpx-dev
Copy link

kpx-dev commented 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?

@alextran1502 alextran1502 moved this from In Progress to Todo in Immich Development Dec 27, 2022
@alextran1502 alextran1502 moved this from Todo to Stable Release in Immich Development Dec 27, 2022
@alextran1502 alextran1502 moved this from Road to stable 💯 to 🟠 Todo in Immich Development Dec 27, 2022
@alextran1502 alextran1502 moved this from 🚧 Tasks to 🎏 Road To Stable in Immich Development Dec 27, 2022
@mplorentz
Copy link

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.

@immich-app immich-app locked and limited conversation to collaborators Feb 8, 2023
@alextran1502 alextran1502 converted this issue into discussion #1694 Feb 8, 2023
@github-project-automation github-project-automation bot moved this from 🎏 Road To Stable to ✅ Done in Immich Development Feb 8, 2023
@github-project-automation github-project-automation bot moved this to Done in Immich Feb 8, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
Archived in project
Development

No branches or pull requests