tmo1 / sms-ie

SMS Import / Export is a simple Android app that imports and exports SMS and MMS messages, call logs, and contacts from and to JSON / NDJSON files.
GNU General Public License v3.0
320 stars 38 forks source link

[feature] Periodic backup support #7

Open Surendrajat opened 2 years ago

Surendrajat commented 2 years ago

It'll be nice to see some sort of automatic backup feature at user-defined time intervals if it's in the scope. I currently use Super Backup for just that.

tmo1 commented 2 years ago

Yes, that's a major feature I would like to add. I don't know how soon I'll get to it, though. I've been learning Android development through this project, and the next thing I'll need to learn in order to implement automatic backups is task scheduling. I'll see what I can do.

Surendrajat commented 2 years ago

Awesome. Take your time. Here are few apps with similar backup feature if you want to take a look into it:

tmo1 commented 2 years ago

Hi,

I have added a basic scheduled backup implementation. Currently, the user can select a particular time of day, and the app will automatically execute a backup at that time each day.

In the future, I may add more control over backup intervals, and perhaps some sort of differential or incremental backup functionality.

Feedback is always welcome!

Surendrajat commented 2 years ago

Hi @tmo1 thanks for the work. I tested it, and it seems to work well once you exclude the app from battery optimization. Without that though, the app get killed in background and triggers the backup when you open it again but I guess it's expected. (same issue with other sync apps I use) I'll keep it running for few days to see if I find any issue.

Few suggestions:

tmo1 commented 2 years ago

Hi @tmo1 thanks for the work. I tested it, and it seems to work well once you exclude the app from battery optimization.

Thanks for testing!

Without that though, the app get killed in background and triggers the backup when you open it again but I guess it's expected. (same issue with other sync apps I use)

Hm. I implemented scheduled backups via the currently recommended WorkManager framework, the documentation of which claims:

In addition, WorkManager adheres to power-saving features and best practices like Doze mode, so you don't have to worry about it.

According to everything I've read, the scheduled backups should run regardless of whether the app is open or not, although they could be delayed by as much as six hours if the device goes into Doze mode:

Apparently, though, some phones do their own aggressive battery optimization, which can prevent background tasks from working properly:

What phone are you using?

I'll keep it running for few days to see if I find any issue.

Thanks - please do report any issues!

Backup the call logs also (or expose the selection in preferences)

I intend to - I wanted to get a basic working implementation out, and then refine it afterward.

With call logs backup and restore working, the app won't really be just sms-ie anymore, will it? laughing Maybe you can look for a more inclusive(pun intended) name for it.

:)

Surendrajat commented 2 years ago

What phone are you using?

I forgot to mention, it's a dreaded Oppo device and yes it does some aggressive battery optimizations.

It seems to work fine so feel free to close this issue.

Surendrajat commented 2 years ago

@tmo1 One possible improvement you can make is to limit the number of backup files to 5 (or some number exposed in preference) and delete all old files. That way it won't pollute the sync-ed dir with old backups.

tmo1 commented 2 years ago

@tmo1 One possible improvement you can make is to limit the number of backup files to 5 (or some number exposed in preference) and delete all old files. That way it won't pollute the sync-ed dir with old backups.

I agree that that's a good idea, and I may implement some sort of retention control, if / when I get a chance.

thanasistrisp commented 1 year ago

Any update here?

tmo1 commented 1 year ago

I'm currently working on a mechanism to allow exporting to be controlled by an external application (such as Automation or Easer), which will provide more flexibility in scheduling exports. I'm not yet sure what, if anything, I'm going to do about retention. Ideally, I'd like to limit the code in my app as much as possible to its core functionality of importing and exporting, and to find ways of leveraging other apps to do more general purpose tasks such as scheduling, file management, and retention.

TinfoilSubmarine commented 1 year ago

I'm not yet sure what, if anything, I'm going to do about retention. Ideally, I'd like to limit the code in my app as much as possible to its core functionality of importing and exporting, and to find ways of leveraging other apps to do more general purpose tasks such as scheduling, file management, and retention.

One option may be to allow the user to customize the name of the exported file. This way, if they so wish, the user can just opt to have the file named the same, so then it just overwrites the previous version. This could actually pair well with Nextcloud since it already has file versioning built in.

tmo1 commented 1 year ago

One option may be to allow the user to customize the name of the exported file. This way, if they so wish, the user can just opt to have the file named the same, so then it just overwrites the previous version. This could actually pair well with Nextcloud since it already has file versioning built in.

Thanks - I'll consider something like this.

tmo1 commented 1 year ago

One option may be to allow the user to customize the name of the exported file. This way, if they so wish, the user can just opt to have the file named the same, so then it just overwrites the previous version. This could actually pair well with Nextcloud since it already has file versioning built in.

It turns out that it's not actually quite that simple, since creating a new file with the same name as an old one doesn't overwrite it - Android just names the new file filename (1). I did, however, add a couple of preferences that implement behavior along the lines of what you suggested.

Nalajalan commented 3 months ago

Hi,

Thanks a lot for your app that seems to be the only foss app with this (so essential) purpose (and i am very surprised of that).

I think it's a good idea to use the app with nextcloud versioning. However for people who just want a quick and simple backup system in case of mistake, it will be great to just can choose the number of versions that are kept before erasing them and not just erase each time ( very dangerous in case of mistake) or never erase ( lot of people are not capable to manage that differently than manually and who want do that for a daily backup...). So it makes the scheduled backup almost not usable for not advanced user, what i find sad :(

tmo1 commented 3 months ago

Thanks a lot for your app that seems to be the only foss app with this (so essential) purpose (and i am very surprised of that).

You're very welcome!

I think it's a good idea to use the app with nextcloud versioning. However for people who just want a quick and simple backup system in case of mistake, it will be great to just can choose the number of versions that are kept before erasing them and not just erase each time ( very dangerous in case of mistake) or never erase ( lot of people are not capable to manage that differently than manually and who want do that for a daily backup...). So it makes the scheduled backup almost not usable for not advanced user, what i find sad :(

Thanks for the feedback - I'll consider adding a setting allowing for the retention of more than one export.