Update
This commit is contained in:
parent
8845fb6fb2
commit
6a8d21b55e
@ -11,6 +11,9 @@ fi
|
|||||||
|
|
||||||
mkdir -p "$outdir"
|
mkdir -p "$outdir"
|
||||||
|
|
||||||
find "$backupdir" -name "data.*.win*" ! -name '*.sha2' ! -name '*.info' -type f -exec tar -xvf {} --directory="$bashdir/$outdir" \;
|
for i in $(find "$backupdir" -name "data.*.win*" ! -name '*.sha2' ! -name '*.info' -type f); do
|
||||||
|
echo "Extracting file \"$i\""
|
||||||
|
pv $i | tar -x --overwrite -C "$bashdir/$outdir"
|
||||||
|
done
|
||||||
|
|
||||||
echo "Done."
|
echo "Done."
|
||||||
|
@ -3,12 +3,14 @@
|
|||||||
|
|
||||||
basedir="$PWD"
|
basedir="$PWD"
|
||||||
|
|
||||||
|
echo "Found main user"
|
||||||
|
ls "$basedir/work/data/data/" --format single-column --indicator-style none > "$basedir/work/packages_list_0.txt"
|
||||||
|
|
||||||
cd work/data/user
|
cd work/data/user
|
||||||
|
|
||||||
for USERID in *; do
|
for USERID in *; do
|
||||||
if [ -d "${USERID}" ]; then
|
if [ -d "${USERID}" ]; then
|
||||||
echo "${USERID}" # your processing here
|
echo "Found user ${USERID}"
|
||||||
ls "$basedir/work/data/user/$USERID/" --format single-column --indicator-style none > "$basedir/work/packages_list_${USERID}.txt"
|
ls "$basedir/work/data/user/$USERID/" --format single-column --indicator-style none > "$basedir/work/packages_list_${USERID}.txt"
|
||||||
fi
|
fi
|
||||||
ls "$basedir/work/data/data/" --format single-column --indicator-style none > "$basedir/work/packages_list_0.txt"
|
|
||||||
done
|
done
|
||||||
|
@ -34,15 +34,15 @@ remotepackages="/data/user/${USER_NUMBER}/"
|
|||||||
readarray -t packages < "work/packages_list_${BACKUP_USER_NUMBER}.txt"
|
readarray -t packages < "work/packages_list_${BACKUP_USER_NUMBER}.txt"
|
||||||
|
|
||||||
if [ -z "$BACKUP_USER_NUMBER" ]
|
if [ -z "$BACKUP_USER_NUMBER" ]
|
||||||
then
|
then
|
||||||
echo "Syntax: script.sh <old_user_id_number> <new_user_id_number>"
|
echo "Syntax: script.sh <old_user_id_number> <new_user_id_number>"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$USER_NUMBER" ]
|
if [ -z "$USER_NUMBER" ]
|
||||||
then
|
then
|
||||||
echo "Syntax: script.sh <old_user_id_number> <new_user_id_number>"
|
echo "Syntax: script.sh <old_user_id_number> <new_user_id_number>"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "=========================================================\n"
|
printf "=========================================================\n"
|
||||||
@ -57,44 +57,61 @@ printf "=========================================================\n"
|
|||||||
|
|
||||||
for package in ${packages[*]}
|
for package in ${packages[*]}
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
printf "=========================================================\n"
|
printf "=========================================================\n"
|
||||||
adb shell am start -a android.intent.action.VIEW -d market://details?id=$package
|
if [[ $(curl -oIL -s -w "%{http_code}" "https://play.google.com/store/apps/details?id=$package") -eq 404 ]]; then
|
||||||
#while [ -n "$(adb shell "dumpsys activity | grep top-activity | grep 'com.android.vending'")" ]; do
|
echo "Skipping package \"$package\" because it's not on the play store."
|
||||||
# echo "wait..."
|
else
|
||||||
# sleep 1
|
adb shell am start -a android.intent.action.VIEW -d market://details?id=$package
|
||||||
#done
|
#while [ -n "$(adb shell "dumpsys activity | grep top-activity | grep 'com.android.vending'")" ]; do
|
||||||
echo "When you have the app installed, press volume UP to copy the data, press volume DOWN to skip"
|
# echo "wait..."
|
||||||
if [[ $(adb shell "getevent -l -v4 | grep -m1 --line-buffered KEY_VOLUME") == *"KEY_VOLUMEDOWN"* ]]; then
|
# sleep 1
|
||||||
echo "skipped $package"
|
#done
|
||||||
else
|
echo "When you have the app installed, press volume UP to copy the data, press volume DOWN to skip"
|
||||||
printf "Killing %s\n" $package
|
if [[ $(adb shell "getevent -l -v4 | grep -m1 --line-buffered -E -e \"KEY_VOLUME(UP|DOWN)[ ]+DOWN\"") == *"KEY_VOLUMEDOWN"* ]]; then
|
||||||
adb shell su -c "am force-stop --user $USER_NUMBER $package"
|
adb shell input keyevent KEYCODE_HOME
|
||||||
printf "Clearing %s\n" $package
|
echo "skipped $package"
|
||||||
adb shell su -c "pm clear --user $USER_NUMBER $package || true"
|
else
|
||||||
|
adb shell input keyevent KEYCODE_HOME
|
||||||
userid=$(adb shell su -c "stat -c '%u' $remotepackages$package") || $(adb shell su -c "dumpsys package $package" | grep userId | cut -d "=" -f2- | tr -d [:alpha:] | head -n 1)
|
printf "Killing %s\n" $package
|
||||||
groupid=$(adb shell su -c "stat -c '%g' $remotepackages$package") || $(adb shell su -c "dumpsys package $package" | grep userId | cut -d "=" -f2- | tr -d [:alpha:] | head -n 1)
|
adb shell su -c "am force-stop --user $USER_NUMBER $package"
|
||||||
echo "App UserId=$userid"
|
printf "Clearing %s\n" $package
|
||||||
echo "App GroupId=$groupid"
|
adb shell su -c "pm clear --user $USER_NUMBER $package || true"
|
||||||
|
|
||||||
printf "Compressing %s\n" $package
|
echo "Local packages=$localpackages"
|
||||||
tar cfz .tmp_$package.tar.gz -C $localpackages $package/
|
echo "Remote packages=$remotepackages"
|
||||||
printf "Copying %s\n" $package
|
echo "Package=$package"
|
||||||
adb shell su -c "chown -R shell:shell /sdcard/.to_move"
|
userid=$(adb shell su -c "stat -c '%U' $remotepackages$package")
|
||||||
adb shell su -c "chmod -R 777 /sdcard/.to_move"
|
groupid=$(adb shell su -c "stat -c '%G' $remotepackages$package")
|
||||||
adb push .tmp_$package.tar.gz /sdcard/.to_move/.tmp_$package.tar.gz
|
cacheuserid="${userid}"
|
||||||
rm .tmp_$package.tar.gz
|
cachegroupid="${groupid}_cache"
|
||||||
printf "Extracting %s\n" $package
|
echo "App Data UserId=$userid"
|
||||||
adb shell "su -c \"cd /sdcard/.to_move/ && tar xfzom /sdcard/.to_move/.tmp_$package.tar.gz -C $remotepackages && rm .tmp_$package.tar.gz\""
|
echo "App Data GroupId=$groupid"
|
||||||
# printf "Restoring %s\n" $package
|
echo "App Cache UserId=$cacheuserid"
|
||||||
# adb shell su -c "mv /sdcard/.to_move/$package $remotepackages"
|
echo "App Cache GroupId=$cachegroupid"
|
||||||
printf "Correcting package\n"
|
|
||||||
adb shell su -c "chown -R \"$userid:$groupid\" \"$remotepackages$package\""
|
printf "Compressing %s\n" $package
|
||||||
adb shell su -c "restorecon -R \"$remotepackages$package\""
|
rm -r "$localpackages$package/cache" 2>/dev/null
|
||||||
printf "Package restored on device\n"
|
rm -r "$localpackages$package/code_cache" 2>/dev/null
|
||||||
sleep 1
|
tar cfz .tmp_$package.tar.gz -C $localpackages $package/
|
||||||
fi
|
printf "Copying %s\n" $package
|
||||||
|
adb shell su -c "chown -R shell:shell /sdcard/.to_move"
|
||||||
|
adb shell su -c "chmod -R 777 /sdcard/.to_move"
|
||||||
|
adb push .tmp_$package.tar.gz /sdcard/.to_move/.tmp_$package.tar.gz
|
||||||
|
rm .tmp_$package.tar.gz
|
||||||
|
printf "Extracting %s\n" $package
|
||||||
|
adb shell "su -c \"cd /sdcard/.to_move/ && tar xfzom /sdcard/.to_move/.tmp_$package.tar.gz -C $remotepackages && rm .tmp_$package.tar.gz\""
|
||||||
|
# printf "Restoring %s\n" $package
|
||||||
|
# adb shell su -c "mv /sdcard/.to_move/$package $remotepackages"
|
||||||
|
printf "Correcting package\n"
|
||||||
|
adb shell su -c "chown -R \"$userid:$groupid\" \"$remotepackages$package\""
|
||||||
|
adb shell su -c "chown -R \"$cacheuserid:$cachegroupid\" \"$remotepackages$package/cache\" 2>/dev/null"
|
||||||
|
adb shell su -c "chown -R \"$cacheuserid:$cachegroupid\" \"$remotepackages$package/code_cache\" 2>/dev/null"
|
||||||
|
adb shell su -c "restorecon -R \"$remotepackages$package\""
|
||||||
|
printf "Package restored on device\n"
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
} || {
|
} || {
|
||||||
echo "Error"
|
echo "Error"
|
||||||
}
|
}
|
||||||
|
40
ab_fix.sh
40
ab_fix.sh
@ -1,19 +1,45 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash -e
|
||||||
bashdir="$PWD"
|
bashdir="$PWD"
|
||||||
outdir="work"
|
outdir="work"
|
||||||
|
|
||||||
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
echo "You must supply the path of the .ab file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
abfile=$(readlink -f "$1")
|
abfile=$(readlink -f "$1")
|
||||||
|
|
||||||
|
if [ -z "$abfile" ]
|
||||||
|
then
|
||||||
|
echo "You must supply the path of the .ab file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p "$outdir"
|
mkdir -p "$outdir"
|
||||||
outdir=$(readlink -f "$outdir")
|
outdir=$(readlink -f "$outdir")
|
||||||
mkdir -p "$outdir/ab_backup"
|
mkdir -p "$outdir/ab_backup"
|
||||||
|
|
||||||
#dd if="$1" bs=512 skip=3 | tar -x -C "$outdir/ab_backup"
|
|
||||||
#java -jar abe.jar unpack "$1" "$outdir/ab_backup.tar"
|
|
||||||
cd "$outdir/ab_backup"
|
cd "$outdir/ab_backup"
|
||||||
"$bashdir/twrpabx" "$abfile"
|
"$bashdir/twrpabx" "$abfile" > /dev/null
|
||||||
|
cd $bashdir
|
||||||
|
|
||||||
#tar -xf "$outdir/ab_backup.tar" -C "$outdir/ab_backup"
|
#Extract
|
||||||
|
for i in $(find "$outdir/ab_backup" -name "data.*.win*" ! -name '*.sha2' ! -name '*.info' -type f); do
|
||||||
|
echo "Extracting file \"$i\""
|
||||||
|
( pv $i | tar -x --overwrite -C "$outdir" ) || true
|
||||||
|
done
|
||||||
|
|
||||||
echo "The backup has been extracted to: \"$outdir/ab_backup\""
|
#Delete extracted backup directory
|
||||||
echo "Please use that path for the next steps"
|
rm -rf "$outdir/ab_backup"
|
||||||
|
|
||||||
|
#Fix directory structure
|
||||||
|
if [ -d "$outdir/user/0" ]
|
||||||
|
then
|
||||||
|
rmdir "$outdir/user/0"
|
||||||
|
fi
|
||||||
|
mv "$outdir/data" "$outdir/data_tmp"
|
||||||
|
mkdir -p "$outdir/data"
|
||||||
|
mv "$outdir/data_tmp" "$outdir/data/data"
|
||||||
|
mv "$outdir/user" "$outdir/data/user"
|
||||||
|
mv "$outdir/app" "$outdir/data/app"
|
||||||
|
Loading…
Reference in New Issue
Block a user