-
Notifications
You must be signed in to change notification settings - Fork 0
/
restore-user-data.sh
executable file
·51 lines (40 loc) · 1.15 KB
/
restore-user-data.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
#!/bin/bash
# Restore profile and user data given a dir containing such user data.
ADB=${ADB:-adb}
BACKUP_DIR=
echo_abort()
{
echo "Usage: ./restore-user-data.sh <dir>"
echo "Need to provide the backup dir containing the user data. Abort."
}
if [ ! -f "`which \"$ADB\"`" ]; then
echo "\'adb\' tool not found, cannot update. Abort."
exit -1
fi
if [ $# -gt 0 ]; then
BACKUP_DIR=$1
else
echo_abort
exit -1
fi
if [ ! -d $BACKUP_DIR ]; then
echo_abort
exit -1
fi
set -x
$ADB wait-for-device
$ADB remount 1>/dev/null 2>&1
$ADB shell rm -r /data/b2g/*
$ADB shell rm -r /data/local/indexedDB/*
$ADB shell rm -r /data/local/permissions.sqlite
$ADB shell rm -r /data/local/webapps/*
$ADB push $BACKUP_DIR/data/b2g /data/b2g 1>/dev/null 2>&1
$ADB push $BACKUP_DIR/data/local/indexedDB /data/local/indexedDB 1>/dev/null 2>&1
$ADB push $BACKUP_DIR/data/local/permissions.sqlite /data/local/ 1>/dev/null 2>&1
$ADB push $BACKUP_DIR/data/local/webapps /data/local/webapps 1>/dev/null 2>&1
if [ -d $BACKUP_DIR/sdcard/media ]; then
$ADB push $BACKUP_DIR/sdcard/media /sdcard/media 1>/dev/null 2>&1
fi
echo "Restarting B2G..."
$ADB shell stop b2g
$ADB shell start b2g