源码备份脚本

\#!/bin/bash

set -x
path_current=`pwd`
path_script=$(cd "$(dirname "$0")"; pwd)
echo "path_script="$path_script
path_waypal=$path_script/waypal.from.101.200.132/waypal
if [ -d $path_waypal ];then
   echo "find the directory:$path_waypal"
else
   mkdir -p $path_waypal
fi

path_targz=$path_script/waypal.from.101.200.162/waypal_backup_`date +%Y-%m-%d`.tar.gz
path_targztmp=$path_targz'.tmp'
rsync --exclude  ".git" -ave ssh ljb@101.200.132:/home/ljb/waypal  $path_waypal && tar -cvzf $path_targztmp $path_waypal && mv $path_targztmp $path_targz && rm $path_script/waypal.from.101.200.132/waypal_backup_`date -d '-5 days' +%Y-%m-%d`.tar.gz