一、服务器端、备份客户端安装 rsync 服务。

1、环境:

CentOS
主 IP:172.16.3.18
备 IP:172.16.3.19

2、安装 rsync 软件

#yum install rsync -y

3、iptables 开放 873 端口

#iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport  -j ACCEPT
#service iptables save
#service iptables restart

二、server 服务端操作
IP: 172.16.3.18
1、需要备份的文件

web、service1、service2

2、rsync 配置文件示例(默认没有、需要收到创建)

# cat /etc/rsyncd.conf 
uid = root
gid = root
use chroot = no
max connections =
timeout =
strict modes = yes
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
hosts allow = 172.16.3.18
# hosts deny = *
list = false
auth users = user
# rsync同步使用的账户
secrets file = /etc/user.passwd
# 需要手动创建密码文件 [web]
path = /home/web/
ignore errors
read only = no
write only = no [service1]
path = /opt/service1/
ignore errors
read only = no
write only = no [service2]
path = /opt/service2/
ignore errors
read only = no
write only = no

3、密码文件 /etc/user.passwd , (默认没有、需要收到创建)

# cat /etc/user.passwd
user:passwd
# 格式 用户:密码

4、启动默认守护进行:

#/usr/bin/rsync --daemon

5、检测进程

#ps -ef |grep rsync
#netstat -ano |grep

二、客户端 bak 设置操作
备 IP:172.16.3.19

1.创建密码文件 /etc/user.passwd , 只写密码就可以。 (默认没有、需要收到创建)

#cat /etc/user.passwd
passwd

# 格式
密码

2、服务的目录 同步 到备机 bak 上:

1、备机 bak 同步服务端上的web
/usr/bin/rsync -vzrtopg --delete --progress --password-file=/etc/user.passwd salt@172.16.3.18::service /opt/bak/web/

2、bak 同步 service1 服务
/usr/bin/rsync -vzrtopg --delete --progress --password-file=/etc/user.passwd salt@172.16.3.18::service1 /opt/bak/service1/

3、bak 同步 service2 服务
/usr/bin/rsync -vzrtopg --delete --progress --password-file=/etc/user.passwd salt@172.16.3.18::service2 /opt/bak/service2/
# 注意 被同步的bak目录 在后,如果在前就是备的同步主的了。

# 备机本地的 bak 同步到服务端;
/usr/bin/rsync -vzrtopg --delete --progress --password-file=/etc/user.passwd /opt/bak/web salt@172.16.3.18::web

三、 设置定时备份

1、同步脚本

# vi /opt/script/rsync-user.sh
/usr/bin/rsync -vzrtopg --delete --progress --password-file=/etc/user.passwd salt@172.16.3.18::service /opt/bak/web

2、定时同步(每周日零点进行同步)

crontab -e
0 0 * * 0 /opt/script/rsync-user.sh > /opt/script/rsync-user.txt

rsync同步备份的更多相关文章

  1. wordpress利用rsync同步备份

    我搭建的wordpress服务器现在使用的系统是opensuse, 服务器上面已做脚本和计划任务将wordpress使用的数据库与web目录每天压缩备份放到 /data/backup目录下 opera ...

  2. rsync同步备份搭建

    Rsync 是 Unix/Linux 下的一款应用软 在平常的运维中进常要对一些数据进行备份,以防止意外的服务器故障导致不可避免的后果,tar,cp只能适应一些小范围backup,对于几T甚至几P的数 ...

  3. rsync数据同步备份

    一.rsync简介 (1)rsync是什么? rsync是一款开源的.快速的.多功能的.可实现全量及增量的本地或远程数据同步备份的优秀工具. (2)rsync作用比较 远程拷贝:有点类似ssh的scp ...

  4. 如何通过rsync+sersync 实现同步备份

    3.rsync+sersync更快更节约资源实现web数据同步4.unison+inotify实现web数据双向同步 一:为什么要实现同步备份 服务器上有些重要文件或数据时,可以把他们多备份一份到其他 ...

  5. Rsync + sersync 实时同步备份

    一      Rsync + Sersync  实时同步介绍 1.Rsync 服务搭建介绍 云机上搭建Rsync server,在本地搭建Rsync Clinet. 2. Sersync 服务搭建介绍 ...

  6. 搭建中小规模集群之rsync数据同步备份

    NFS重要问题 1.有关NFS客户端普通用户写NFS的问题. 1)为什么要普通用户写NFS. 2)exports加all_squash. Rsync介绍 什么是Rsync? Rsync是一款开源的.快 ...

  7. CentOS 6.5 rsync+inotify实现数据实时同步备份

    CentOS 6.5 rsync+inotify实现数据实时同步备份 rsync    remote sync 远程同步,同步是把数据从缓冲区同步到磁盘上去的.数据在内存缓存区完成之后还没有写入到磁盘 ...

  8. Linux下简单粗暴使用rsync实现文件同步备份【转】

    这篇来说说如何安全的备份,还有一点不同的是上一篇是备份服务器拉取数据,这里要讲的是主服务器如何推送数据实现备份. 一.备份服务器配置rsync文件 vim /etc/rsyncd.conf #工作中指 ...

  9. 同步备份工具之 rsync

    1.常用同步方法 SCP. NFS. SFTP. http. samba. rsync. drbd(基于文件系统同步,效率高) 2.rsync 介绍 rsync,英文全称是 remote synchr ...

随机推荐

  1. SQL系列(十)—— 联结(join)

    在数据库设计中,基本上都是根实体ER关系和范式设计多张表.这样更能设计出更合理.紧凑的表结构,提高有效数据存储,数据的管理维护更简便,也提高了库表的伸缩性. 但是事物总是平衡的,在很多场景中单张表的数 ...

  2. C# 创建json传输格式的http请求

    public static string PostRequestTest(string content, string url, string contentType = "applicat ...

  3. APS.NET MVC + EF (07)---表单和HTML辅助方法

    在ASP.NET MVC中,可以借助HtmlHelper 对象来输出页面内容,提高开发效率.下面,我们将介绍一些常用的辅助方法. 7.1 HTML辅助方法 BeginForm 该辅助方法主要用来产生& ...

  4. spring boot整合spring Data JPA和freemarker

    1.spring Data JPA简介 是一个替代hibernate的一个作用于数据库的框架. 2.整合 1.导入依赖 <dependency> <groupId>org.sp ...

  5. arm树莓派Raspbian 下安装selenium+chrome

    arm树莓派Raspbian 下安装selenium+chrome 安装selenium pip3 install selenium 安装chromedriver sudo apt-get insta ...

  6. Js中级复习

    JS中级复习—— 1,this   就是js的关键字 用途:指向某一个对象 如何判断this指向: 函数(方法)内—— 一种以函数的方式调用(不带.)this指向window 一种以方法的形式调用(函 ...

  7. npm err! Unexpected end of JSON input while parsing near解决办法

    npm install时出现npm err! Unexpected end of JSON input while parsing near错误 输入  npm cache clean --fore ...

  8. 关于DataX

    1. 关于DataX 1.1. 前言 为什么写这篇文章,因为初出茅庐的时候,曾经遇到的一个面试官就是DataX的作者之一,而当时我还偏偏因为业务需求做了个数据库的同步工具,我当时不知道他做过这么专业的 ...

  9. Delphi - ShellExecute资料

    Windows官方资料: https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea#p ...

  10. ML-对偶(Duality)问题 KKT 条件

    Primal => Dual 现实中我们遇到的原优化问题, 写为标准型的话是这样的. \(min _w f(w) \\ s.t. \\ g_i(w) <=0 \\ h_i(w) = 0\) ...