Skip to content

Instantly share code, notes, and snippets.

@kehh
Created October 31, 2012 08:03
Show Gist options
  • Save kehh/3985742 to your computer and use it in GitHub Desktop.
Save kehh/3985742 to your computer and use it in GitHub Desktop.
Warsync - a tool for speeding up rsync of war files by unzipping them on the source and target and then rsyncing the diffs
#!/bin/bash
#Warsync - a tool for speeding up rsync of war files by unzipping them on the source and target and then rsyncing the diffs
echo "Usage: $0 source.war destinationserver"
CURRENTDIR=$PWD
WARFILE="$CURRENTDIR/$1"
REMOTEHOST=$2
CURRENTUSER=$USER
REMOTEHOME="/home/$CURRENTUSER"
WARFILENAME=`basename $1`
echo "source is $WARFILE target is $TARGET"
TEMPBASE="/tmp/warsync/"
TEMPDIR="$TEMPBASE/$WARFILENAME"
mkdir -p "$TEMPDIR"
cd "$TEMPDIR"
jar -xvf "$WARFILE"
ssh $REMOTEHOST "mkdir -p \"$TEMPDIR\";cd \"$TEMPDIR\";REMOTEDIR=\"$PWD\";pwd;jar -xvf \"$REMOTEHOME/$WARFILENAME\""rsync -avz --human-readable --progress --delete "$TEMPDIR" $REMOTEHOST:"$TEMPBASE"
ssh $REMOTEHOST "jar -cvf \"$WARFILENAME\" -C \"$TEMPDIR\" ./;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment