-
-
Save slabua/7616020 to your computer and use it in GitHub Desktop.
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 characters
| #!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment