Last active
August 29, 2015 14:11
-
-
Save int64ago/772b74d7a29bd47d2766 to your computer and use it in GitHub Desktop.
Centos rsync script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#wget works, too | |
#wget -r -p -k -np -c -nH --cut-dirs=1 -e robots=off -t5 -R iso,gif,css,js,ico,png,html,1 -P /srv/http/centos/ http://mirrors.aliyun.com/centos/6.5/ | |
RsyncBin="/usr/bin/rsync" | |
RsyncPerm='-avrt --delete --exclude=isos/ --exclude=i386/' | |
Version=6.5 #depends | |
Target='/srv/http/centos/$Version/' #depends | |
Repo='rsync://mirrors.kernel.org/centos/$Version/' | |
LogFile='/srv/http/centos/log' #depends | |
Date=`date +%Y-%m-%d` | |
function check { | |
if [ $? -eq 0 ];then | |
echo -e "Rsync is success!" >>$LogFile/$Date.log | |
else | |
echo -e "Rsync is fail!" >>$LogFile/$Date.log | |
fi | |
} | |
if [ ! -d "$LogFile" ];then | |
mkdir $LogFile | |
fi | |
echo 'Now start to rsync !' >>$LogFile/$Date.log | |
$RsyncBin $RsyncPerm $Repo $Target >>$LogFile/$Date.log | |
check |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment