[SCRIPT PACKAGE] ~zipbackup_v_2~ creates flashable backup zip right from your device!

pitchblack5691

Senior Member
Jan 12, 2012
437
447
0
chennai
Hi friends of XDA,

This is my first post in Developer's section :)

I'm very new to android and linux, actually i'm a noob in scripting but i've tried my best and will try to learn more from here.
i've been using ubuntu for past two months and android phone for past seven months.
i really started to like the open source community and learnt a lot! here i have created a simple piece of shell script
which will backup your phone and create a zip package for flashing with clockworkmod.

this piece of script package works right from your phone from start to end and will create a flashable zip package.
this idea was inspired by onandroid by ameer1234567890
so credits to him for creating a very portable script to create a nandroid backup while the phone is online.

this tool here works the same way as onandroid but instead creates a flashable recovery zip and the compression rate is higher than a Nandroid backup (see comparison chart below).
I have learnt everything i know about android from this forum. I wanted to contribute to XDA so i wrote this package
for you, my friends of XDA.
This is the first release for testing but i will be releasing upgraded versions with increased features and support for more devices.

first is first,

#include
/*
* I am not responsible for bricked devices, dead SD cards or
* thermonuclear war.
* do some research if you have any concerns.
* YOU are choosing to make these changes.
* yes, i copied this disclaimer from FXP because it is cool and i am lazy! :)
*/

REQUIREMENTS for v_2 :

1. xperia phone and kernel with CWM installed.
(theoretically it can be easily ported to all andriod devices. if interested, please test and let me know)
2. if hte script fails to install busybox and zip bianry, you have to manually place the busybox and zip binary and set permissions (execute the script and read the instructions)
3. script manager (compulsory)
4. some patience.

HOW TO USE:

1. download the attached zipbackup_v_X.zip
2. extract the "zipbackup" folder present in the attachment to the root of your sdcard
3. executed the extracted "zipbackup" present in /sdcard/zipbackup/ with superuser permissions using script manager with appropriate command line parameter (just execute it it will instruct you).
4. follow the on screen instructions.


COMPRESSION COMPARISON CHART:





NOTE:


1. PLEASE DO A NANDROID BACKUP BEFORE TESTING THIS SCRIPT PACKAGE

if this works in your device probably you won't be using nandroid backup anymore :p

2. this script package was tested in my xperia mini st15i running in my own stock base rom (.431)
and rage kernel so it should probably support all xperia android phones .

3. Everybody is welcome to edit the package without asking my permission provided you inform me and add a link
to this original thread in your version of zipbackup and credits should be awarded where due.

4. Right now in this v_2 release, only the /data , /system and /cache partition backups are done but in future
versions i will try to add support to backup /sd-ext and .android_secure .

5. Anybody interested is encouraged to suggest improvements in script and credits will be awarded where due.

6. If you are using a governor to limit the processor speed during screen off please disable it before back up and enable wakelock in sript manager else it
will greatly increase the time for compression if the screen is off while zipbackup script is running or try keep the screen on while the script is running.


SCREENSHOT:



NOTE: zip binary is actually installed in /system/xbin/ ignore the mistakes in screenshot it was shot during testing and that is a typo.

How this works?

Read second post!


CREDITS:

