yashsingh1/xdaforums huggingface dataset:
[G1 Android Development] Binary100100:
I can't wait until this becomes ONE WITH THE RECOVERY so we don't have to:

ALT+X

m-o-u-n-t- -s-y-s-t-e-m-/-s-d <enter>

s-h- -s-y-s-t-e-m-/-s-d-/-s-w-i-t-c-h-r-o-m-.-s-h- ---s- -s-a-v-e-d-r-o-m-n-a-m-e-v-1-2-3 <enter>

y <enter>

r-e-b-o-o-t <enter>

How about... scroll down and select Nandroid Backup inc SD

s-a-v-e-d-r-o-m-n-a-m-e-v-1-2-3 <enter>

Then press any key to reboot. Done.

To recover:

Scroll down to select Nandroid Recovery inc SD

savedromnamev121

savedromnamev122

savedromnamev123

3 <enter>

Home (to confirm)

OH

And another request (or recommendation)...

If we can, perhaps in the next version, have the script MOVE the nandroid backups to the switchrom directory instead of COPY, I think that this will save some time in the process. Not to mention storage space. I have a 16 (well... 13 after the partitioning) gig sdcard so space isn't really an issue... but for the poor folks out there pimping the 2gb class 4 cards... I can only imagine how long it must take for them. And to be in the process of doing this only to find out that they ran out of space and couldn't do it at all... must be incredibly frustrating. We don't need 2 copies of the nandroid backup because we shouldn't ever need to use the nandroid recovery option as long as we have this script. Or perhaps there could be a way to symlink the backups so that the backups will actually be stored on the switchrom/romname direcotry instead of the nandroid directory? Or maybe an option to remove the original nandroid backup after copying it to the switchrom directory? But then that wouldn't speed up the process of copying the backups to the switchrom since moving would definitly be faster. I dunno... I know nothing about scripting. But I do know is that I'm CONSTANTLY deleting GIGS (the most I've had was 8gb) of backups from my nandroid folder.

Just a thought.
[G1 Android Development] rob.turner:
Switchrom in /sbin

Don't know if anyone else has tried this, but I left the script as a .txt and then pushed it to /sbin/switchrom and chmod 755ed it instead of pushing it to /system/sd/switchrom.sh. Now I don't have to type out the "sh /system/sd" part (less typing is better, I have large fingers), and it survives a wipe. Seems to back up and restore successfully. YMMV. Code for fellow noobs out there follows:

Sorry, apparently this doesn't work like I thought it would. A happy accident, as it were.
[URL="http://xdaforums.com/showthread.php?t=541183&page=20"]http://xdaforums.com/showthread.php?t=541183&page=20[/URL]

A little off topic noobishness, I peeked inside the ext-backup.tar in my newly minted backup and noticed that most of my apps are being stored in /app-private as well as /app (essentially, there are two copies of each .apk, one in each folder). Is this normal behavior?
[G1 Android Development] Binary100100:
Thanks for the tip but it doesn't work. Not for me anyway.

I pushed it to sbin directory and attempted to run it from recovery and:

/sbin/sh: switchrom: not found

so I checked out the /sbin folder and it's there alright... but I don't have access to the /sh directory.

/sbin/sh: cd: can't cd to sh

and when I reboot the switchrom file isn't in the /sbin directory anymore.
[G1 Android Development] rondey-:
Sh isnt a directory, it is used to execute the script. Also I dont know what the deal is with the sbin folder, adb allows me to push things there then execute just fine (did it with the sdparted script to partition sdcard) but nothing stays after a reboot. Havent looked into it much but would be easier for all of us who run scripts, dont have to type the path everytime.
[G1 Android Development] overground:
Until this is incorporated into a recovery, you guys are going to run into major issues placing this script anywhere except /system/sd or /system/sd/x where "x" is any directory not starting with app* or dalv*. It needs to be run from a directory that is not set up for backup/restore from within switchrom.sh.
[G1 Android Development] rob.turner:
Tried to recreate my backup/restore, and figured out what I did, no issues though it doesn't work the way I hoped it would. Oh well. I didn't think the /sbin directory got backed up, that's why I thought I could run it from there.

1st, booted to recovery, pushed script to /sbin. successfully performed a backup to sd card.

2nd, decided to push a themed Advanced Launcher to /system/app as well.

3rd, rebooted. turns out i messed something up inside the launcher apk, got stuck at 1st boot screen (g1 flashlight)

4th, popped out battery, booted to recovery. perfomed a wipe. entered console, cd to /sbin, ls showed script was still there. ran script from /sbin, successfully performed a restore from sd card.

5th, normal reboot. everything a-ok, just like it was before the botched launcher push.

6th, rebooted to recovery, entered console, cd to /sbin, ls shows script is gone (incidentally, so is sdparted script. Is it not possible to add a script to /sbin and have it stay there after a reboot?)

I guess since it never completed the initial boot after I pushed the script and bad launcher, it didn't get deleted when I booted back into recovery, which allowed me to do the restore. What I thought was a neat new trick was just a one time fluke, I guess.
[G1 Android Development] Binary100100:
What is probably going on here is that the sbin directory is being written and re-written when the recovery.img is being read. At that point the data from the recovery.img file (with /sbin included) is at that point accessible. But when you reboot the recovery.img file has to be reloaded thus nothing stays. To edit the sbin file you would have to edit the recovery.img file.

http://xdaforums.com/showthread.php?t=443994
[G1 Android Development] devsk:
That is precisely what's happening here. I wonder what will happen if I change switchrom.sh to not restore the recovery image from NANDROID backup.
[G1 Android Development] Binary100100:
I doubt that it would make any difference. In fact... if you look at the recovery image across different roms (like hero vs cyanogen roms for example) the recovery.img file is the exact same size. These roms don't come with the recovery.img file as it is installed seperately. (Such as Cyanogens 1.4 Recovery.) What the Nandroid does it backs up the boot.img, cache.img, data.img, system.img and whatever misc is (possibly boot screens? 256kb is standard with all of my backups) and the recovery.img file. Even if you tell it not to restore the recovery.img file then it is only going to use the one that is already flashed in... which doesn't matter since it's the same one. The only difference that it MIGHT make would that it might flash faster. But to add anything to the sbin directory you would have to modify the recovery.img file and flash it. By using this guide: http://xdaforums.com/showthread.php?t=443994 it IS possible to edit the recovery.img file and add the script... but I hope you have the script exactly how you want it because it'll be a pain to modify again since you would have to do the entire editing process over. It's just not as simple as pushing it to the directory because the directory gets written after the phone is powered on. It looks as though it even gets read BEFORE the boot.img file. (Recovery.img file is mtd1 and boot.img file is mtd2. Also when you shut down, the Recovery.img file (which is backed up and stored in /system directory) is copied back over to the mtd1. So even if you do manage to modify the mtd1 file it is lost when you power on the phone before the recovery.img file is starts. Thus any changes to the sbin (which is written by the recovery.img file) will be lost.

I'm sure that makes sense... so any brave and savey soul want to try making a Recovery 1.5 file? :D
[G1 Android Development] Mikey:
Blah, im still learning all this stuff, so bear with me :)

