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

Search This thread

devsk

Senior Member
Dec 14, 2008
2,052
763
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.
 

Attachments

  • switchrom.txt
    7.7 KB · Views: 5,304
Last edited:
  • Like
Reactions: rongold3

Binary100100

Retired Forum Moderator
Apr 6, 2008
6,470
1,649
Detroit, Mi
This may sound like a silly question but please forgive me as I have not yet flashed the haykuro spl.

Once you've flashed the new spl, instead of flashing the update.zip of the cyanogen rom, can't you use nandroid restore? Or will that restore the previous spl as well (in my case HARD SPL)?

I ask because I would like to try the spl, but I'm so comfortable with my rom and settings that I would hate to wipe just to try Hero which is still in development. Call me crazy, but I like stable and finished builds. But I am curious and with a lot of time on my hands but not so much that I'm willing to lose everything just to try something that I'm not going to keep.

With this script, it would make it so much easier and would allow us to switch roms on the fly... but would it work from Hero builds and non-Hero builds?
 

devsk

Senior Member
Dec 14, 2008
2,052
763
I don't think I know enough about the SPL image contents to comment on this. But as far as I know SPL is not touched by nandroid restore. I upgraded the radio and SPL (haykuro) first, and then went with updating my ROM. I will never flash radio and SPL unless and until I really need to.

This script is just taking the pain out of switching between ROMs (whether Hero or Cyano or official) and nicely organizes your ROM backups. So, to answer your question:
would it work from Hero builds and non-Hero builds?
Yes. It would! I have switched between drizzy's Hero ROM and JACMyTouchSki (my favorite) many times using this. The restore is perfect!
 

rondey-

Senior Member
Mar 3, 2009
125
0
Fort Worth
www.myspace.com
Once you've flashed the new spl, instead of flashing the update.zip of the cyanogen rom, can't you use nandroid restore? Or will that restore the previous spl as well (in my case HARD SPL)?

Considering the most amount of bricks come from radio/spl updates, I dont think this script would integrate backing up and restoring them. Same reason why rom's themselves dont include the latest radio/spl in the update.zip when it is required by the rom.
 

Binary100100

Retired Forum Moderator
Apr 6, 2008
6,470
1,649
Detroit, Mi
Considering the most amount of bricks come from radio/spl updates, I dont think this script would integrate backing up and restoring them. Same reason why rom's themselves dont include the latest radio/spl in the update.zip when it is required by the rom.

Okay... so I'm running cyanogen's rom now with hardspl.

I back it up and lable it "Cyan 3.9"
I install the Haykuro spl (I already have the radio)
I install a Hero rom.
I try the Hero rom.
I backup the Hero rom and lable it "Hero"
I can then restore "Cyan 3.9" and still have the Haykuro spl.

Correct?
 

devsk

Senior Member
Dec 14, 2008
2,052
763
Okay... so I'm running cyanogen's rom now with hardspl.

I back it up and lable it "Cyan 3.9"
I install the Haykuro spl (I already have the radio)
I install a Hero rom.
I try the Hero rom.
I backup the Hero rom and lable it "Hero"
I can then restore "Cyan 3.9" and still have the Haykuro spl.

Correct?

Make sure you use labels which don't have whitespace or other special characters in the name like use Cyan-3.9 instead of "Cyan 3.9". I don't think script likes it much at this time. I need to fix that.
 

rondey-

Senior Member
Mar 3, 2009
125
0
Fort Worth
www.myspace.com
Okay... so I'm running cyanogen's rom now with hardspl.

I back it up and lable it "Cyan 3.9"
I install the Haykuro spl (I already have the radio)
I install a Hero rom.
I try the Hero rom.
I backup the Hero rom and lable it "Hero"
I can then restore "Cyan 3.9" and still have the Haykuro spl.

Correct?

The only difference between this and a "typical" nandroid restore should just be that it copies your ext2/3/4 partition for the app data. It wasnt listed anywhere that it would backup/restore your spl/radio.

Prior to flashing the haykuro spl I made a nandroid backup of the cyanogen rom I was using. I tested a hero rom and restored a nandroid backup of the cyanogen rom I was running and the new radio/spl were in place.
 

Binary100100

Retired Forum Moderator
Apr 6, 2008
6,470
1,649
Detroit, Mi
Prior to flashing the haykuro spl I made a nandroid backup of the cyanogen rom I was using. I tested a hero rom and restored a nandroid backup of the cyanogen rom I was running and the new radio/spl were in place.

Sweet! This was the exact answer that I was hoping and searching for for hours. Thank you very much. I've been getting guesses and theories this whole time and I knew someone out there just had to have personal experience with it. Thank you.
 

johnnylicious

Senior Member
Nov 9, 2008
1,464
6
WOW amazing script!! just downloaded and used it

works very well!! can't wait to see what else you can do with it.
 

mookie3three

Member
Jul 7, 2009
37
0
This may a dumb question, but why is it necessary to do this if your app data is still sitting on your ext partition, isnt it going to look for apps there anyway if you have apps2sd setup automatically like in a CM rom?

Cheers
 

pensive

Senior Member
Jun 29, 2009
231
1
The current version of nandroid lets you switch

