Android Question Correct backup of multiplatform project

Alessandro71

Well-Known Member
Licensed User
Longtime User
Not really strictly Android, but...

What is the correct procedure for a proper backup of a multi platforms project that is structured as suggested:
B4X:
+root dir
  - common .bas files
  + B4A dir
    - platform specific files
  + B4J dir
    - platform specific files
Autobackup or export as zip function of each platform get only platform specific files.

Open each project, CTRL P for cleanup, then a zip of the whole root directory?
Is there a batch command for cleanup, so I can perform the whole procedure with a scripts?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can create a batch file in the root folder with:
B4X:
rd /s /q B4A\AutoBackups
rd /s /q B4i\AutoBackups
rd /s /q B4J\AutoBackups
rd /s /q B4A\Objects
rd /s /q B4i\Objects
rd /s /q B4J\Objects
del "Backup.zip"
zip "Backup.zip" -r "*.*"

zip.exe is attached. Source: http://infozip.sourceforge.net/Zip.html
 

Attachments

  • zip.zip
    72.6 KB · Views: 254
Upvote 0

Alessandro71

Well-Known Member
Licensed User
Longtime User
is the rd command on Objects safe?
in B4A there are some files in res dir to be backed up
do you expect them to be read-only?
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Yes, it is.
But will it also delete the res subfolder
Well, yes, as the command Erel suggested is
rd /s /q B4A\Objects​

and as per rd command help,

>rd /?
Removes (deletes) a directory.

RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path

/S Removes all directories and files in the specified directory
in addition to the directory itself. Used to remove a directory
tree.

/Q Quiet mode, do not ask if ok to remove a directory tree with /S
Regards,

Anand
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
It looks like Erel's batch file:

1) Delete's B4A's, B4I's and B4J's own historical backups before the main BACKUP.ZIP backup is performed so the resulting ZIP backup wont be too big.
2) Delete's all the \Objects directory because these directories only contain files that resulted from a compile operation and are not useful (because you can recreate them just by doing another compile.)
3) Since the RD is only used for the above two sub-directories, it should not delete any other files or directories (where your res files are)

But keep this in mind - you may want to remove the \AutoBackups lines from the batch file so it WILL preserve older versions of your files because Erel's batch file will not only delete those historical versions, but it will also erase the previous "Backup.ZIP" so when you do a new backup, it will delete the older one, so you won't have any older backups at all. (you could however, modify the script to remove the "del backup.zip" line and make it so the new ZIP backup filename includes the date text i.e "Backup-102719.ZIP" - this way your previous backups will be preserved when you do a new one)
 
Last edited:
Upvote 0

Alessandro71

Well-Known Member
Licensed User
Longtime User
It looks like Erel's batch file:
2) Delete's all the \Objects directory because these directories only contain files that resulted from a compile operation and are not useful (because you can recreate them just by doing another compile.)
3) Since the RD is only used for the above two sub-directories, it should not delete any other files or directories (where your res files are)

That's clear, but something bothers me:
the icon of the B4A project is in
project root\B4A\Objects\res\drawable
The RD command will delete my icon.png file also
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
From what I understand, all files in \Objects are generated after a compile.

Your icon is probably stored somewhere else and *after* a compile, it is *copied* into the \objects directory.

As a test, just move the \Objects folder somewhere else that B4x can't see it, and then do a new compile. This will create a whole new \objects set of files.

I'm thinking that there will be no errors and you will find your icon file waving at you in the new \Objects directory :)

(If you do get an error for some reason you can always move the original \objects folder back).
 
Last edited:
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Not really. The icon will be deleted. Better to remove the single delete command and delete the sub folders instead of the Objects folder (except of res\).
So @Alessandro71 is right.
Thanks to him, we also know now about the icon file residing in only res folder.

Regards,

Anand
 
Last edited:
Upvote 0

Alessandro71

Well-Known Member
Licensed User
Longtime User
Not really. The icon will be deleted. Better to remove the single delete command and delete the sub folders instead of the Objects folder (except of res\).

this is not what the Clean Project (CTRL-P) option does, since other files are still left in place, like the manifest
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
I noticed that auto backup saves the "Objects\res\drawable\icon.png" and also "Objects\AndroidManifest.xml" in zip file.
So these files can be
ATTRIB +R
before zip and
ATTRIB -R
after zip, in the suggested batch file.

Regards,

Anand
 
Upvote 0
Top