免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2736 | 回复: 0
打印 上一主题 下一主题

yum自动跟公网站点同步! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-02-20 22:19 |只看该作者 |倒序浏览
在salogs搜索了yum rsync的脚本,拿来一试感觉不错。就是共享出来,以下我根据实际情况修改并增加了其他同步的文件。存储使用了mfs。
#!/bin/bash
Date=`date +%Y%m%d`
LogFile="/var/log/rsync_yum/$Date.log"
CentOSTrunkVer="5"
CentOSCurrentVer="5.5"
CentOSCurrentv="4.8"
ReceiveMail="nathanzhou@mysite.com"
Cpanpath="/data0/yum/mirrors.sohu.com/CPAN/"
RsyncBin="/usr/local/bin/rsync"
RsyncPerm="-avrt --delete --exclude=debug/  --exclude=isos/"
CentOS_Trunk_Ver_Path="/data0/yum/mirrors.sohu.com/centos/$CentOSTrunkVer"
CentOS_Current_Ver_Path="/data0/yum/mirrors.sohu.com/centos/$CentOSCurrentVer"
CentOS_Current_v_Path="/data0/yum/mirrors.sohu.com/centos/$CentOSCurrentv"
YumSiteList="rsync://mirrors.sohu.com/centos"
Cpansitelist="cpan.wenzk.com::CPAN"
#============ epel ==============
epelSite="rsync://mirrors.sohu.com/fedora-epel/"
epelLocalPath="/data0/yum/mirrors.sohu.com/epel"

# rpmforge
rpmforgeSite="rsync://mirrors.sohu.com/dag/redhat/"
rpmforgeLocalPath="/data0/yum/mirrors.dzwww.com/rpmforce"
# CPAN mirrors
cpansite="rsync://mirrors.sohu.com/nginx/"
cpanlocalpath="/data0/yum/mirrors.sohu.com/CPAN/"

echo "---- $Date `date +%T` Begin ----" >>$LogFile
#CPAN
$RsyncBin $RsyncPerm $Cpansitelist $cpanlocalpath >> $LogFile
# centos 5
$RsyncBin $RsyncPerm $YumSiteList/$CentOSTrunkVer/ \
$CentOS_Trunk_Ver_Path >> $LogFile

# centos 5.5
$RsyncBin $RsyncPerm $YumSiteList/$CentOSCurrentVer/ \
$CentOS_Current_Ver_Path  >> $LogFile
# centos 4.8
$RsyncBin $RsyncPerm $YumSiteList/$CentOSCurrentv/ \
$CentOS_Current_v_Path  >> $LogFile
# epel
$RsyncBin $RsyncPerm  --exclude=4/ --exclude=4AS/ --exclude=4AS/ \
--exclude=4WS/  --exclude=beta/ --exclude=testing/ $epelSite $epelLocalPath >> $LogFile

# rpmforge
$RsyncBin $RsyncPerm $rpmforgeSite $rpmforgeLocalPath >> $LogFile

# CPAN
#$RsyncBin $RsyncPerm $cpansite $cpanlocalpath >> $LogFile

echo  "---- $Date `date +%T` End ----" >> $LogFile


将其置于cron中,一天同步四次。
  1. * */6 * * * /usr/local/bin/yummirror 2>&1 >/dev/null &
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP