rsync从linux到linux的文件同步备份

一、环境

需要备份文件的服务器(服务器端):192.168.1.201 (RHEL 5)

接收备份文件的服务器(客户端):192.168.1.202 (CENTOS 5)

二、安装配置

1.服务器端的配置

A、采用系统默认安装的rsync 编辑/etc/rsyncd.conf文件,如果没有则新建一个。

vi /etc/rsyncd.conf

#[globale]

strict modes= yes  #check passwd file

port= 873 #default port

logfile= /var/log/rsyncd.log

pidfile= /var/run/rsyncd.pid

max connections= 4

#[modules]

[testlink]   #备份模块

uid= root

gid= root

path= /usr/local/apache/htdocs/testlink/upload_area  #要备份的目录

read only= no

host allow= *

auth users= wwyhy

secrets file= /etc/rsyncd.scrt

[bugfree]         #备份模块

uid= root

gid= root

path= /usr/local/apache/htdocs/bugfree/BugFile         #要备份的目录

read only= no

host allow= *

auth users= wwyhy

secrets file= /etc/rsyncd.scrt

[redmine]   #备份模块

uid= root

gid= root

path= /usr/local/redmine-0.8.1/files       #要备份的目录

read only= no

host allow= *

auth users= wwyhy

secrets file= /etc/rsyncd.scrt

B、 添加一个密码文件

vi /etc/rsyncd.scrt

内容如下:

wwyhy:123456  #(自己设置)

C、改变权限为600

chmod 600 /etc/rsyncd.scrt

D、启动服务(如开有防火墙请允许873端口通过)

rsync --daemon --config=/etc/rsyncd.conf &

2.配置客户端

客户端我则自己编译安装的rsync-3.0.3.tar.gz的

A、安装:

tar -zxvf rsync-3.0.3.tar.gz

cd rsync-3.0.3

./configure

make

make install

B、添加密码文件

vi /etc/rsyncd.scrt (没有就新建)

内容如下:

wwyhy:123456 (文件与客户端文件内容一样)

C、改文件权限为600

chmod 600 /etc/rsyncd.scrt

三、开始备份

可以在客户端通过man rsync指令来查看备份指令

我们用脚本来自动执行备份

列:rsync -avz --password-file=密码文件路径 [email protected]需要备份的主机IP::备份里的模块名称

接收备份文件的路径

在/root建一个脚本文件

vi backup

添加内容如下:

#1.192.168.1.201上的testlink附件备份指令

rsync -avz --password-file=/etc/rsyncd.scrt [email protected]::testlink

/home/wangwei/testlink/upload_area

#2.192.168.1.201上的bugfree附件备份指令

rsync -avz --password-file=/etc/rsyncd.scrt [email protected]::bugfree

/home/wangwei/bugfree/BugFile

#3.192.168.1.201上的redmine附件备份指令

rsync -avz --password-file=/etc/rsyncd.scrt [email protected]::redmine

/home/wangwei/redmine-0.8.1/files

chmod u+x backup

每晚2.30自动执行

vi /etc/crontab

30 2 * * * root /root/backup

时间: 2024-08-27 14:01:57

rsync从linux到linux的文件同步备份的相关文章

rsync加inotify实现无间隔文件同步

一: 工具简介  rsync 它是一款实现远程同步功能的软件,它在同步文件的同时,可以保持原来文件的权限.时间.软硬链接等附加信息. rsync是用 "rsync 算法"来使本地和远程两个主机之间的文件达到同步,这个算法只传送文件的变化部分,而不是每次都整体传送,因此速度相当快. inotyify    inotify是Linux核心子系统之一,做为文件系统的附加功能,它可监控文件系统并将异动通知应用程序.于Linux核心2.6.13发布时,被正式纳入Linux内核.所以内核版本在2.

SCP实现Linux到Windows的文件数据备份

我们上一篇介绍了使用Curl+windows FTP实现linux到windows的数据备份,今天我们介绍一下使用SCP服务将Linux的文件到Windows的文件备份:我们都知道SCP使用的是SSL协议进行数据传输的,所以我们如果使用SCP服务进行数据传输的话需要安装openssh-clients(linux上),而windows上我们需要单独下载openssh for windows 工具.具体见下: 我们首先在linux上安装openssh-clients yum install –y o

Rsync文件同步备份

主服务器端: 同过命令下载最新rsync:links http://rsync.samba.org/ 本例以rsync-3.1.2版本为例 如果没有安装links,需要安装:yum install links 下载安装 tar xvf rsync-3.1.2.tar.gz cd rsync-3.1.2 ./configure --prefix=/usr/local/rsync make make install 建立文件夹: mkdir -p /etc/rsyncd/ mkdir -p /hom

CentOS7通过rsync+crontab实现两台服务器文件同步

centos7系统中已经默认安装rsync 1:主服务器配置 (1)修改rsyncd.conf 配置文件 [[email protected] app]# vi /etc/rsyncd.conf motd file = /etc/rsyncd.motdlog file = /var/log/rsyncd.logpid file = /var/run/rsyncd.pidlock file = /var/run/rsyncd.lockport = 873address = 192.168.0.24

centos7安装rsync及两台机器进行文件同步

安装及配置 yum -y install rsync #启动rsync服务 systemctl start rsyncd.service systemctl enable rsyncd.service #检查是否已经成功启动 netstat -lnp|grep 873 服务端配置 # /etc/rsyncd: configuration file for rsync daemon mode # See rsyncd.conf man page for more options. # config

linux配置文件、日志文件全备份

1.分别设置两台主机满足试验要求                 服务器                       IP                   主机名          nginx-web服务器             192.168.10.150                    web1              备份服务器             192.168.10.20                    backup 要求:每天晚上 00 点整在 Web 服务器

rsync+inotify-tools+ssh实现mysql-bin日志文件实时备份

1.环境:两台Centos计算机直连,其服务器A的IP地址为192.168.1.124,服务器B的IP地址为192.168.1.121. 2.需求软件安装(ssh系统默认已经安装): 服务器A: yum install rsync inotify-tools 服务器B: yum install rsync 3.建立用户(备份执行用户) 建立用户:useradd rsync 设置密码:略 注意:两台服务器都需要建立用户(此处两天服务器建立了相同的用户,也可建立不同的用户) 4.建立ssh-key实

简单的文件同步备份程序,仅支持单向同步_程序及源代码

1. 程序 http://files.cnblogs.com/files/fjwuyongzhi/FileSync.zip 2. 源代码 http://files.cnblogs.com/files/fjwuyongzhi/FileSync2016080405.rar 此备份程序,主要用于办公云化,将文件备份到本地电脑等(如下图), 也可以用于其它单向的文件备份的情况. 免责声明:本程序不提供任何承诺,请自行确认.

Linux文件同步工具-rsync

Linux文件同步工具-rsync 安装包 yum install -y rsync rsync常用选项 -a:归档模式,表示递归方式传输文件,并保持所有属性:通-rlptgoD:-r:同步目录时要加上,类似cp时加R:-v:同步时显示一些信息,让我们知道同步国创:-l:保留软链接:-L:同步软链接时会把源文件给同步:-p:保持文件权限属性:-o:保持文件的属主:-g:保持文件的属组:-D:保持设备文件信息:-t:保持文件的时间属性:--delte:删除DEST中SRC没有的文件:--exclu