Chinaunix首页 | 论坛 | 博客
  • 博客访问: 74534
  • 博文数量: 66
  • 博客积分: 2546
  • 博客等级: 少校
  • 技术积分: 740
  • 用 户 组: 普通用户
  • 注册时间: 2009-10-27 10:35
文章存档

2011年(1)

2010年(1)

2009年(64)

我的朋友

分类:

2009-10-27 10:52:35

rsync 镜像备份

配置 rsync

  1. 系统环境

    [root@linuxas3 root]# uname -a
    
    Linux linuxas3.9812.net 2.4.21-4.ELsmp #1 SMP Fri Oct 3 17:52:56 EDT 2003 i686 i686 i386 GNU/Linux
    
    				
  2. 安装rsync

    在AS3 第二张CD上找到rsync-2.5.6-20.i386.rpm

    [root@linuxas3 root]# cd /mnt
    
    [root@linuxas3 mnt]# mount cdrom
    
    [root@linuxas3 mnt]# cd cdrom/RedHat/RPMS
    
    [root@linuxas3 RPMS]# rpm -ivh rsync-2.5.6-20.i386.rpm
    
    				
  3. 配置/etc/rsyncd.conf

    在rh9,as3系统上rsync安装后,并没有创建rsyncd.conf文档,笔者是自己创建的rsyncd.conf文档

    [root@linuxas3 root]# vi /etc/rsyncd.conf
    
    
    
    uid=nobody
    
    gid=nobody
    
    max connections=4
    
    use chroot=no
    
    log file=/var/log/rsyncd.log
    
    pid file=/var/run/rsyncd.pid
    
    lock file=/var/run/rsyncd.lock
    
    #auth users=root
    
    secrets file=/etc/rsyncd.pwd
    
    
    
    [postfix]
    
    path=/var/mail
    
    comment = backup mail
    
    ignore errors
    
    read only = yes
    
    list = no
    
    auth users = postfix
    
    
    
    [netkiller]
    
    path=/home/netkiller/web
    
    comment = backup 9812.net
    
    ignore errors
    
    read only = yes
    
    list = no
    
    auth users = netkiller
    
    
    
    [pgsqldb]
    
    path=/var/lib/pgsql
    
    comment = backup postgresql database
    
    ignore errors
    
    read only = yes
    
    list = no
    
    
    
    				

    选择说明

    uid = nobody 
    
    gid = nobody 
    
    use chroot = no         # 不使用chroot
    
    max connections = 4     # 最大连接数为4
    
    pid file = /var/run/rsyncd.pid 	  #进程ID文件
    
    lock file = /var/run/rsync.lock
    
    log file = /var/log/rsyncd.log    # 日志记录文件
    
    secrets file = /etc/rsyncd.pwd    # 认证文件名,主要保存用户密码,权限建议设为600,所有者root
    
    
    
    [module]            # 这里是认证的模块名,在client端需要指定
    
    path = /var/mail    # 需要做镜像的目录
    
    comment = backup xxxx # 注释
    
    ignore errors         # 可以忽略一些无关的IO错误
    
    read only = yes       # 只读
    
    list = no             # 不允许列文件
    
    auth users = postfix  # 认证的用户名,如果没有这行,则表明是匿名
    
    
    
    [other]
    
    path = /path/to...
    
    comment = xxxxx
    
    				
  4. 密码文件

    在server端生成一个密码文件/etc/rsyncd.pwd

    [root@linuxas3 root]# echo postfix:xxx >>/etc/rsyncd.pwd
    
    [root@linuxas3 root]# echo netkiller:xxx >>/etc/rsyncd.pwd
    
    [root@linuxas3 root]# chmod 600 /etc/rsyncd.pwd
    
    				
  5. 启动rsync daemon

    [root@linuxas3 root]# rsync --port 8033 --daemon 
    
    				
  6. 测试

    [root@linux docbook]#  rsync rsync://
    
    
    
    [root@linux tmp]# rsync rsync://netkiller@
    
    Password:
    
    
    
    [chen@linux temp]$  rsync -vzrtopg --progress --delete postfix@ /tmp
    
    Password:
    0 4 * * *   rsync -vlzrtogp --port 8033 --progress --delete   /opt/new5jia1/test_from_web68
    */5 * * * * rsync -vlzrtogp --port 8033 --progress --delete  /opt/new5jia1/new5jia1

    rsync rsync://认证用户@主机/模块

    rsync -vzrtopg --port 8033 --progress --delete 认证用户@主机::模块 /mirror目录

  7. 添加到启动文件

    echo "rsync --daemon" >> /etc/rc.d/rc.local 
    
    				
  8. 更复杂的使用,请参考

    rsync examples

阅读(318) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~