immich
immich copied to clipboard
[Feature]: Background backup
Feature detail
Current behavior: When switching from the Immich Android app to another app, or turnint my phone screen off the upload/backup process pauses. When starting on a brand new device the backup process may take a long time and it's inconvenient for the user to leave the app open/running with the screen on.
Desired behavior: Backup process continues in app, regardless of phone state or active app. This may require granting permissions and should be optional.
Platform
Mobile App
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.
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.
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.
Also the ability to only allow auto upload/backup of photos when on a specific WiFi network.
Implemented in https://github.com/immich-app/immich/pull/382 for Android.
We still need to implement the counterpart on iOS
Is there any ETA for the feature on iOS?
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.
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.
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?
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?
I'm making some edits to the issue as this now exists on android, I'm changing the issue to be iOS specific.
Could we start a bounty on this? I am happy to contribute £10. It's the only missing feature for me in immich.
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 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
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.
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:
- 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.
- 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.
- (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 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?
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.
https://github.com/fluttercommunity/flutter_workmanager/blob/main/IOS_SETUP.md looks interesting
https://github.com/transistorsoft/flutter_background_fetch is another option.