Default [UTIL] [NEW] switchrom.sh V1.1 - One step bookmark, store and restore your ROMs

Changelog:
  • 1.1 - Allow delete/restore without a name. Choose from the list.
  • 1.0 - Use nandroid to make it one step process.
Currently, nandroid backups do not contain the a2sd app folders. It has been painful to say the least to jump between ROMs.

This script does two things:

1. Store and tag a ROM's nandroid backup and its apps data. You can provide any name for tagging while storing.
2. Restore a tagged ROM's app data and its latest nandroid backup.

The nice side effect of this is that you have complete environments you have created nicely bookmarked with easy to understand names and version numbers, ready to be restored easily.

Requirements:

1. Two partitions in order: fat32, ext2/3
2. cyanogen's recovery image 1.4. 1.3.1 will not work with V1.0.
3. Attached script called switchrom.txt downloaded and stored in folder /system/sd/ and renamed as switchrom.sh

Usage:

1. Boot into recovery using Home + End buttons together.
2. To bookmark and tag current ROM,

Go into console with Alt+X (or do adb shell from PC)
mount /system/sd
sh /system/sd/switchrom.sh -s <name>

e.g.

I am backing up soulife-1.2.3 with

sh /system/sd/switchrom.sh -s soulife-1.2.3

3. To restore a ROM,

Go into console with Alt+X (or do 'adb shell' from PC)
mount /system/sd
sh /system/sd/switchrom.sh -r

It will give you a list of available ROMs to restore and you can choose the one you want to restore using the corresponding number.

e.g.

I am restoring soulife-roger-new-3.9.1-latest with

Code:
sh /system/sd/switchrom.sh -r
1. JACMyTouchSkiV2-mod                
2. JACxROM-1.3r3                      
3. cm-3.9.7-best-setup                
4. drizzy-hero-2.8-best               
5. soulife-ion-1.2.3-mod              
6. soulife-roger-new-3.9.1-latest     
Choose a ROM (type in the number and press enter)...6

Restoring ROM soulife-roger-new-3.9.1-latest, proceed? (y/n) y
Cleaning up /system/sd ...                                    
Restoring soulife-roger-new-3.9.1-latest app data in /system/sd ...
Restoring nandroid backup...                                       
Done restoring the ROM soulife-roger-new-3.9.1-latest.
Note that no extra steps are necessary. No wipe! No nandroid restore!

Note that options have changed since last version. Make sure to read the help with '-h' or '--help' option. Compression (-c option) is supported for both the apps partition and the nandroid but the way it is done in nandroid is dumb and takes like 17 minutes, so I would not recommend it at this time but you can definitely try it. I will post patches for nandroid script to fix that.

Code:
# sh /system/sd/switchrom.sh -h

Usage: /system/sd/switchrom.sh OPTIONS <rom_name>

Options are:
          -h --help
          -c --compress, only used with -s
          -d --delete
          -l --list
          -r --restore
          -s --store
          -v --version

Always specify options as separate words
  e.g. -c -r instead of -cr. Its required!
Don't use blanks or special characetrs in rom_name.
Compress will take longer but image will be smaller.
<rom_name> is optional with -r and -d. Choose from a list.
NOTES:

Note that this is not storing the whole backup of your EXT2/3 partition. This is just storing app* and dalv* folders needed to restore the ROM behavior, apps and settings only. If you wipe your EXT2/3 partition with a formatter or manually with 'rm -rf /system/sd/*', you will loose everything on that partition and won't get it back from this backup. This backup will only restore app* and dalv* folder.


It was reported that certain versions of 'adb' hangs in the sub-shell created and it doesn't pass through the commands that are typed. Make sure to upgrade the SDK to 1.5r3.
Attached Files
File Type: txt switchrom.txt - [Click for QR Code] (7.7 KB, 5044 views)