zurchpet

How to backup and restore with tar in ext4

Apr 7th, 2011
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.06 KB | None | 0 0
  1. # Precautions
  2. # --------------------------------------------------
  3. #
  4. # - only tesed with FuguMod >= 2.0 and SpeedMod >= K13D
  5. # - you do all those commands while booted into Recovery Mode
  6. # - be sure to have enough space free on internal SD
  7. # - It restores to ext4-all
  8.  
  9. # Fast one-liners for copy & paste
  10. # --------------------------------------------------
  11. # *** BACKUP ***
  12. 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
  13.  
  14. # *** RESTORE ***
  15. umount /system; umount /data; umount /mnt/sdcard; umount /dbdata; umount /cache; /sbin/mke2fs -J size=4 -T ext4 -b 4096 -O ^resize_inode,^ext_attr,^huge_file /dev/block/stl9 && /sbin/mke2fs -J size=4 -T ext4 -b 4096 -O ^resize_inode,^ext_attr,^huge_file /dev/block/mmcblk0p2 && /sbin/mke2fs -J size=4 -T ext4 -b 4096 -O ^resize_inode,^ext_attr,^huge_file /dev/block/stl10 && /sbin/mke2fs -J size=4 -T ext4 -b 4096 -O ^resize_inode,^ext_attr,^huge_file /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
  16.  
  17. # backup - in adb shell (as root) do:
  18. # --------------------------------------------------
  19. # mount all filesystems
  20. mount /dev/block/mmcblk0p1 /mnt/sdcard
  21. mount /dev/block/mmcblk0p2 /data
  22. mount /dev/block/stl9 /system
  23. mount /dev/block/stl10 /dbdata
  24. # remove older backups
  25. rm /mnt/sdcard/data.tar /mnt/sdcard/system.tar /mnt/sdcard/dbdata.tar
  26. # backup them all to the root of the internal sdcard (make sure enough space is free)
  27. cd /
  28. tar cvf /mnt/sdcard/system.tar /system
  29. tar cvf /mnt/sdcard/data.tar /data
  30. tar cvf /mnt/sdcard/dbdata.tar /dbdata
  31. # restore - process
  32. # --------------------------------------------------
  33. # flash stock ROM with Odin/heimdall
  34. # flash fugumod with Odin/heimdall
  35. # reboot recovery - claim root and open a shell
  36. adb root
  37. adb shell
  38. # unmount all filesystems
  39. umount /system
  40. umount /data
  41. umount /mnt/sdcard
  42. umount /dbdata
  43. umount /cache
  44. umount -f /cache
  45. # recreate filesystems (jfs)
  46. /sbin/mke2fs -J size=4 -T ext4 -b 4096 -O ^resize_inode,^ext_attr,^huge_file /dev/block/stl9
  47. /sbin/mke2fs -J size=4 -T ext4 -b 4096 -O ^resize_inode,^ext_attr,^huge_file /dev/block/mmcblk0p2
  48. /sbin/mke2fs -J size=4 -T ext4 -b 4096 -O ^resize_inode,^ext_attr,^huge_file /dev/block/stl10
  49. /sbin/mke2fs -J size=4 -T ext4 -b 4096 -O ^resize_inode,^ext_attr,^huge_file /dev/block/stl11
  50. # mount all filesystems and internal sdcard
  51. mount /dev/block/mmcblk0p1 /mnt/sdcard
  52. mount /dev/block/mmcblk0p2 /data
  53. mount /dev/block/stl9 /system
  54. mount /dev/block/stl10 /dbdata
  55. mount /dev/block/stl11 /cache
  56. # restore the tar
  57. cd /
  58. tar xvf /mnt/sdcard/system.tar
  59. tar xvf /mnt/sdcard/data.tar
  60. tar xvf /mnt/sdcard/dbdata.tar
  61. # reboot
  62. reboot bootloader
Advertisement
Add Comment
Please, Sign In to add comment