nightscout / AndroidAPS

Opensource automated insulin delivery system (closed loop)
https://wiki.aaps.app
GNU Affero General Public License v3.0
694 stars 1.7k forks source link

[Suggestion] export settings from maintenance go to dowloads folder or straight to google drive #3296

Open Not-AriStienfeld opened 5 months ago

Not-AriStienfeld commented 5 months ago

Without a proper file sorting system, it can be annoying (and potentially confusing) to get the settings export onto the cloud. The option to send it straight to google drive would probably result in more people backing up more frequently, and would be more helpful for people who aren't as good at working with technology.

MilosKozak commented 4 months ago

Storing config to some cloud is a way .... But changing diricetory will be impossible with upcomming Android versions anyway

vanelsberg commented 4 months ago

Suggestion: I'm using FolderSsync to automagically sync AAPS settings the (cloud) storage of my choice. (https://play.google.com/store/apps/details?id=dk.tacit.android.foldersync.lite&pcampaignid=web_share)

olorinmaia commented 4 months ago

xDrip has automatic backup to google drive which is very useful

andyrozman commented 1 month ago

@MilosKozak Could we add some sort of automatic backup like that? And we could see how Xdrip has this handled... My proposal would be to create export in such way that we just add date in readable format to the end (for example settings_20240702_1202.zip) and then copy it to specific google drive directory... Is it even possible to create export now that we need password for creating export?

MilosKozak commented 1 month ago

the problem is encryption of backup. AAPS doesn't know master password

KelvinKramp commented 1 month ago

@MilosKozak => maybe we can ask the user to input the password when it's time for a backup?

I recently ran into the same issue. It has also been discussed in 2022 here: https://github.com/nightscout/AndroidAPS/issues/1208#issuecomment-1018023093

The options provided there were:

  1. Automatically save settings on a regular basis (every day, keep last 5 days, last 4 nondays, last 12 months)
  2. Automatically save settings after enabling a new omnipod (or other event requiring data from settings)
  3. Provide an option to keep a copy of the settings in an alternate location
  4. Provide an option to keep a copy of the settings in a predefined cloud location (note IMHO, since we are on android, google drive might be better suited than dropbox)

I would vote for a combination of 1 and 4 and for 4 (although more cumbersome) we could use mongodb via Nightscout for backupstorage https://www.mongodb.com/developer/products/mongodb/storing-large-objects-and-files/

vanelsberg commented 1 month ago

the problem is encryption of backup. AAPS doesn't know master password

@MilosKozak As far as I can see the (sole?) purpose of encrypting the settings export file is to prevent sharing settings for the purpose of circumventing the need for acquiring the AAPS objectives. Right?

I will not share details, but most of you will know this can be overcome fairly easily without the need for any special tooling. So I'd say the current solution of encrypting the settings on export (which required the users password) is not as sound as it suggests.

So to enable automatic backup of the settings using encryption the encryption key (e.g. password) need to be available to AAPS. Currently this is not the case and user is always asked to enter the password for exporting or importing settings.

Proposal#1: Securely store the users password in Android Keystore system. This system allows you to store cryptographic keys in a secure container, making them difficult to extract from the device. Need to study details on implementing this but I think this is quite doable (Try Windows CoPilot for an example ;-)

Proposal#2: Generate an alternate encryption key based on proof of ownership. One (sort of minimalistic) way would be to generate the key based on the Nightscout URL and API key configured for connecting the Nightscout site. Requirements:

  1. Use the Nightscout connection specs as configured in AAPS
  2. Require AAPS being successfully connected.

Note: This solution is not fully secure and would require a working NS site. But would make it more complicated to share the encrypted settings file (at least for non-dev users)

Proposal#1 would be my choice. Let me know your thoughts. I think I could do some draft on how to implement such solution?

andyrozman commented 1 month ago

@vanelsberg Option 1 should be doable, there is simple Android way to Secure application settings and it should be pretty secure.

@KelvinKramp I looked at Google Drive API and is not very simple to use... You would expect that you could specify username and password (or even use settings directly from configured account on phone), but not such luck... I mean there must be a way to do this, I just haven't found it yet...

Using Dropbox might be much easier, but I would like to avoid that way (person can have just 1 free Dropbox and if person is already is using it for some other stuff, using it for AAPS at same time would be a problem)...

And using Nightscout ... I don't think we should use it... Lot of people stopped using it...

but maybe someone has some other idea... Someone mentioned that XDrip is using Cloud for backup, maybe we should look into that.

andyrozman commented 1 month ago

Ok. Update on Cloud backup. I found that Xdrip had cloud backup (added in 2022): https://navid200.github.io/xDrip/docs/GoogleDriveBackup.html , so we could do something similar here, as soon as we can do automatic backup...

Tested and it it is working (but my backup size was 150 Mb, which is why it took so long (and I thought it was broken) - I have been using Xdrip for over 10 years, which explains size of database).

vanelsberg commented 1 month ago

@vanelsberg Option 1 should be doable...

Ok, I'll have a look at that then.