Between backups, but not all options are yet connected to the UI.

Currently,

A. nandroid backups do not contain the a2sd app folders.
B. nandroid backups are not tagged but instead are time stamp based, so if you forget you backed up your most stable ROM with all the setup done and apps installed at 11:01pm on Friday, you will have tough time getting it back.

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 make its nandroid backup the latest so that the recovery console can restore from it.

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. Eventually, this should be part of the nandroid in recovery image itself.

Requirements:

cyanogen's recovery image 1.3.1
attached script (only txt extension is allowed) downloaded to /sdcard/switchrom.sh

Usage:

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

Do a nandroid backup first
Go into console with Alt+X (or do adb shell from PC)
mount /sdcard
sh /sdcard/switchrom.sh store <name>

e.g.

I am backing up soulife-1.2.3 with

sh /sdcard/switchrom.sh store soulife-1.2.3

3. To restore a ROM,

Go into console with Alt+X (or do 'adb shell' from PC)
mount /sdcard
sh /sdcard/switchrom.sh restore <name>

e.g.

I am restoring soulife-1.2.3 with

sh /sdcard/switchrom.sh restore soulife-1.2.3

Go back to recovery screen (by typing 'recovery' on the shell prompt if you are on console)
Alt+w to wipe
Do a nandroid restore from latest backup

I have tested this script with cyanogen 3.9, soulife 1.2.3, drizzy's hero and JACMyTouchSki.
 

ccunningham83

Senior Member
Feb 13, 2009
234
1
Dallas
I must be missing something...

I would like to say first, I am sure there is something I am missing, but to me it would just seem easier to do this in the terminal:

Make a copy of whatever ROM you want to use and rename it to update.zip. I will use Soulife's Ion for example. Also using the assumption you have an update.zip file on hand. You can use the ls command to see what all ROMs you have on your sdcard.

$ su
# cd /sdcard
# rm -r update.zip
# cp soulife.ion.v.1.2.2.zip /sdcard/update.zip
# reboot recovery

Flash as normal


I usually keep my phone backed up using backup for root users. So I just restore all my text messages and settings from the SD card and that is it.

I guess that is more typing, but to me each individual command it simpler.
 

devsk

Senior Member
Dec 14, 2008
2,052
763
This may a dumb question, but why is it necessary to do this if your app data is still sitting on your ext partition, isnt it going to look for apps there anyway if you have apps2sd setup automatically like in a CM rom?

Cheers
Apps data is not portable between ROMs. You need to clean it up otherwise expect random FCs.
 

devsk

Senior Member
Dec 14, 2008
2,052
763
I would like to say first, I am sure there is something I am missing, but to me it would just seem easier to do this in the terminal:

Make a copy of whatever ROM you want to use and rename it to update.zip. I will use Soulife's Ion for example. Also using the assumption you have an update.zip file on hand. You can use the ls command to see what all ROMs you have on your sdcard.

$ su
# cd /sdcard
# rm -r update.zip
# cp soulife.ion.v.1.2.2.zip /sdcard/update.zip
# reboot recovery

Flash as normal
And lose all that you did with your current ROM. I think you did not get the point of this script....:D This is for people who have setup their phone well with a ROM and don't want to lose its goodness but still want to test other ROMs and possibly have a couple of them on their phone which they can switch to & from.
 

Chahk

Senior Member
Apr 11, 2009
1,372
233
New York
I would like to say first, I am sure there is something I am missing, but to me it would just seem easier to do this in the terminal:

Make a copy of whatever ROM you want to use and rename it to update.zip. I will use Soulife's Ion for example. Also using the assumption you have an update.zip file on hand. You can use the ls command to see what all ROMs you have on your sdcard.

$ su
# cd /sdcard
# rm -r update.zip
# cp soulife.ion.v.1.2.2.zip /sdcard/update.zip
# reboot recovery

Flash as normal


I usually keep my phone backed up using backup for root users. So I just restore all my text messages and settings from the SD card and that is it.

I guess that is more typing, but to me each individual command it simpler.
The thing you are missing is that many apps do not have an option to export their settings, nor do they store them in an easily accessible place. Even if you manage to pull their settings off /data/data/ folders, you still have problems with restoring them. First off, you have to worry about their Linux permissions since they don't get preserved on the Fat32 partition. Second, simply pushing back the setting folders won't work for apps that use SQLlite database to store account info, so you're stuck with re-entering everything manually.

Take K9 Mail for example. I have 4 accounts (both IMAP and POP3) that I have to set up every time I wipe my phone or reformat the Ext partition. Same with progress on most games. A tar of the entire Ext partition combined with a Nandroid image resolves most of these issues.
 

Zappza

Senior Member
Nov 16, 2008
237
21
I get an error during backup.

I take a nandroid backup, enter recovery terminal, type in "mount /sdcard" enter "sh /sdcard/switchrom.sh store lastramjet" type in yes at the confirmation prompt and the script starts it's magic.

However, after the "moving nandroid (or something)" I get an error saying "Cannot umount /sdcard device/resource in use/busy". After that I get a successfully bookmarked the backup message.

Not sure if this matters, but just wanted to let you know :)
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    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.