#!/bin/bash
BAKUP_DIR="/home/zhangxiaotong/work/push_bak"
function bakup()
{
#得到bakup目录
bakdir=$1
curdir=`pwd`
if [ -z $bakdir ]; then
bakdir=`basename $curdir`
fi
bakdir="$BAKUP_DIR/$bakdir"
if [ ! -e $bakdir ]; then
echo "mkdir $bakdir as bak directory!"
mkdir $bakdir
fi
#进行bakup
paths=(`svn st | sort -k 1 | awk '{if($1 != "?") print $0}' | grep src | awk '{print $NF}'`)
num=${#paths[@]}
for ((i=0; i < $num; i++))
do
path=${paths[i]}
file=`basename $path`
bakpath=`dirname $path`
if [ ! -e $bakdir ]; then
echo "bakup directory is not exist!"
break
BAKUP_DIR="/home/zhangxiaotong/work/push_bak"
function bakup()
{
#得到bakup目录
bakdir=$1
curdir=`pwd`
if [ -z $bakdir ]; then
bakdir=`basename $curdir`
fi
bakdir="$BAKUP_DIR/$bakdir"
if [ ! -e $bakdir ]; then
echo "mkdir $bakdir as bak directory!"
mkdir $bakdir
fi
#进行bakup
paths=(`svn st | sort -k 1 | awk '{if($1 != "?") print $0}' | grep src | awk '{print $NF}'`)
num=${#paths[@]}
for ((i=0; i < $num; i++))
do
path=${paths[i]}
file=`basename $path`
bakpath=`dirname $path`
if [ ! -e $bakdir ]; then
echo "bakup directory is not exist!"
break
fi
if [ $bakpath != "." ]; then
if [[ ! -e ${bakdir}/${bakpath} ]]; then
cd $bakdir
mkdir -p $bakpath
cd $curdir
fi
fi
cp -rf $path ${bakdir}/${path}
echo "cp -rf $path ${bakdir}/${path}"
done
}
bakup