-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzip-datadir.sh
executable file
·65 lines (44 loc) · 1.08 KB
/
zip-datadir.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
#! /bin/bash
set -e
set -x
if [ "x$*" = "x" ]
then
echo "parameter for datadir is not set"
echo "use zip-fetched.sh or zip-imported.sh"
exit 1
fi
datadir="$1"
cd $(dirname $0)
base=$(pwd)
source ./wowauc.conf
dataname="$(basename $datadir)"
abs_zipping=$(readlink -n -e $dir_zipping)
abs_zipped=$(readlink -n -e $dir_zipped)
zipdir="$abs_zipping/$dataname"
if [ -d $zipdir ]
then
echo "directory $zipdir already exists. is there another backup process?"
exit 1
fi
mkdir -p $abs_zipping
mv $datadir $zipdir
mkdir -p $datadir
cd $zipdir
ts_first=`ls -1 | sort -n | head -n1 | sed -e 's|\([0-9]\{8\}_[0-9]\{6\}\).*$|\1|'`
ts_last=`ls -1 | sort -n | tail -n1 | sed -e 's|\([0-9]\{8\}_[0-9]\{6\}\).*$|\1|'`
if [ "x$ts_first" = "x" ]; then
echo "empty ts_first !"
exit 1
fi
if [ "x$ts_last" = "x" ]; then
echo "empty ts_last !"
exit 1
fi
zname=$dataname-${ts_first}-${ts_last}.tar.xz
echo ""
echo "zip $name to $zname"
find . -print | grep -v '^\.$' | sort | \
tar --xz -cnvf $abs_zipping/$zname.tmp -T -
mv $abs_zipping/$zname.tmp $abs_zipped/$zname
cd $base
rm -rf "$zipdir"