使用Rsync备份数据



  经历了硬盘数据全没了的痛苦,痛定思痛,作好每日或更短时间的备份功作犹为重要,真正做到有备无患。
  1. '''准备:'''
    • 系统环境:Debian 4.0 (其它linux大同小异)
    • 需要权限:root
  2. '''安装:'''
    apt-get install rsync
  3. '''配置服务端:'''
    • '''建立配置文件:/etc/rsyncd.conf'''
      Debian4下rsyncd.conf不直接提供,那就新建一个
      vi /etc/rsyncd.conf
      输入
      uid = nobody
      gid = nogroup
      use chroot = no
      max connections = 4
      pid file = /var/run/rsync.pid
      lock file = /var/run/rsync.lock
      log file=/var/log/rsync.log
      
      #备份的模块名
      [website]
      path = /var/www
      comment = backup
      ignore errors
      read only = true
      list = false
      #备份用户名
      auth users = test
      #帐号密码文件
      secrets file = /etc/rsyncd.secrets
    • '''建立帐号文件/etc/rsyncd.secrets'''
      vi /etc/rsyncd.secrets
      输入
      #用户名:密码
      test:test
    • '''更改rsyncd.secrets的权限为只读'''
      chmod 0400 /etc/rsyncd.secrets
    • '''配置inetd'''
      vi /etc/inetd.conf
      添加
      rsync stream tcp nowait root /usr/bin/rsync rsync --daemon
    • '''重启inetd'''
      /etc/init.d/openbsd-inetd restart
  4. '''配置客户端'''
    • '''建立密码文件password'''
      echo 'test'>password
    • '''同步数据'''
      rsync -vzrtopg --progress --password-file=password test@服务器IP::website /var/www
      同步服务器IP的website到目录/var/www
      -v --verbose #输出调试信息
      -z --compress #压缩数据
      -r --recursive #递归目录,通俗讲就是包括所有子目录
      -t --times #保持时间
      -o --owner #保持所有者
      -p --permission #保持permission
      -g --group #保持组

发表评论

电子邮件地址不会被公开。 必填项已被标记为 *

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>