Linux系统下的数据镜像备份工具——Rsync

浏览:
字体:
发布时间:2013-12-13 14:31:31
来源:

1、什么是rsync

rsync,remote synchronize顾名思意就知道它是一款实现远程同步功能的软件,它在同步文件的同时,可以保持原来文件的权限、时间、软硬链接等附加信息。 rsync是用“rsync 算法”提供了一个客户机和远程文件服务器的文件同步的快速方法,而且可以通过ssh方式来传输文件,这样其保密性也非常好,另外它还是免费的软件。

  rsync 包括如下的一些特性:

  能更新整个目录和树和文件系统;
  有选择性的保持符号链链、硬链接、文件属于、权限、设备以及时间等;
  对于安装来说,无任何特殊权限要求;
  对于多个文件来说,内部流水线减少文件等待的延时;
  能用rsh、ssh 或直接端口做为传输入端口;
  支持匿名rsync 同步文件,是理想的镜像工具;

2、rsync的安装,通用方式:yum install rsync

3、rsync服务器的配置文件

cat /etc/rsyncd/rsync.conf # Distributed under the terms of the GNU General Public License v2# Minimal configuration file for rsync daemon# See rsync(1) and rsyncd.conf(5) man pages for help# This line is required by the /etc/init.d/rsyncd scriptpid file = /var/run/rsync.pidport = 873#address = 192.168.1.171#uid = nobody#gid = nobodyuid = rootgid = rootuse chroot = yesread only = no#limit access to private LANshosts allow=*#hosts deny=*max connections = 5motd file = /etc/rsyncd/rsync.motd#This will give you a separate log file#log file = /var/log/rsync.log#This will log every file transferred - up to 85,000+ per user, per sync#transfer logging = yeslog format = %t %a %m %f %bsyslog facility = local3timeout = 300[data]path = /data1list=yesignore errorsauth users = rootsecrets file = /etc/rsyncd/rsync.secretscomment = rsync data1 dir#exclude = beinan/ samba/[garbagekrc]path = /data1/garbagekrclist=yesignore errorsauth users = rootsecrets file = /etc/rsyncd/rsync.secretscomment = rsync garbagekrc dir

用户密码文件:

cat /etc/rsyncd/rsync.secrets root:test123

其中用户名必须是服务器上已经存在的用户
4、启动rsync服务:/usr/bin/rsync --daemon --config=/etc/rsyncd/rsync.conf

5、备份文件到服务器:

rsync -az --password-file=rsync.password jsoncpp/* root@IP::data/mydata/

其中:password-file可以指定密码。

6、rsync也可以从服务器上拉文件到本地。结合crontab可以实现定时同步的功能。

7、更多用法请:man rsync。

>更多相关文章
24小时热门资讯
24小时回复排行
资讯 | QQ | 安全 | 编程 | 数据库 | 系统 | 网络 | 考试 | 站长 | 关于东联 | 安全雇佣 | 搞笑视频大全 | 微信学院 | 视频课程 |
关于我们 | 联系我们 | 广告服务 | 免责申明 | 作品发布 | 网站地图 | 官方微博 | 技术培训
Copyright © 2007 - 2024 Vm888.Com. All Rights Reserved
粤公网安备 44060402001498号 粤ICP备19097316号 请遵循相关法律法规
');})();