-
Notifications
You must be signed in to change notification settings - Fork 15
/
backup_apps.sh
executable file
·71 lines (51 loc) · 1.73 KB
/
backup_apps.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# License; Apache-2
# Originally from Raphael Moll
# Tested/Fixed for Android O by [email protected] 2017/12
# improved / completly reworked to play nice with Android 9 / 10 by [email protected] 2019/12
curr_dir="$(dirname "$0")"
. "$curr_dir/functions.sh"
set -e # fail early
SYSTEM_PATTERN=""
if [[ "$1" == "--system-apps" ]]; then shift; SYSTEM_PATTERN="/system/app\|/system/priv-app\|/system/product/app\|/system/product/priv-app\|/product/overlay" ; fi
checkPrerequisites
updateBusybox
lookForAdbDevice
checkRootType
checkForCleanData
pushBusybox
mkBackupDir
pushd $DIR
PACKAGES=$($A shell "cmd package list packages -f")
echo $PACKAGES
stopRuntime
echo "## Pull apps"
DATADIR=""
DATA_PATTERN="/data/app"
PATTERN=$DATA_PATTERN
if [[ "$SYSTEM_PATTERN" != "" ]]; then PATTERN="$SYSTEM_PATTERN}\|$DATA_PATTERN" ; fi
for APP in `echo $PACKAGES | tr " " "\n" | grep "${PATTERN}"`; do
echo $APP
appPath=`echo $APP | sed 's/package://' | rev | cut -d "=" -f2- | rev`
appDir=${appPath%/*}
dataDir=`echo $APP | sed 's/package://' | rev | cut -d "=" -f1 | rev`
echo $appPath
echo $appDir
echo $dataDir
if [[ "$AS" == "$AROOT" ]]; then
#
# --- version for adb insecure
#
$AS "/dev/busybox tar -cv -C $appDir . 2>/dev/null | gzip" | gzip -d | pv -trabi 1 | gzip -c9 > app_${dataDir}.tar.gz
$AS "/dev/busybox tar -cv -C /data/data/$dataDir . 2>/dev/null | gzip" | gzip -d | pv -trabi 1 | gzip -c9 > data_${dataDir}.tar.gz
else
#
# --- version for magisk rooted
#
$AS "'cd $appDir && /dev/busybox tar czf - ./' 2>/dev/null" | pv -trabi 1 > app_${dataDir}.tar.gz
$AS "'cd /data/data/$dataDir && /dev/busybox tar czf - ./' 2>/dev/null" | pv -trabi 1 > data_${dataDir}.tar.gz
fi
done
cleanup
startRuntime
popd