定时执行rsync同步数据以及mysql备份
需求:把机器A中的附件、图片等,备份到备份机B中。将数据库进行备份
附件备份
在A中,启动rsync服务,编辑/etc/xinetd.d/rsync文件,将其中的disable=yes改为disable=no,并重启xinetd服务(需安装xinetd)
vi /etc/xinetd.d/rsync
/etc/init.d/xinetd restart
手动创建rsync的主配置文件: vi /etc/rsyncd.conf ,输入
uid=root
gid=root
max connections=
log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock
secrets file=/etc/rsyncd.passwd
hosts allow=10.46.xx.xx [databak]
comment= backup web
path=/xx/xx/mybak
read only = no
exclude=test
auth users=worker
(主机)创建密码文件
echo "work:abc12" > /etc/rsyncd.passwd
chmod /etc/rsyncd.passwd
(备份机)创建备份机密码
vi /etc/rsync_client.pwd,输入abc12
chmod /etc/rsync_client.pwd
备份机创建文件/home/bakdata.sh,赋予可执行权限 chmod +x bakdata.sh 。bakdata.sh的内容为
echo '--------------------------------------------------------------' >> /home/data.log
rsync -avz --progress --exclude "xxx" --password-file=/etc/rsync_client.pwd worker@10.46.1.62::data /home/bak/databak/ >> /home/data.log >& &
time=` date +%Y%m%d%H%M `
echo $time >> /home/data.log
数据库备份
备份机创建文件/home/bakmysql.sh 赋予可执行权限:chmod +x bakmysql.sh。bakmysql.sh的内容为
backupdir=/home/bak/databasebak
time=` date +%Y%m%d%H%M `
/home/server/mysql/bin/mysqldump -h10.xx.x.xx -ubackup -pbackup XXXX| gzip > $backupdir/database$time.sql.gz
find $backupdir -name database"*.sql.gz" -type f -mtime + -exec rm -rf {} \; > /dev/null >&
crontab定时任务
备份机设置定时任务,vi /etc/crontab ,加入:
* * * root /home/bakmysql.sh
* * * root /home/bakdata.sh
表示每天凌晨3点进行备份数据库,4点同步data数据
问题:
1、出现 “rsync: opendir "/." (in data) failed: Permission denied (13)”
解决: 不必重启Linux: setenforce 0;但开机后会恢复,则在/etc/sysconfig/selinux 中设置 SELINUX=disabled,将它关闭
定时执行rsync同步数据以及mysql备份的更多相关文章
- Windows 之间用rsync同步数据(cwRsyncServer配置)
rsync是一款优秀的数据同步软件,在跨服务器,跨机房,跨国备份服务器的首选工具,下面就来介绍下如何配置安装cwRsyncServer很大多数软件一样是B/C架构,cwRsyncServer是rsyn ...
- 7z常用命令行&7z检测压缩包完整性&7z压缩包错误不执行rsync同步
7Z简介&常用命令 7Z脚本使用说明 7Z检测压缩包完整性脚本 7Z压缩包错误不执行Rsync脚本 1.7Z简介&常用命令 ⑴简介: 7z,全称7-Zip, 是一款开源软件.是目前公认 ...
- Linux运维: Rsync同步数据(ubuntu16.04+windows10)
rsync同步数据 -环境:Linux (ubuntu16.04) + windows10 Linux: 安装 sudo apt-get install rsync rsync --version 查 ...
- 使用rsync 同步数据一些常用参数和示例
rsync rsync是linux系统下的数据镜像备份工具.支持远程同步,本地复制,或者与其他SSH.rsync主机同步. 包括本地推到远程,远程拉到本地两种同步方式,也可以实现本地不同路径下文件的同 ...
- 使用rsync同步数据(by quqi99)
作者:张华 发表于:2015-12-28版权声明:能够随意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 ( http://blog.csdn.net/quqi99 ) 急需使 ...
- 大数据批量导入,解决办法,实践从定时从 sqlserver 批量同步数据到 mySql
c#代码,批量导入数据代码 public class MySql_Target : ZFCommon.DataAccesser.Base.DABase { public MySql_Target() ...
- rsync同步数据---把左边的文件全部拷贝到右边
背景,配置好了ssh 使用rsa pulbic key的方式登陆远程服务器.//ssh-keygen -t rsa -b 2048 -f andy-rsync-key -P '' https://he ...
- rsync同步数据
1. rsync 命令格式rsync [OPTION]... SRC DESTrsync [OPTION]... SRC [USER@]HOST:DESTrsync [OPTION]... [USER ...
- 配置rsync 同步数据 rpm包安装rsync及配置
[root@Hammer home]# rpm -qa |grep rsync #检查系统是否安装了rsync软件包rsync-2.6.8-3.1[root@Hammer CentOS]# rpm - ...
随机推荐
- 常见的js算法面试题收集,es6实现
1.js 统计一个字符串出现频率最高的字母/数字 let str = 'asdfghjklaqwertyuiopiaia'; const strChar = str => { let strin ...
- 嵌入式Linux环境搭建备忘
嵌入式Linux开发平台搭建步骤: 1.安装宿主机Linux系统 如果选用最新的Linux发行版,应改主意其他软件是否能很好的兼容. 2.安装交叉编译器 交叉编译器的版本很多,一般到芯片厂家官网下载官 ...
- 洛谷P4231 三步必杀
题目描述: $N$ 个柱子排成一排,一开始每个柱子损伤度为0. 接下来勇仪会进行$M$ 次攻击,每次攻击可以用4个参数$l$ ,$r$ ,$s$ ,$e$ 来描述: 表示这次攻击作用范围为第$l$ 个 ...
- P3387 【模板】缩点
题目背景 缩点+DP 题目描述 给定一个n个点m条边有向图,每个点有一个权值,求一条路径,使路径经过的点权值之和最大.你只需要求出这个权值和. 允许多次经过一条边或者一个点,但是,重复经过的点,权值只 ...
- Winform VS2015打包
首先 ,我们要去官网http://learn.flexerasoftware.com/content/IS-EVAL-InstallShield-Limited-Edition-Visual-Stud ...
- codeforce GYM 100741 A Queries
A. Queries time limit per test:0.25 s memory limit per test:64 MB input:standard input output:standa ...
- 使用Vue CLI3开发多页面应用
一.安装vue-cli3 1.如果你已经全局安装了旧版本的 vue-cli(1.x 或 2.x),你需要先通过 npm uninstall vue-cli -g 或 yarn global remov ...
- Monkey log分析说明
运行命令: adb shell monkey -p com.crazyhornets.MyHokageAndroidZSY -v -v -v 20 -- throttle 1000 Log: :Mon ...
- 精通CSS高级Web标准解决方案(7、布局)
7.1 让设计居中 7.1.1 使用自动空白边让设计居中 <body> <div id="wrapper"> </div> </body& ...
- LeetCode with Python -> String
344. Reverse String Write a function that takes a string as input and returns the string reversed. E ...