NeoApplications / Neo-Backup

backup manager for android
GNU Affero General Public License v3.0
2.37k stars 120 forks source link

[Feature Request] Shortcut support #800

Open RobertZenz opened 8 months ago

RobertZenz commented 8 months ago

Is your feature request related to a problem? Please describe it.

I'm running a scheduled backup in the night and then synchronize the backup directory to a server. Sometimes the backup has not yet finished when the synchronization happens, even though plenty of time has been granted (lots of apps to backup), so an inconsistent state is being synchronized to the server. The time between backup and synchronization could be further improved, but it would be nicer if there was the possibility to have the synchronization directly invoked after the backup has finished.

Describe the primary solution

It would be neat if Neo-Backup would gain shortcut support, allowing external applications (like Tasker) to directly call backup routines/scheduled backups. The idea is to allow external applications to control when the backup runs, and do something directly after it has finished running.

Describe alternative solutions, if any

I guess what might also be a neat feature (instead?) is to run shortcuts of other apps after a scheduled backup has run. That would also allow to chain synchronizations directly after the backup has finished.

RobertZenz commented 8 months ago

I just noticed that #717 is similar.

hg42 commented 8 months ago

Controlling when a backup starts is already possible via intents, see FAQ.

May be this is a new feature, at least I didn't know this, yet: Tasker can read the logcat...and react to patterns.

To make this work, you need to enable logToSystemLogcat in NB settings (via DevTools [see faq]). The logcat messages are not exactly made for this, but the events are all there and can be easily identified:

each batch (a schedule is a batch, but also batches started manually):

%%%%% $batchName begin ...
%%%%% $batchName end ...

if all the batches are finished you get:

%%%%% ALL DONE

The beginBatches function doesn't output a log message, may be I add this...

The %%%%% are chosen exactly to identify these states.

The single batch begin and end messages may be changed to:

%%%%% batch begin: '$batchName' ...
%%%%% batch end: '$batchName' ...

at some point in the future to make it more machine readable.

You also get the number of batches running and the thread responsible for it in those batch messages, so you could also detect, when the thread dies for some reason (e.g. your OS killing it...), not sure if Tasker can detect threads.

"All DONE" should also be triggered in those cases, at least it's designed like that, not sure if it works in all cases (if catching exceptions is enough, otherwise there is no way to do it anyways).

There are cases where the notifications are not finished, but I think, this is usually due to restrictions of the number of notifications per time unit, which would mean the logcat messages should still be emitted. Please report if they don't.

this may relate to

307

655

717

RobertZenz commented 8 months ago

Controlling when a backup starts is already possible via intents, see FAQ.

That's good to know, thank you.

May be this is a new feature, at least I didn't know this, yet:
Tasker can read the logcat...and react to patterns.

This is actually an old feature, one I keep forgetting about, to be honest. But yes, that would work, thanks for the detailed explanation.