Back up apps

171 views
Skip to first unread message

Alan Hendry

unread,
Jan 2, 2021, 11:08:37 AM1/2/21
to DroidScript
Hi,
Recent posts warn of losing all projects if DS is uninstalled on Android 10/11.
It should be simple to write a simple app that can assist in backups.
Use ListFolder for the user to choose a folder under Droidscript , then copy to a backup folder, possibly into a sub folder named DSBackup/yymmddhhmmss.
It could zip the backup to save space (or even backup everything in the DS folder).
I presume _AddPermissions("Storage" ) would let the app store the backup in a secure location (failing that perhaps Sendfile and let the user choose Gmail/Drive/etc)
Regards, ah

Alan Hendry

unread,
Jan 3, 2021, 12:04:41 PM1/3/21
to DroidScript
Hi,
I've written a little js to zip DS folders and send, but got 2 problems.
For individual folders the zip seems to work, sending to drive seems to work,
but sending to email gives message
"Couldn't send attachment".
Choosing ALL doesn't seem to zip the entire DS folder 
(possibly because the zip destination is inside the DS folder).
It should be run under DS (so that it has full access to all DS files), not an APK.
Regards,ah

folder ="ALL" ;
function OnStart() {
var lay = app.CreateLayout( "linear", "Top" );
var txt = app.AddText( lay,"Backup DS Apps (choose folder then touch GO)" );
start = app.GetInternalFolder() + "/Droidscript" ;
var lf = "ALL," + app.ListFolder( start,null,null,"Folders,Alphasort" );
var spin = app.AddSpinner( lay,lf );
spin.SetOnChange( spin_OnChange );
var go = app.AddButton( lay,"GO" );
go.SetOnTouch( go_OnTouch );
app.AddLayout( lay ) ;
} // fn
function spin_OnChange(item,index) {
folder = item
} //fn
function go_OnTouch() {
if (folder == "ALL") {src = start;} else {src = start + "/" + folder;}
app.ZipFolder( src , folder+".zip");
var appname= app.GetAppName();
app.SendFile(start + "/" + appname + "/" + folder + ".zip") ;
alert(start + "/" + appname + "/" + folder + ".zip") ;
} //fn

Steve Garman

unread,
Jan 15, 2021, 3:04:19 AM1/15/21
to DroidScript
I have done a fresh install of DroidScript on my Android 10 phone so I can test Scoped Storage
One of the problems with Scoped Storage is that it can all be lost if DroidScript is uninstalled

Attached is the SPK I use to do backups to Google Drive

Please note, the archives produced cannot be sent by or to Gmail because they contain .js files

It only requires a change to one line of code to store those files in the same format used by SPK files but that would then require a specially written app to restore the files.
As I am using Drive it is more convenient for me to store them in their raw format
backup Storage.spk

Alan Hendry

unread,
Jan 18, 2021, 6:08:53 AM1/18/21
to DroidScript
Hi,
From the DS home screen you can long-touch then choose Share SPK, then touch Gmail, and it seems to work
(then go <- from the Compose screen and the SPK is kept in your Gmail Drafts folder).
Probably sensible to make occasional backups anyway, in case of accidental deletion, loss of phone, etc.
Regards, ah

Steve Garman

unread,
Jan 18, 2021, 6:36:39 AM1/18/21
to DroidScript
Yes, Share SPK works very well for a single app. I used it to post my SPK above. That SPK saves all the projectss and most of the other contents of DroidScript. For devices using Scoped Storage it also offers an option to backup anything else that might go missing if DroidScript is uninstalled

Save SPK and Share SPK change the name of .js files to .js.txt to allow them to be sent by email or to Google Groups.

I could have used the same trick in backupStorage.spk to allow me to send my backup to email but it would have needed a restore app to reverse the process. As I suggested above, you only need to change one line.

For my needs, saving to Google Drive, it makes more sense to leave the source unaltered in the .zip

Attached is the more recent version I am using now.
backup Storage.spk

Steve Garman

unread,
Jan 18, 2021, 7:13:09 AM1/18/21
to DroidScript
By the way the one line change is
// change:
  zip.AddFile(name + "/" + title, fldr + "/" + title)
// to:
  zip.AddFile(name + "/" + title.replace(".js",".js.txt"), fldr + "/" + title)

This will allow the output to be attached to an email in Gmail provided the .zip does not exceed the maximum attachment size. I am not sure what that limit is.

Converting it back will require an app which does the opposite
  //  title.replace(".js.txt",".js")
Reply all
Reply to author
Forward
0 new messages