-
-
Save slabua/7616020 to your computer and use it in GitHub Desktop.
Revisions
-
slabua revised this gist
Nov 23, 2013 . 1 changed file with 23 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,27 +14,35 @@ # # USAGE: Boot your phone in to TWRP, then run this script # # Currently only backs up /data, /system, /boot and /recovery which mactches TWRPs default. # It will also ignore /data/media files (like TWRP does) # # This might not work so well on anything other than a Nexus 4 ¯(°_o)/¯ # Specify your boot and recovery partitions below: BOOT_PARTITION="/dev/block/platform/msm_sdcc.1/by-name/boot" #Nexus 4 BOOT_NOTE="Nexus 4" # This isn't required, it's just for logging # You can change it if you have multiple copies of this file RECOVERY_PARTITION="/dev/block/platform/msm_sdcc.1/by-name/recovery" #Nexus 4 RECOVERY_NOTE="Nexus 4" # This isn't required, it's just for logging # You can change it if you have multiple copies of this file # To find your boot partition, reboot in to twrp, then run # adb shell cat /etc/recovery.fstab | grep /boot # The last line on the right is your boot partition # To find your recovery partition, reboot in to twrp, then run # adb shell cat /etc/recovery.fstab | grep /recovery # The last line on the right is your recovery partition SYSTEM_START_MESSAGE="Backing up /system..." SYSTEM_DONE_MESSAGE="/system backup complete!" DATA_START_MESSAGE="Backing up /data..." DATA_DONE_MESSAGE="/data backup complete!" BOOT_START_MESSAGE="Backing up /boot for a $BOOT_NOTE from $BOOT_PARTITION..." BOOT_DONE_MESSAGE="/boot backup complete!" RECOVERY_START_MESSAGE="Backing up /recovery for a $RECOVERY_NOTE from $RECOVERY_PARTITION..." RECOVERY_DONE_MESSAGE="/recovery backup complete!" adb shell mount -r /system @@ -50,6 +58,8 @@ adb forward tcp:5551 tcp:5551 adb shell "rm -rf /tmp/data_fifo && mkfifo /tmp/data_fifo && cd /data/ && tar -cz --exclude='media*' -f /tmp/data_fifo * & nc -l -p 5551 -e cat /tmp/data_fifo" & adb forward tcp:5552 tcp:5552 adb shell "rm -rf /tmp/boot_fifo && mkfifo /tmp/boot_fifo && dd if=$BOOT_PARTITION of=/tmp/boot_fifo & nc -l -p 5552 -e cat /tmp/boot_fifo" & adb forward tcp:5553 tcp:5553 adb shell "rm -rf /tmp/recovery_fifo && mkfifo /tmp/recovery_fifo && dd if=$RECOVERY_PARTITION of=/tmp/recovery_fifo & nc -l -p 5553 -e cat /tmp/recovery_fifo" & sleep 1 @@ -80,7 +90,16 @@ echo $DATA_START_MESSAGE | tee -a recovery.log BOOT_PID=$! echo $BOOT_START_MESSAGE | tee -a recovery.log # Backup /recovery ( nc 127.0.0.1 5553 > recovery.emmc.win md5sum recovery.emmc.win > recovery.emmc.win.md5 echo $RECOVERY_DONE_MESSAGE ) | tee -a recovery.log & RECOVERY_PID=$! echo $RECOVERY_START_MESSAGE | tee -a recovery.log wait $SYS_PID $DATA_PID $BOOT_PID $RECOVERY_PID echo "Done!" | tee -a recovery.log -
inhies revised this gist
Mar 2, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ # # This might not work so well on anything other than a Nexus 4 ¯(°_o)/¯ # Specify your boot partition below: BOOT_PARTITION="/dev/block/platform/msm_sdcc.1/by-name/boot" #Nexus 4 BOOT_NOTE="Nexus 4" # This isn't required, it's just for logging -
inhies revised this gist
Mar 2, 2013 . 1 changed file with 13 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #!/bin/bash # # Version 1.4 # # twrp.sh -- a TWRP compatible backup script for your computer # Brought to you by inhies @@ -19,11 +19,21 @@ # # This might not work so well on anything other than a Nexus 4 ¯(°_o)/¯ # Uncomment only one of the lines below: BOOT_PARTITION="/dev/block/platform/msm_sdcc.1/by-name/boot" #Nexus 4 BOOT_NOTE="Nexus 4" # This isn't required, it's just for logging # You can change it if you have multiple copies of this file # To find your boot partition, reboot in to twrp, then run # adb shell cat /etc/recovery.fstab | grep /boot # The last line on the right is (should be?) your boot partition SYSTEM_START_MESSAGE="Backing up /system..." SYSTEM_DONE_MESSAGE="/system backup complete!" DATA_START_MESSAGE="Backing up /data..." DATA_DONE_MESSAGE="/data backup complete!" BOOT_START_MESSAGE="Backing up /boot for a $BOOT_NOTE from $BOOT_PARTITION..." BOOT_DONE_MESSAGE="/boot backup complete!" adb shell mount -r /system @@ -39,7 +49,7 @@ adb shell "rm -rf /tmp/sys_fifo && mkfifo /tmp/sys_fifo && cd /system/ && tar -c adb forward tcp:5551 tcp:5551 adb shell "rm -rf /tmp/data_fifo && mkfifo /tmp/data_fifo && cd /data/ && tar -cz --exclude='media*' -f /tmp/data_fifo * & nc -l -p 5551 -e cat /tmp/data_fifo" & adb forward tcp:5552 tcp:5552 adb shell "rm -rf /tmp/boot_fifo && mkfifo /tmp/boot_fifo && dd if=$BOOT_PARTITION of=/tmp/boot_fifo & nc -l -p 5552 -e cat /tmp/boot_fifo" & sleep 1 -
inhies revised this gist
Mar 2, 2013 . 1 changed file with 5 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #!/bin/bash # # Version 1.3 # # twrp.sh -- a TWRP compatible backup script for your computer # Brought to you by inhies @@ -24,7 +24,7 @@ SYSTEM_DONE_MESSAGE="/system backup complete!" DATA_START_MESSAGE="Backing up /data..." DATA_DONE_MESSAGE="/data backup complete!" BOOT_START_MESSAGE="Backing up /boot..." BOOT_DONE_MESSAGE="/boot backup complete!" adb shell mount -r /system @@ -50,7 +50,7 @@ sleep 1 echo $SYSTEM_DONE_MESSAGE ) | tee -a recovery.log & SYS_PID=$! echo $SYSTEM_START_MESSAGE | tee -a recovery.log # Backup /data ( @@ -59,7 +59,7 @@ echo "$SYSTEM_START_MESSAGE (PID $SYS_PID)" | tee -a recovery.log echo $DATA_DONE_MESSAGE ) | tee -a recovery.log & DATA_PID=$! echo $DATA_START_MESSAGE | tee -a recovery.log # Backup /boot ( @@ -68,9 +68,7 @@ echo "$DATA_START_MESSAGE (PID $DATA_PID)" | tee -a recovery.log echo $BOOT_DONE_MESSAGE ) | tee -a recovery.log & BOOT_PID=$! echo $BOOT_START_MESSAGE | tee -a recovery.log wait $SYS_PID $DATA_PID $BOOT_PID -
inhies revised this gist
Mar 2, 2013 . 1 changed file with 23 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #!/bin/bash # # Version 1.2 # # twrp.sh -- a TWRP compatible backup script for your computer # Brought to you by inhies @@ -14,14 +14,17 @@ # # USAGE: Boot your phone in to TWRP, then run this script # # Currently only backs up /data, /system, and /boot which mactches TWRPs default. # It will also ignore /data/media files (like TWRP does) # # This might not work so well on anything other than a Nexus 4 ¯(°_o)/¯ SYSTEM_START_MESSAGE="Backing up /system..." SYSTEM_DONE_MESSAGE="/system backup complete!" DATA_START_MESSAGE="Backing up /data..." DATA_DONE_MESSAGE="/data backup complete!" BOOT_START_MESSAGE="Backing up /boot..." BOOT_DONE_MESSAGE="/boot backup complete!"= adb shell mount -r /system @@ -34,7 +37,9 @@ echo "Backup started in $FOLDER" adb forward tcp:5550 tcp:5550 adb shell "rm -rf /tmp/sys_fifo && mkfifo /tmp/sys_fifo && cd /system/ && tar -cz -f /tmp/sys_fifo * & nc -l -p 5550 -e cat /tmp/sys_fifo" & adb forward tcp:5551 tcp:5551 adb shell "rm -rf /tmp/data_fifo && mkfifo /tmp/data_fifo && cd /data/ && tar -cz --exclude='media*' -f /tmp/data_fifo * & nc -l -p 5551 -e cat /tmp/data_fifo" & adb forward tcp:5552 tcp:5552 adb shell "rm -rf /tmp/boot_fifo && mkfifo /tmp/boot_fifo && dd if=/dev/block/mmcblk0p6 of=/tmp/boot_fifo & nc -l -p 5552 -e cat /tmp/boot_fifo" & sleep 1 @@ -45,7 +50,7 @@ sleep 1 echo $SYSTEM_DONE_MESSAGE ) | tee -a recovery.log & SYS_PID=$! echo "$SYSTEM_START_MESSAGE (PID $SYS_PID)" | tee -a recovery.log # Backup /data ( @@ -54,11 +59,21 @@ echo "$SYSTEM_START_MESSAGE (PID $SYS_PID)" echo $DATA_DONE_MESSAGE ) | tee -a recovery.log & DATA_PID=$! echo "$DATA_START_MESSAGE (PID $DATA_PID)" | tee -a recovery.log # Backup /boot ( nc 127.0.0.1 5552 > boot.emmc.win md5sum boot.emmc.win > boot.emmc.win.md5 echo $BOOT_DONE_MESSAGE ) | tee -a recovery.log & BOOT_PID=$! echo "$BOOT_START_MESSAGE (PID $BOOT_PID)" | tee -a recovery.log echo "If you kill me now, you'll have to manually stop the PIDs listed above" wait $SYS_PID $DATA_PID $BOOT_PID echo "Done!" | tee -a recovery.log adb shell umount /system -
inhies revised this gist
Mar 2, 2013 . 1 changed file with 27 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #!/bin/bash # # Version 2 # # twrp.sh -- a TWRP compatible backup script for your computer # Brought to you by inhies @@ -9,10 +9,13 @@ # By default it makes a folder in the standard TWRP date--time format (I think) # To restore these backups, place the folder in /sdcard/TWRP/BACKUPS/<serialnumber>/ # # If you can figure out a better way to run the two netcat downloads in parallel # I would be forever grateful # # USAGE: Boot your phone in to TWRP, then run this script # # Currently only backs up /data and /system. Ignores /data/media files (like TWRP does) # This might not work so well on anything other than a Nexus 4 ¯(°_o)/¯ SYSTEM_START_MESSAGE="Backing up /system..." SYSTEM_DONE_MESSAGE="/system backup complete!" @@ -25,28 +28,37 @@ adb shell mount -r /system FOLDER=`date '+%Y-%m-%d--%H-%M-%S'` mkdir $FOLDER; cd $FOLDER echo "Backup started in $FOLDER" # Setup adb forward tcp:5550 tcp:5550 adb shell "rm -rf /tmp/sys_fifo && mkfifo /tmp/sys_fifo && cd /system/ && tar -cz -f /tmp/sys_fifo * & nc -l -p 5550 -e cat /tmp/sys_fifo" & adb forward tcp:5551 tcp:5551 adb shell "rm -rf /tmp/data_fifo && mkfifo /tmp/data_fifo && cd /data/ && tar -cz --exclude='media*' -f /tmp/data_fifo * & nc -l -p 5551 -e cat /tmp/data_fifo"& sleep 1 # Backup /system ( nc 127.0.0.1 5550 > system.ext4.win md5sum system.ext4.win > system.ext4.win.md5 echo $SYSTEM_DONE_MESSAGE ) | tee -a recovery.log & SYS_PID=$! echo "$SYSTEM_START_MESSAGE (PID $SYS_PID)" # Backup /data ( nc 127.0.0.1 5551 > data.ext4.win md5sum data.ext4.win > data.ext4.win.md5 echo $DATA_DONE_MESSAGE ) | tee -a recovery.log & DATA_PID=$! echo "$DATA_START_MESSAGE (PID $DATA_PID)" echo "If you kill me now, you'll have to manually stop the PIDs listed above" wait $SYS_PID $DATA_PID echo $DONE_MESSAGE | tee -a recovery.log adb shell umount /system -
inhies created this gist
Mar 2, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ #!/bin/bash # # Version 1 # # twrp.sh -- a TWRP compatible backup script for your computer # Brought to you by inhies # # This script creates TWRP compatible backups over usb using adb and magikz # By default it makes a folder in the standard TWRP date--time format (I think) # To restore these backups, place the folder in /sdcard/TWRP/BACKUPS/<serialnumber>/ # # If you can figure out how to run the two netcat downloads in parallel it will # work twice as fast, but I failed and don't want to waste more time on it for now. # # USAGE: Boot your phone in to TWRP, then run this script SYSTEM_START_MESSAGE="Backing up /system..." SYSTEM_DONE_MESSAGE="/system backup complete!" DATA_START_MESSAGE="Backing up /data..." DATA_DONE_MESSAGE="/data backup complete!" DONE_MESSAGE="Done!" adb shell mount -r /system FOLDER=`date '+%Y-%m-%d--%H-%M-%S'` mkdir $FOLDER; cd $FOLDER # Setup adb forward tcp:5550 tcp:5550 adb shell "rm -rf /tmp/sys_fifo && mkfifo /tmp/sys_fifo && cd /system/ && tar -c -f /tmp/sys_fifo * & nc -l -p 5550 -e cat /tmp/sys_fifo" & adb forward tcp:5551 tcp:5551 adb shell "rm -rf /tmp/data_fifo && mkfifo /tmp/data_fifo && cd /data/ && tar -c --exclude='media*' -f /tmp/data_fifo * & nc -l -p 5551 -e cat /tmp/data_fifo"& sleep 1 # Backup /system echo $SYSTEM_START_MESSAGE | tee -a recovery.log nc 127.0.0.1 5550 > system.ext4.win md5sum system.ext4.win > system.ext4.win.md5 echo $SYSTEM_DONE_MESSAGE | tee -a recovery.log # Backup /data echo $DATA_START_MESSAGE | tee -a recovery.log nc 127.0.0.1 5551 > data.ext4.win md5sum data.ext4.win > data.ext4.win.md5 echo $DATA_DONE_MESSAGE | tee -a recovery.log echo $DONE_MESSAGE | tee -a recovery.log adb shell umount /system