FORUMS

[GUIDE] How To Backup and Restore using tar on adb shell - Fastest recovery

929 posts
Thanks Meter: 167
 
Post Reply Email Thread
If you are like me, and try out things alot that leave you with an unusable system and you want to recover as fast as possible, I made a small Listing, that shows what you have to enter on adb shell while booted in recovery.

Prequisites:
  • Tested on FuguMod >= 2.0 only
  • Be sure you have enough space free on internal SD
  • all these commands are issued in adb shell while booted into Recovery Mode
  • It restores to JFS on all partitions

One-liners for copy paste while root on adb shell in Recovery Mode:

Backup:
Code:
mount /dev/block/mmcblk0p1 /mnt/sdcard; mount /dev/block/mmcblk0p2 /data; mount /dev/block/stl10 /dbdata; rm /mnt/sdcard/system.tar /mnt/sdcard/data.tar /mnt/sdcard/dbdata.tar && cd / && tar cvf /mnt/sdcard/system.tar /system && tar cvf /mnt/sdcard/data.tar /data && tar cvf /mnt/sdcard/dbdata.tar /dbdata
Restore:
Code:
umount /system; umount /data; umount /mnt/sdcard; umount /dbdata; umount /cache; /sbin/jfs_mkfs -q /dev/block/stl9 && /sbin/jfs_mkfs -q /dev/block/mmcblk0p2 && /sbin/jfs_mkfs -q /dev/block/stl10 && /sbin/jfs_mkfs -q /dev/block/stl11 && mount /dev/block/mmcblk0p1 /mnt/sdcard; mount /dev/block/mmcblk0p2 /data; mount /dev/block/stl9 /system; mount /dev/block/stl10 /dbdata; mount /dev/block/stl11 /cache; cd / && tar xvf /mnt/sdcard/system.tar && tar xvf /mnt/sdcard/data.tar && tar xvf /mnt/sdcard/dbdata.tar
In detail:

Backup:
Code:
# backup - in adb shell (as root) do:
# --------------------------------------------------
# mount all filesystems
mount /dev/block/mmcblk0p1 /mnt/sdcard
mount /dev/block/mmcblk0p2 /data
mount /dev/block/stl9 /system
mount /dev/block/stl10 /dbdata
# remove older backups
rm /mnt/sdcard/data.tar /mnt/sdcard/system.tar /mnt/sdcard/dbdata.tar
# backup them all to the root of the internal sdcard (make sure enough space is free)
cd /
tar cvf /mnt/sdcard/system.tar /system
tar cvf /mnt/sdcard/data.tar /data
tar cvf /mnt/sdcard/dbdata.tar /dbdata
Restore:
Code:
# restore - process
# --------------------------------------------------
# flash stock ROM with Odin/heimdall
# flash fugumod with Odin/heimdall
# reboot recovery - claim root and open a shell
adb root
adb shell
# unmount all filesystems
umount /system
umount /data
umount /mnt/sdcard
umount /dbdata
umount /cache
# recreate filesystems (jfs)
/sbin/jfs_mkfs -q /dev/block/stl9
/sbin/jfs_mkfs -q /dev/block/mmcblk0p2
/sbin/jfs_mkfs -q /dev/block/stl10
/sbin/jfs_mkfs -q /dev/block/stl11
# mount all filesystems and internal sdcard
mount /dev/block/mmcblk0p1 /mnt/sdcard
mount /dev/block/mmcblk0p2 /data
mount /dev/block/stl9 /system
mount /dev/block/stl10 /dbdata
mount /dev/block/stl11 /cache
# restore the tar
cd /
tar xvf /mnt/sdcard/system.tar
tar xvf /mnt/sdcard/data.tar
tar xvf /mnt/sdcard/dbdata.tar
Listing: http://pastebin.com/rpZW1uWD
The Following 12 Users Say Thank You to zurchpet For This Useful Post: [ View ] Gift zurchpet Ad-Free
4th April 2011, 03:31 PM |#2  
ragin's Avatar
Senior Member
Flag Hubli
Thanks Meter: 159
 
More
Good stuff.
The Following User Says Thank You to ragin For This Useful Post: [ View ] Gift ragin Ad-Free
4th April 2011, 03:40 PM |#3  
theduckking's Avatar
Senior Member
Thanks Meter: 98
 
More
really useful, thank you.
Danke^^

When I think about it, it should not be too difficult to write an application to create and pull the backups off the phone. And pushing and restoring would be the same thing in the other way. If I got some spare time I could do that, I think it would be really handy
4th April 2011, 03:42 PM |#4  
zurchpet's Avatar
OP Senior Member
Flag Winterthur, Schweiz
Thanks Meter: 167
 
More
Yeah... I also though about to supply an update.zip for backup and one for restore... but I was to lazy
4th April 2011, 03:58 PM |#5  
theduckking's Avatar
Senior Member
Thanks Meter: 98
 
More
I'm starting to form the project and layout for the program in my head, but on the other hand my laziness starts to fight all growing motivation. I'm wondering how this will turn out
9th April 2011, 01:01 PM |#6  
Perka's Avatar
Senior Member
Thanks Meter: 3,139
 
More
Works perfect, thx.
13th May 2011, 10:57 PM |#7  
Junior Member
Flag Budapest
Thanks Meter: 1
 
More
How and in what regard is this faster than making the backup with CWM?

Not that I don't believe you that it is faster I just want to understand things

I pretty much understand what your script does, so probably what I would need to know to see the difference is how the CWM does the backup. I guess CWM is storing the whole file system with dd or something like that...
15th May 2011, 03:08 PM |#8  
zurchpet's Avatar
OP Senior Member
Flag Winterthur, Schweiz
Thanks Meter: 167
 
More
Quote:
Originally Posted by zsori

How and in what regard is this faster than making the backup with CWM?

Not that I don't believe you that it is faster I just want to understand things

I pretty much understand what your script does, so probably what I would need to know to see the difference is how the CWM does the backup. I guess CWM is storing the whole file system with dd or something like that...

It's faster since it does not create a new filesystem to back up the data... TBH. It is less safe than a nandroid backup (no md5 check). but faster in creation. and actually never failed on me

also everybody modding the hell out of their phones should get to know adb shell and the power that lies within it. You can take many shortcuts and debug errors easier.
20th August 2014, 08:48 AM |#9  
Junior Member
Thanks Meter: 0
 
More
do I understand correctly that this is able to restore a TAR file decrypted from a AB android backup file created before?
13th November 2017, 02:53 AM |#10  
Member
Thanks Meter: 7
 
More
Can this make the backup on the computer the phone is connected to? Not enough free space on the phone to backup to.
Can it pull apps and their data from external SD?
Does it work without the user having to touch the screen? Broken screen, no touch possible and can't see anything so even if I had paired a bluetooth mouse before the damage it'd still be useless.
Can it restore to a different but identical in every way phone?
Post Reply Subscribe to Thread

Tags
backup, fugumod, guide, restore, tar

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes