Chinaunix首页 | 论坛 | 博客
  • 博客访问: 384037
  • 博文数量: 87
  • 博客积分: 2810
  • 博客等级: 少校
  • 技术积分: 825
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-28 22:34
文章分类

全部博文(87)

文章存档

2010年(25)

2009年(43)

2008年(19)

分类: 系统运维

2008-12-08 21:36:12

#!/bin/bash
# Remote Server Rsync backup Replication Shell Script
# -------------------------------------------------------------------------
# Copyright (c) 2005 nixCraft project <
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit  for more information.
# -------------------------------------------------------------------------
# Local dir location
LOCALBAKPOINT=/disk3
LOCALBAKDIR=/remote/home/httpd/
# remote ssh server
# user
SSHUER=brootbeer 
 
# server IP / host
SSHSERVER=10.10.11.12 
 
#remote dir to backup
SSHBACKUPROOT=/disk2.backup/hot/ 
 
rsync --exclude '*access.log*' --exclude '*error.log*' -avz -e 'ssh ' ${SSHUER}@${SSHSERVER}:${SSHBACKUPROOT} ${LOCALBAKPOINT}${LOCALBAKDIR}
 
# log if backup failed or not to /var/log/messages file
[ $? -eq 0 ] && logger 'RSYNC BACKUP : Done' || logger 'RSYNC BACKUP : FAILED!'
 
# Replicate backup to /disk1 and /disk2
# You can also use format user@host:/path
# refer to rsync man page
SRC=${LOCALBAKPOINT}${LOCALBAKDIR}
DST="/disk1/remote /disk2/remote"
for d in $DST
do
 [ ! -d $d ] && mkdir -p $d || :
 rsync -avr $SRC $d
done
阅读(1227) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~