Skip to content

Instantly share code, notes, and snippets.

@int64ago
Last active August 29, 2015 14:11
Show Gist options
  • Save int64ago/772b74d7a29bd47d2766 to your computer and use it in GitHub Desktop.
Save int64ago/772b74d7a29bd47d2766 to your computer and use it in GitHub Desktop.
Centos rsync script
#!/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