-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrsync.sh
executable file
·53 lines (40 loc) · 1.02 KB
/
rsync.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
if [ $# != 1 ] ; then
echo
echo "usage: $0 <version>"
echo
exit
fi
version=$1
remoteUserName=cassandra
remoteBasePath="/data/cassqueue"
remoteAppPath="${remoteBasePath}/app"
remoteConfPath="${remoteBasePath}/conf"
localBaseDir=`dirname $0`
tarFile=cassandra-queue-${version}.tar.gz
hostName="host.btoddb.com"
explodeDir=target/explode.tmp
#
# set working directory
#
pushd ${localBaseDir}
#
# make required remote dirs
#
ssh ${remoteUserName}@${hostName} "mkdir -p ${remoteAppPath} ${remoteConfPath} 2> /dev/null"
#
# explode tar and use rsync to properly add/remove files
#
rm -rf ${explodeDir} 2> /dev/null
mkdir -p ${explodeDir}
tar xvfz target/${tarFile} -C ${explodeDir}
#
# sync the files
#
# libs
rsync --progress --recursive --dirs --delete --rsh=ssh ${explodeDir}/app ${remoteUserName}@${hostName}:${remoteBasePath}/
rsync --progress --recursive --cvs-exclude --dirs --delete --rsh=ssh ${explodeDir}/conf ${remoteUserName}@${hostName}:${remoteBasePath}/
#
# return to starting state
#
rm -r ${explodeDir}
popd