forked from phorward/viur-tools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
copydb.sh
executable file
·96 lines (74 loc) · 1.28 KB
/
copydb.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh
TMPDIR=/tmp
DBDIR=$HOME/DB
cd $DBDIR
if [ $? -ne 0 ]
then
echo "No DB directory in $HOME found."
exit 1
fi
choice=0
dirlist=`ls -t *.tar.gz | sed -e 's/\.tar\.gz$//g'`
while true
do
cnt=0
sel=""
echo "---"
for i in $dirlist
do
if [ $cnt -eq $choice ]
then
printf "> %2d %s\n" $cnt $i
sel=$i
else
printf " %2d %s\n" $cnt $i
fi
cnt=`expr $cnt + 1`
done
if [ $cnt -eq 0 ]
then
echo "No Databases available."
exit 1
fi
printf "Select [%s]>" $sel
read nchoice
if [ -z "$nchoice" ]
then
b=`basename $sel`
targetdir="$TMPDIR/appengine.$b.`whoami`"
if [ -d "$targetdir" ]
then
echo -n "$targetdir already exists, deleting..."
rm -rf "$targetdir"
if [ $? -ne 0 ]
then
echo "Error deleting directory"
exit 1
fi
echo "Done"
fi
echo -n "Unpacking '$sel' into '$targetdir'..."
mkdir $targetdir
if [ $? -ne 0 ]
then
echo "Error creating directory"
exit 1
fi
chmod 700 $targetdir
#rsync -a --delete $sel/ /tmp/appengine.$b.`whoami`/
tar xfz $sel.tar.gz --strip-components=1 -C $targetdir
if [ $? -ne 0 ]
then
echo "Error unpacking"
exit 1
fi
echo "Done"
break
fi
if [ $nchoice -ge $cnt -o $nchoice -lt 0 ]
then
echo "Invalid selection!"
continue
fi
choice=$nchoice
done