davidhealey / waistline

Libre calorie counter app for Android. Built with Cordova.
519 stars 63 forks source link

[Feature request] Database backup to custom folder #742

Open schklom opened 8 months ago

schklom commented 8 months ago

Database backups are a pain to find and backup properly (in /Android/data/com.waist.line/files). Is it possible to add a button somewhere to pick a folder where we want to save the backup?

EmilJunker commented 8 months ago

On versions prior to Android 13, the backup files are saved to the Documents folder which is very accessible. But on Android 13 and above, the backup files must be saved to a different folder for technical reasons, see #738 and #733.

grrrrr commented 8 months ago

@EmilJunker is that actually the case? WaistLine is the only app I have on Android13 that doesn't let me choose a backup location.

Is there any option around this, as on my device I do not have access to Android/data/com.waist.line/files via a file browser (e.g. Material Files) to do an off phone backup of the export?

EmilJunker commented 8 months ago

@grrrrr I'm able to access the backup location using this file browser app from the Play Store: https://play.google.com/store/apps/details?id=com.marc.files

In the future, maybe we can implement a solution where the exported file can be shared with other apps via Android's native sharing widget (a suggestion from #744). This Cordova plugin looks like it might allow to do just that: https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin

grrrrr commented 8 months ago

Thanks for checking, I am de-googled so can't get that to try but at least those I've tried on f-droid don't have access, no root access error.

But sure I can wait for a share option and hope in the mean time no need to re-install :)

EmilJunker commented 8 months ago

The com.marc.files app is basically just a shortcut that opens the system file browser. I don't think it requires any Google APIs or Play services. You can just download the APK from here: https://www.apkmirror.com/apk/marc-apps-software/files-20/

grrrrr commented 8 months ago

I grabbed it via adb in the end :D

schklom commented 8 months ago

@EmilJunker Is it possible to backup to a less protected storage location like Android/media/com.waist.line/files instead? Most apps do not even try to allow access to Android/data/..., but Android/media/... is much easier to access. Backing up a folder there can be done by every backup app I tried (Nextcloud, FolderSync, Tasker) without requiring any tricks.

Alternatively, would it be possible to use the Storage Access Framework to define the backup location? A quick search shows that there are cordova plugins to do that https://github.com/customautosys/cordova-plugin-saf-mediastore

EmilJunker commented 8 months ago

Is it possible to backup to a less protected storage location like Android/media/com.waist.line/files instead?

I just tried that using the trick described in https://github.com/davidhealey/waistline/issues/252#issuecomment-932939576, but it looks like it's no longer working. It worked on older versions of Android but when I try it on an Android 13 device I always get "Export failed".

As I wrote above, I think our best option would be to implement a solution where the exported file can be shared with other apps via Android's native sharing widget.

Nitrousoxide commented 5 months ago

I attempted to backup my database as well on android 13 and while the popup said it went to /Android/data/com.waist.line/files/waistline_export.json there was no directory "com.waist.line" under /Android/data/

I assume it has just backed up the file to the container's directory path rather than the android host's path because the host's was not symlinked.

EmilJunker commented 5 months ago

there was no directory "com.waist.line" under /Android/data/

@Nitrousoxide Make sure you are using a file browser that actually lets you access the files under /Android/data/. Not all file browser apps do that. This one works for me: https://play.google.com/store/apps/details?id=com.marc.files https://www.apkmirror.com/apk/marc-apps-software/files-20/

EmilJunker commented 5 months ago

There should be hundreds of folders under /Android/Data. One for each app on your phone. If you only see so few folders, then there is something fishy going on. Please try a different file browser.

Nitrousoxide commented 5 months ago

Using Marc's "Files" app seems to make them visible. Looking into that app it seems like its just an aliased link to the built-in file browser for android so it doesn't suffer the permission issues other ones do in modern android 13. So that's a good install regardless of your situation!

BenediktBroich commented 3 months ago

+1

makkus commented 1 month ago

Just chipping in to say that waistline is the only app atm where I can't (automatically) backup data. Most other apps I've setup backups for (via syncthing, foldersync, etc) have the backup data under /Android/media, so with the right permissions its possible for those apps to access the to-be-backed-up data and put it where-ever I think is a good idea. For waistline, that's unfortunately not possible (with Android 14, anyway), so the only way to backup the data would be to copy it manually out of that folder (via the "Files" app mentioned above), or maybe use the Google backup mechanism (which I'd like to avoid because it doesn't give a lot of control where my data is stored).