ameer1234567890 for the creation of his portable onandroid script.
The creators of opkg from which i extracted the zip binary for ARM devices.
to cigognes for informing me about opkg
To all my friends of XDA and XDA forum itself without which i could not have acquired this amount of knowledge in scripting.
to fxp for the busybox binary.
To users of ubuntuforums for helping me with my doubts in shell scripting commands.
please let me know if i have missed you out! if i have missed you out then it was done unintentionally! :(



VERSION CHANGELOGS:


zipbackup_v_2:


1. Added advanced backup functionality using command line parameters.
2. this version comes with busybox from fxp 142 kernel so it does not use the busybox present in your device for archiving so no need to worry about support for creation of bz2 archives.

USAGE for v_2:
1. to backup all (/system , /data and /cache) partitions use "-a" parameter
2. to backup only /data partition use "-d" parameter
3. to backup only /cache partition use "-c" parameter
4. to backup only /system partition use "-s" parameter


zipbackup_v_1:


1. Completely re-wrote the script from scratch.
3. removed the zipbackup_install.sh script and merged two scripts into one.
4. Included busybox for bz2 archive creation and extraction.
5. added analysis of power status function.
6. added led, vibration and lcd notification upon sucessful completion of backup.
7. this version comes with busybox from fxp 142 kernel so it does not use the busybox present in your device for archiving so no need to worry about support for creation of bz2 archives.


NOTE: please do not use alpha versions (no longer supported and they are buggy)



zipbackup_v_alpha2


1. added support to backup /cache partition
2. added elapsed time function
3. few minor changes in the script


zipbackup_v_alpha


initial release

TESTED SUCESSFULLY ON:

fxp 142 kernel
rage kernel 3.2
mesa kernel 1.9
kernel panic 1.25

PLEASE COMMENT IF IT WORKS OR DOES NOT WORK WITH YOUR DEVICE!

Please press thanks if my thread is useful! :D
 

Attachments

Last edited:

pitchblack5691

Senior Member
Jan 12, 2012
437
447
0
chennai
how this works???

HOW THIS WORKS (v_2) :

If you have a good amount of knowledge on shell scripting (which i know a little):

View full code with highlighted syntax and detailed comments, see pastebin entry.

for others,

The package consists of:

zipbackup_v_2.zip
|
|------reqfiles.zip
| |
| |---META-INF.zip (META-INF folder)
| |---busybox (busybox binary)
| |---zip (zip binary)
|
|---zipbackup (main script)


how does it back up?

1. When the zipbackup is executed with superuser permissions and with correct commandline parameters it extracts the busybox, zip binary and META-INF.zip inside the
ziprecovery folder. then it copies the attached busybox binary and zip binary to /tmp/ and /system/xbin folder respectively and assigns 755 permission to both of them.
this busybox binary is necessary for creating .bz2 archives and zip binary is necessary for creating the flashable zip.

2. then it creates /sdcard/zipbackup/temp folder and starts archiving /cache or /data or /system or all the three according to your requirement and
places it inside the temp folder temporarily.
during archiving it also creates a log file of all the files archived and places it in /sdcard/zipbackup/logs/backup/
after archiving it generates a updater-script compatible with provided update-binary (included in the package)
then the META-INF.zip is extracted into the temp folder and creates a compatible META-INF folder tree and includes the
generated updater-script in it.

NOTE: since the compression is higher it may comparatively take longer to backup than a Nandroid backup so if it doesn't throw any errors and
the screen says "please wait...." Then please wait it's actually working! :D

2. Then a ziprecovery.sh script is generated. this script is necessary for flashing the zip package with clockworkmod.

3. then the busybox included with the package is moved to temp folder

3. Then the zip binary is invoked and the created archives (cache.tar.bz2, data.tar.bz2 and system.tar.bz2), ziprecovery.sh the META-INF folder and included busbox binary are
zipped in store mode as requiered by clockworkmod.

4. A md5 sum is generated for the created zip file and placed in /sdcard/zipbackup/logs/backup/ folder for your reference.
the flashable backup zip is placed in /sdcard/zipbackup/backups/


NOTE: the md5 sum generated is only for your reference and it will not be checked during restore


how does it restore?

1. when the created backup zip file is flashed via clockworkmod the updater script formats the /system and /data and /cache partition first.
then extracts the busybox binary from the recovery zip and places it in /tmp folder and assings 755 permissions to the temporary busybox.
then extracts the three archives (cache.tar.bz2, data.tar.bz2 and system.tar.bz2) to the root of the sd card temporarily. so make sure that you have free space in sdcard prior to restore.
then the ziprecovery.sh is extracted to /tmp and 755 permission is assingned to it.

2. the ziprecovery.sh is executed which inturn extracts the archives (cache.tar.bz2, data.tar.bz2 and system.tar.bz2) present in the root of the sd card (see 1)
to their respective partitions (/cache, /data and /system).
during restore it also creates a log file of all the files restored and places it in /sdcard/zipbackup/logs/restore/
after the extraction, the cache.tar.bz2, data.tar.bz2 and system.tar.bz2 archives are deleted from the root of the sd card.
the symlinks and permissions are preserved by default in a .tar.bz2 archive (because i have tested it personally many times and it works with me).


NOTE:

1. everybody interested in this and have a prior knowledge in shell scripting can add features and optimize ziprecovery,
provided, a link to this thread and credits where due are given in your version of zipbackup.

2. I will try to optimize and add additional features in upcoming releases.
i need your help to implement this zipbackup script package optimally and bug free.


thank you for spending your valuable time in reading my thread.

press thanks if i haved helped you.

-------------------------------------------gouthamthemostwanted-----------------------------------------------
 
Last edited:

pitchblack5691

Senior Member
Jan 12, 2012
437
447
0
chennai
Great Idea, hope you will contiune this project. Very good that there are some toolkits like yours for linux, too. Maybe I'll try to add some functions ;)
Ya thanks! And you are very much welcome to contribute to zipbackup!
:)

Please test and tell me if it works with your device (XMP)

Sent from my smultron using xda app-developers app
 
Last edited:
  • Like
Reactions: mihahn

pitchblack5691

Senior Member
Jan 12, 2012
437
447
0
chennai
Great work from you, if this concept reaches official release stage, post it at android hacking and development forum !

Great future for this work. :)

Thanks !
Ya thanks but for that I need testers . I've tested it on my Xperia mini but I need users to test it in other Xperia models and give me feedback.

press thanks if I have helped you!
sent from my smultron
 

pitchblack5691

Senior Member
Jan 12, 2012
437
447
0
chennai
Okay what did the zipbackup_install say? Did you run it with superuser permissions and with script manager? Don't use terminal emulator it throws errors

press thanks if I have helped you!
sent from my smultron
 
  • Like
Reactions: eltonpestana

zhanjia

Senior Member
Jul 6, 2012
465
1,217
0
Penang
Okay what did the zipbackup_install say? Did you run it with superuser permissions and with script manager? Don't use terminal emulator it throws errors

press thanks if I have helped you!
sent from my smultron
Yup, ran with scriptmanager and superuser permission.
And was told to run the zipbackup.sh at zipbackup folder.
Zipbackup folder was created but no zipbackup.sh inside..

Thanks !