2
by Alan Pope
add backup and restore options |
1 |
#!/bin/bash
|
2 |
# Script to restore backup file manually to phone
|
|
3 |
# Requires one parameter, the backup file
|
|
4
by Alan Pope
update comments |
4 |
# No sanity checking done, presumes it's a backup taken with
|
5 |
# phablet-flash-wrapper.sh or backup-phablet.sh which means
|
|
6 |
# a tarball of /home/phablet from the device minus Pictures & Videos
|
|
2
by Alan Pope
add backup and restore options |
7 |
#
|
8 |
# Assumptions:-
|
|
9 |
# * Device already running some build of Ubuntu Touch and is connected via USB
|
|
10 |
# * Your backup file was made by phablet-flash-wrapper.sh and is specified as the only parameter
|
|
11 |
#
|
|
12 |
# (c) 2013 Canonical - Alan Pope alan.pope@canonical.com
|
|
13 |
||
14 |
UBUNTU_ROOT="/data/ubuntu" |
|
15 |
||
16 |
function adb_root { |
|
17 |
echo ":: Run adb root" |
|
18 |
adb root |
|
19 |
if [ $? -ne "0" ]; then |
|
20 |
echo ":: adb root failed" |
|
21 |
exit 1 |
|
22 |
fi
|
|
23 |
}
|
|
24 |
||
25 |
function pause { |
|
3
by Alan Pope
Fix scripts so restore actually restores to the right place. Doh |
26 |
echo ":: Wait $1" |
2
by Alan Pope
add backup and restore options |
27 |
sleep $1
|
28 |
}
|
|
29 |
||
30 |
die () { |
|
31 |
echo >&2 "$@" |
|
32 |
exit 1 |
|
33 |
}
|
|
34 |
||
35 |
[ "$#" -eq 1 ] || die "1 argument required, $# provided" |
|
36 |
||
37 |
adb_root |
|
38 |
||
39 |
pause 5
|
|
40 |
||
41 |
echo ":: Upload previously taken backup" |
|
42 |
adb push $1 $UBUNTU_ROOT/home/phablet.tgz |
|
43 |
||
44 |
if [ $? -ne "0" ]; then |
|
45 |
echo ":: Restore to device failed. Manual restore of $1 required" |
|
46 |
exit 1 |
|
47 |
fi
|
|
48 |
||
49 |
echo ":: Build script to restore" |
|
50 |
TMP_FILE=$(mktemp) |
|
51 |
||
52 |
cat > $TMP_FILE << 'EOF' |
|
53 |
#!/bin/bash
|
|
3
by Alan Pope
Fix scripts so restore actually restores to the right place. Doh |
54 |
cd /
|
2
by Alan Pope
add backup and restore options |
55 |
/bin/tar zxvf /home/phablet.tgz
|
56 |
EOF
|
|
57 |
||
58 |
echo ":: Run restore script" |
|
59 |
adb push $TMP_FILE $UBUNTU_ROOT/$TMP_FILE |
|
60 |
adb shell chmod 755 $UBUNTU_ROOT/$TMP_FILE |
|
61 |
adb shell chroot $UBUNTU_ROOT $UBUNTU_ROOT/$TMP_FILE |
|
62 |
||
63 |
pause 10
|
|
64 |
||
3
by Alan Pope
Fix scripts so restore actually restores to the right place. Doh |
65 |
echo ":: Delete backup file from device" |
66 |
adb shell rm -r $UBUNTU_ROOT/home/phablet.tgz
|
|
67 |
||
2
by Alan Pope
add backup and restore options |
68 |
echo ":: Reboot" |
69 |
adb reboot |
|
3
by Alan Pope
Fix scripts so restore actually restores to the right place. Doh |
70 |
|
71 |
echo ":: Done" |