chris41g

Nandroid Backup Script

May 27th, 2011
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.73 KB | None | 0 0
  1. #!/sbin/sh -x
  2. ## This program is free software; you can redistribute it and/or modify it
  3. # under the terms of the GNU Library General Public License as published
  4. # by the Free Software Foundation; either version 2, or (at your option)
  5. # any later version.
  6. ## This program is distributed in the hope that it will be useful,
  7. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  9. # GNU General Public License for more details.
  10. ## License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>
  11. BB=/sbin/busybox;
  12. YAFF=/sbin/mkyaffs2image;
  13. DATA=/dev/block/stl10;
  14. DUMP=cat;
  15. SYS=/dev/block/stl9;
  16. CHE=/dev/block/stl11;
  17. SD=/dev/block/mmcblk0p1;
  18. BOOT=/dev/block/bml7;
  19. RECOV=/dev/block/bml8;
  20. DATE=`date +.%m.%d.%Y.%I:%M`;
  21. BU=/sdcard/clockworkmod/backup/$DATE;
  22. OUTFD=$(ps | grep -v "grep" | grep -o -E "update_binary(.*)" | cut -d " " -f 3);
  23. ui_print() {
  24.   if [ $OUTFD != "" ]; then
  25.     echo "ui_print ${1} " 1>&$OUTFD;
  26.     echo "ui_print " 1>&$OUTFD;
  27.   else
  28.     echo "${1}";
  29.   fi;
  30. }
  31. $BB mount $DATA /data;
  32. $BB mount $SD /sdcard;
  33. #exec > /sdcard/backup.log 2>&1
  34. $BB mount $SYS /system;
  35. $BB mount $CHE /cache;
  36. $BB test -d $BU || $BB mkdir $BU;
  37. $BB rm -rf $BU/*;
  38. cd $BU && ui_print "Backing up Boot Kernel" && $DUMP $BOOT > boot.img && ui_print "Backing up Recovery Kernel" && $DUMP $RECOVERY > recovery.img;
  39. ui_print "Backing up System" && $YAFF /system $BU/system.img && ui_print "Backing up Data" && $YAFF /data $BU/data.img && ui_print "Backing up Cache" && $YAFF /cache $BU/cache.img && ui_print "Backing up .android_secure" && $YAFF /sdcard/.android_secure $BU/.android_secure.img;
  40. ui_print "Generating MD5" && $BB md5sum *img > $BU/nandroid.md5;
Advertisement
Add Comment
Please, Sign In to add comment