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
# Script to restore backup file manually to phone
# Requires one parameter, the backup file
# No sanity checking done, presumes it's a backup taken with
# phablet-flash-wrapper.sh or backup-phablet.sh which means
# a tarball of /home/phablet from the device minus Pictures & Videos
#
# Assumptions:-
# * Device already running some build of Ubuntu Touch and is connected via USB
# * Your backup file was made by phablet-flash-wrapper.sh and is specified as the only parameter
#
# (c) 2013 Canonical - Alan Pope alan.pope@canonical.com
UBUNTU_ROOT="/data/ubuntu"
function adb_root {
echo ":: Run adb root"
adb root
if [ $? -ne "0" ]; then
echo ":: adb root failed"
exit 1
fi
}
function pause {
echo ":: Wait $1"
sleep $1
}
die () {
echo >&2 "$@"
exit 1
}
[ "$#" -eq 1 ] || die "1 argument required, $# provided"
adb_root
pause 5
echo ":: Upload previously taken backup"
adb push $1 $UBUNTU_ROOT/home/phablet.tgz
if [ $? -ne "0" ]; then
echo ":: Restore to device failed. Manual restore of $1 required"
exit 1
fi
echo ":: Build script to restore"
TMP_FILE=$(mktemp)
cat > $TMP_FILE << 'EOF'
#!/bin/bash
cd /
/bin/tar zxvf /home/phablet.tgz
EOF
echo ":: Run restore script"
adb push $TMP_FILE $UBUNTU_ROOT/$TMP_FILE
adb shell chmod 755 $UBUNTU_ROOT/$TMP_FILE
adb shell chroot $UBUNTU_ROOT $UBUNTU_ROOT/$TMP_FILE
pause 10
echo ":: Delete backup file from device"
adb shell rm -r $UBUNTU_ROOT/home/phablet.tgz
echo ":: Reboot"
adb reboot
echo ":: Done"
|