一、服务器端、备份客户端安装 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. TCP/UDP的网络底层实现

    1.1Socket的使用背景 当我们在使用微信.玩游戏.收发邮件,以及用web浏览器上网时,底层的实现是TCP/UDP的协议,封装socket实现网络通信功能. 了解了网络通信的底层实现原理,在出现s ...

  2. 在 Docker 中运行 SpringBoot 应用

    创建 SpringBoot 项目 用 Idea 创建一个 SpringBoot 项目,编写一个接口: package cloud.dockerdemo import org.springframewo ...

  3. C#桌面程序启动时传入参数

    using System;using System.Collections.Generic;using System.Linq;using System.Windows.Forms; namespac ...

  4. .NET中的泛型概述

    什么是泛型? 泛型是具有占位符(类型参数)的类.结构.接口和方法,这些占位符是类.结构.接口和方法所存储或使用的一个或多个类型的占位符.泛型集合类可以将类型形参用作其存储的对象类型的占位符:类型形参呈 ...

  5. Django(一)初始

    一:Web开发中的基本术语 1.两种架构 (1)cs架构 Client/Server:客户端-服务端架构 优点:CS能充分发挥客户端PC的处理能力,很多工作可以在客户端处理后在提交给服务器,用户体验好 ...

  6. 人脸跟踪开源项目HyperFT代码算法解析及改进

    一.简介 人脸识别已经成为计算机视觉领域中最热门的应用之一,其中,人脸信息处理的第一个环节便是人脸检测和人脸跟踪.人脸检测是指在输入的图像中确定所有人脸的位置.大小和姿势的过程.人脸跟踪是指在图像序列 ...

  7. 物联网学习笔记三:物联网网关协议比较:MQTT 和 Modbus

    物联网学习笔记三:物联网网关协议比较:MQTT 和 Modbus 物联网 (IoT) 不只是新技术,还是与旧技术的集成,其关键在于通信.可用的通信方法各不相同,但是,各种不同的协议在将海量“事物”连接 ...

  8. uniapp之w-picker使用采坑

    1. uniapp之w-picker使用采坑 1.1. 前言 由于我是先在index页面集合了这个组件,发现该文件内容实在太多了,不好维护,所以打算把内容一个个抽成组件,在抽w-picker时,遇到了 ...

  9. Java 之 异常的处理

    Java 异常处理的五个关键字:try.catch.finally.throws.throw 一.捕获异常 try...catch 如果异常出现的话,会立刻终止程序,所以我们得处理异常. try... ...

  10. React-router5.x 路由的使用及配置

    在 React router 中通常使用的组件有三种: 路由组件(作为根组件): BrowserRouter(history模式) 和 HashRouter(hash模式) 路径匹配组件: Route ...