android backup

androidManifest.xml内allowBackup为true

则可以使用adb backup 备份, adb restore 恢复。

1
2
3
4
5
# 备份
adb backup -f egame.ab cn.egame.terminal.cloud5g

# 解压ab文件
( printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 egame.ab  ) |  tar xfvz -

adb backup 命令说明

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
adb backup [-f <file>] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all] 
           [-system|nosystem] [<packages...>]
-f <filename> specify filename default: creates backup.ab in the current directory

-apk|noapk enable/disable backup of .apks themself default: -noapk

-obb|noobb enable/disable backup of additional files default: -noobb

-shared|noshared backup device's shared storage / SD card contents default: -noshared

-all backup all installed apllications

-system|nosystem include system applications default: -system

<packages> a list of packages to be backed up (e.g. com.example.android.myapp) (not needed if -all is specified)

For a full device backup, including everything, use

1
adb backup -apk -obb -shared -all -system -f fullbackup.ab

Note: Doing a full backup can take a long time.

In order to restore a backup, use

1
adb restore backup.ab