Is what i get, any ideas?
[G1 Android Development] devsk:
Are you booted in recovery?
[G1 Android Development] Mikey:
no, i thought you cant use ADB while in recivery mode.

Should i be?

Edit.......rebooted in recovery mode and tried:
[G1 Android Development] devsk:
You should boot into recovery. And issue commands from 'adb shell' prompt and not ask it to do 'adb shell ...'. On the first page there is a mention of old 'adb' not working correctly like this. Either upgrade android tools or get into 'adb shell' and fire commands from the prompt.

And you better be in recovery when using this script.
[G1 Android Development] Chahk:
ADB doesn't seem to like prompts, try entering it in recovery console on the phone.
[G1 Android Development] devsk:
Only the old 'adb' doesn't. New 'adb' from 1.5 tools works fine.
[G1 Android Development] Chahk:
I must hunt down and destroy every instance of adb on my machine and leave only the 1.5r3 version.

I have a feature request. Could you please add another option (-w for example) to wipe /system/sd/app* and /system/sd/dalv* in order to prepare the card for installation of a new ROM?
[G1 Android Development] overground:
Been working fine for me the whole time with 1.5r3 ADB.

That would be a nice feature. I'm still looking forward to separation. I am still happy with switchrom.sh in it's current form, and use it about every other day. Thanks again, devsk.
[G1 Android Development] devsk:
Good idea! This will be part of 1.2.
[G1 Android Development] palosjr:
so if hero roms require me to wipe /system/sd/*, how will i be able to use this? i just backed up a hero rom and installed a different one that required me to do this, tried to go back and restore the first one and switchrom.sh was not there because i had wiped! arghhhh lol. no biggie, ill just try it again... ok so wait... since the backup isnt really stored on the ext, i could just adb the switchrom.sh to the /system/sd/ and run it again and my backup of my first hero should still be accessible right?
[G1 Android Development] devsk:
The answer is "yes". Just push switchrom with adb and restore. The backups are in /sdcard.
[G1 Android Development] Mikey:
Is this capable to work on an EXT4 partition?

Thats the type i have
[G1 Android Development] palosjr:
ok thanks. it clicked while i was writing that last post. is there a way to get switchrom to not delete when wiping? i dont mind pushing, its just a question.
[G1 Android Development] devsk:
I am going to add the wipe function to the script, so you don't have to remove the files manually with a filter like /system/sd/*, which will mean that switchrom.sh itself will survive the ext wipe.
[G1 Android Development] Chahk:
You don't really need to format the Ext partition to install Hero ROMs. Deleting /system/app* and /system/dalv* is quite sufficient. Trust me, I did that just yesterday. This leaves switchrom and any other scripts untouched.

Once Cyanogen rolls this script into his recovery image like he said he would, this won't be a problem.
[G1 Android Development] palosjr:
awesome! sounds good.
[G1 Android Development] palosjr:
im waiting for cyanogen to update his recovery... once this is done it will be simple. but the script works great!
[G1 Android Development] JoshHart:
Awesome script, I like your comments in the code haha comedy.
[G1 Android Development] devsk:
yeah, they look funny now. The script just started out with them...:D
[G1 Android Development] dohon:
i'm stuck on step 1.. moving the switchrom.sh to /system/sd

I just started with ADB and I am nto at all familiar with the commands.

I tried the terminal codes in this thread but it said something along the line of:

"no file or directory found"

Maybe I'll have better luck with ADB; could anyone give me a quick walkthrough to do this?

I've gone through 22 pages of this forum and did not find one :(
[G1 Android Development] dohon:
anyone :O?
[G1 Android Development] notxel21:
I would suggest getting the app "Root Explorer" It's the easiest way to move stuff without having to rely on ADB or Terminal.

Just copy and paste and reboot afterwards.:cool:
[G1 Android Development] devsk:
Most likely your are pushing it without mounting /system/sd. You need to mount it if you are in recovery ('adb shell mount /system/sd'). Otherwise, just boot into the phone and push it. Normal boot would have mounted it.

You need to run switchrom.sh from recovery.
[G1 Android Development] palosjr:
ok so i thought i had these commands saved but if i just want to delete those directories i would do ?

# mount -o rw /dev/block/mmcblk0p2 /system/
# cd /system/apps*
# rm -rf /system/apps/*
# cd /system/dalv*
# rm -rf /system/dalv/*
[G1 Android Development] devsk:
that's wrong set of commands! /system should not be used for mounting EXT partition. The right ones would be:

mount /dev/block/mmcblk0p2 /system/sd
rm -rf /system/sd/app*
rm -rf /system/sd/dalv*
[G1 Android Development] Chahk:
[Edit] Beaten to the punch by the Master Yoda himself ;)
[G1 Android Development] palosjr:
sweet thanks... i just like wiping these two so i avoid force closes and what not when switching back and forth. now second question... i know i dont really need to wipe when switching roms, but what is the recommended way to switch from say a hero rom and jacxom and vice versa...
[G1 Android Development] devsk:
If you are just switching between ROMs already saved by switchrom.sh, you don't need to do anything, switchrom.sh takes care of it. If you are installing a new ROM, then a wipe and above three commands are required to remove apps folder and dalvik cache.
[G1 Android Development] jf4888:
Someone help me get this straight.

Ok so i just tagged Cyanogens ROM using the script

but i want to tag a hero build (Elitev0.5)

So in order to not lose my tagged Cyan

I would have to not wipe my ext?(or do i, becuase wont it bootloop??))

but wipe the cache and data(using the recovery menu alt+w)

then flash away the hero(tag it also)

then jump back to cyan, with everything there before i even flashed hero

please help me out im trying to understand how to do this

thanxs in advanced
[G1 Android Development] Chahk:
Once you tag CM ROM, you should do the following (in recovery console) to prepare the SD for installation of a different ROM:

# mount /system/sd
# rm -rf /system/sd/app*
# rm -rf /system/sd/dalv*

This will wipe your Ext partition as far as the ROM is concerned. You then flash whatever ROM you want, install themes, apps, basically make it look like you want to. Then reboot to recovery, drop to console and tag it again.

After you've tagged the 2nd ROM, going back to CM doesn't require another wipe because the script already does that.
[G1 Android Development] jf4888:
So basically when you install a new ROM

you have to repush all your apps for that one

and then tag it?

so that when you come back to it later you'll have whatever apps you want for that one

becuase i kinda found out the hardway(no help)

that each time i flashed a new rom

i would have to format the ext with the commands above

then flash it, then set it up

then tag

then whatever comes next

i went from cyan(stable) to Elite(hero) then to (unstable)cyan

then back to stable cyan and everything fine

this script is very handy

saves me alot from pushing all my apps back again through adb

good job dev

hopefully they intergrate this into Cyan Recovery

oh and thanxs for the help Chahk
[G1 Android Development] overground:
Question

I guess I could try it, but wondering if you knew offhand, devsk. What would happen if I removed the .tar file from the backup and tried to restore? Would it still restore the nandroid? I guess I'll ask the same question in reverse. Removing the nandroid possibly restore just the .tar? I'm guessing maybe the first scenario may work, but the second probably not. Any thoughts?

EDIT: I don't expect any scenario to be error free.

EDIT2: Got it, thanks. So, obviously, per your reply it restores the EXT first.
[G1 Android Development] devsk:
If you remove the ext backup, you will error out right away. If you remove the nandroid backup, it will restore the ext backup and crib about failed nandroid restore.
[G1 Android Development] macray76:
I think I've found a small bug in the script.

I stored a Hero ROM and named it HERO1.5

However, when I looked at the list of saved ROMs I noticed it was saved as hero1.5

I didn't think much of it until I came to having to restore it. It was unable to complete the nandroid part of the restore and the log file didn't say much.

So I went to the /sdcard/switchROM/hero1.5/nandroid/ folder and noticed that the saved folder still had the name capitalised (i.e HERO1.5-CBD...)

I fixed the issue by renaming this folder hero1.5-CBD...

In the past, when I have stored ROMs with names as a mix of upper and lower case letters, it has saved them fine. Looks like the issue could be where only upper case letters are used.

Otherwise, it is a great script which I find invaluable! Many thanks!
[G1 Android Development] Chahk:
I've learned a long time ago to always use lower case whenever I work in case-sensitive environments.
[G1 Android Development] dumfuq:
Complete Ext backup

So I tweaked switchrom.sh to give the option of a complete backup/restoration which includes all files on /system/sd instead of just the apps and our dalvik overlords folder. My initial reasoning was to be able to switch between ROMs that had unique /system/sd/userinit.sh or /system/sd/bin files. This is switchromv1.1 with one extra option available “-a”.

-a|--all

"-a|--all" can be used in conjunction with "-s|store" and "-r|restore".

when used with "-s" it backs up the entire Ext partition

when used with "-r" it deletes the entire Ext partition before restoring
[G1 Android Development] rainabba:
RAv1.2

Any reason this script wouldn't work with RAv1.2 Recovery Rom?

Honestly I can't remember exactly why right now, but I prefer it (think it had a couple more options) so I'd rather not switch if it's not necessary.

UPDATE: So far it looks like this works fine with RAv1.2
[G1 Android Development] devsk:
Thank you for doing this! I have not been able to make much progress on this script because I have been too busy with other personal stuff. I will incorporate this in the next version whenever I get the time to do it.
[G1 Android Development] devsk:
I somehow lost subscription to this thread...strange!
[G1 Android Development] jf4888:
all i know is

switchrom.is the best mutha 4ucken script ever

and i dont know what id do without it

go dev
[G1 Android Development] palosjr:
second that. it has made switching and testing and finding an awesome ROM easier than ever!
[G1 Android Development] cx92001:
I agree this is the most useful script ever.
[G1 Android Development] Chahk:
It's up there with sdparted and userinit.sh :)
[G1 Android Development] palosjr:
if i got a new sd, and i moved everything from my old sd to my new one, would i be able to run switchrom and boot back to the backups i have made... i know with nandroid this causes problems so i understand it not working, i just dont want to have to get everything all up and running again just to get back to where i was.
[G1 Android Development] cx92001:
Cool. I love the revision. Choosing from the list is a very nice function. Keep up the good work.
[G1 Android Development] dumfuq:
added a few more things

I have added some more functionality to switchrom in order to make it more versatile as a backup/restore tool. This is still almost entirely the same script(v1.1), I just added a few options to choose what data is to be stored/restored and changed the default to store all.

New Features:

store/restore all made default

ability to store/restore extended partition only

ability to store/restore nandroid backup only

ability to store/restore base only (nandroid, apps folders, and dalvik-cache)

options and rom_name are always optional

Usage:

switchrom [options] -s|--store [rom_name]

switchrom [options] -r|--restore [rom_name]

switchrom -d|--delete [rom_name]

Options:

-b –-base, nandroid apps dalvik_cache

-c –-compress, only used with -s

-e –-ext_only

-h –-help

-l –-list

-n –-nandroid_only

-v –-version

Examples:

store a complete backup, prompt for rom_name (nandroid and entire ext partition)

sh /system/sd/switchrom.sh -s

store nandroid, /system/sd/apps*, and /system/sd/dalv* (original switchrom behavior)

sh /system/sd/switchrom.sh -b -s

store nandroid only and name it mycy_nand

sh /system/sd/switchrom.sh -n -s mycy_nand

store complete ext partition only

sh /system/sd/switchrom.sh -e -s

store /system/sd/apps* and system/sd/dalv* only

sh /system/sd/switchrom.sh -b -e -s

restore complete backup (nandroid and entire ext partition)

sh /system/sd/switchrom.sh -r

restore nandroid, apps folder, and dalvik-cache (original switchrom behavior)

sh /system/sd/switchrom.sh -b -r

restore entire ext partition only

sh /system/sd/switchrom.sh -e -r

restore /system/sd/app* and /system/sd/dalv* (not nandroid, only apps* dalv* folders cleared first, rest of ext partition left intact)

sh /system/sd/switchrom.sh -b -e -r

delete a backed up rom

sh /system/sd/switchrom.sh -d

Obviously -e and -n don't work together.

You can update just the ext partition on an existing saved rom or whatnot.

***************Warning****************

By default when doing -r|--restore the ext partition data will be deleted before restoration. If you only want the app* and dalv* folders cleared first, be sure to specify the -b option.

**************************************

Thank you much devsk your script is awesome!
[G1 Android Development] palosjr:
hate to do this but....bump, for this question.
[G1 Android Development] overground:
Well, until someone tries it, I'm going to have to speculate. I think it should work. As long as your new EXT is at least as large as your previous one. If anyone tries switching sdcards and attempts a restore with this, please don't forget to let us know how it went.

BTW: A huge thank you to devsk for making the first great leaps with this. This script has already saved my ass at least a half a dozen times the way it stood at 1.1.

@ Dumfuq....well, you know.
[G1 Android Development] palosjr:
im about to just dive in and try it now. i just set up my new sdcard with the same size ext partition. only thing i changed was linux-swap... upped it from 32 to 64MB

i am going to transfer it all over, i already got my data backed up on my hard drive, its transferring over now. only thing i might lose is my current rom but i will just go back to my last switchrom save and get back to where i was from there.

heres hoping the best! post back in a few.
[G1 Android Development] nolimit78:
Actually the answer is yes. I've done this a couple times. Everything is stored in the folder that switchROM creates. You're good :)
[G1 Android Development] palosjr:
sweet bro thanks for the clairfication. i am pushing back my /system/sd folders now... its taking a while... been stuck on LatinIME.dex from the davl-cache folder for a few mintues.

-EDIT-

it works. i did a switchrom save of my current rom.

then did an adb pull of /sdcard then adb push to my new sd card (pushed the files from my hard drive)

put new sd card in phone, reboot into recovery, pushed switchrom.sh back over to /system/sd

ran switchrom.sh, restored the rom i just saved, voila, all is good as new. i am going to test with the other roms i had saved to make sure it works and i didnt just get lucky.
[G1 Android Development] BrooklynAvi:
Typo

First of all, great script. I am not much of a shell scripter (mostly PHP and .NET) but your code is pretty easy to follow (looks like a C variant of some sort but Linux is not my thing unfortunately). Anyway, you may want to correct a typo in one of the echo statements in the help command. It currently reads "Don't use blanks or special characetrs in rom_name." The word "characters" has letters reversed.

Can't wait to try this script. I have been itching to throw a Hero ROM on my phone just so I can see it in person rather than just videos but I my current setup is too nice to risk it. Now I think I have found the tool that will allow me to do this. Thanks.

EDIT: The typo is also in the OP.
[G1 Android Development] BrooklynAvi:
Delete /sdcard/BackupRoot for BRU.
[G1 Android Development] cx92001:
You will never regret it. This script made switching roms more fun and exciting than ever.;)