A Mysql backup script
#
Echo "/PATH/mysqlbak.sh -f: You can backup all databases"
Echo "/PATH/mysqlbak.sh -i: Just backup the exter change from the last backup"
Echo "/PATH/mysqlbak.sh -d: Backup from the last full-backup to the current time"
}
MySQL -e "FLUSH TABLES WITH READ LOCK;"
/dev/null">MySQL -e "SHOW MASTER STATUS >/dev/null;"
Startfile=/tmp/startposition
Exterfile=/tmp/exterposition
Case $OPTS in
F)
/mybackup/db.$DATE">Mysqldump --all-databases >/mybackup/db.$DATE
$startfile`">STARTPOSITION=`mysql -e "SHOW MASTER STATUS; tail -1 awk'{print" | | $2}'>$startfile`
$exterfile`">ESTARTPOSITION=`mysql -e "SHOW MASTER STATUS; tail -1 awk'{print" | | $2}'>$exterfile`
CD /mybackup
/dev/null">Tar -cjf /root/bakmysql/db.$DATE.tar.gz2 db.$DATE >/dev/null
;;
D)
MySQL -e "FLUSH TABLES WITH READ LOCK;"
/dev/null">MySQL -e "SHOW MASTER STATUS >/dev/null;"
FILE=`mysql -e "SHOW MASTER STATUS; tail -1 awk'{print" | | $1}'`
STARTPOSITION=`cat $startfile`
ENDPOSITION=`mysql -e "SHOW MASTER STATUS; tail -1 awk'{print" | | $2}'`
/mybackup/incre.$DATE">Mysqlbinlog --start-position $STARTPOSITION
--stop-position $ENDPOSITION /mydata/data/$FILE
>/mybackup/incre.$DATE
CD /mybackup
/dev/null">Tar -cjf /root/bakmysql/incre.$DATE.tar.gz2 incre.$DATE >/dev/null
;;
I)
MySQL -e "FLUSH TABLES WITH READ LOCK;"
/dev/null">MySQL -e "SHOW MASTER STATUS >/dev/null;"
FILE=`mysql -e "SHOW MASTER STATUS; tail -1 awk'{print" | | $1}'`
>$exterfile`">EENDPOSITION=`mysql -e "SHOW MASTER STATUS tail -1;" | | awk'{print $2}'>>$exterfile`
ESTARTPOSITION=`tail -n 2 $exterfile head -n 1` |
Exendposition=`tail -n 1 $exterfile`
/mybackup/exter.$DATE">Mysqlbinlog --start-position $ESTARTPOSITION
--stop-position $Exendposition /mydata/data/$FILE
>/mybackup/exter.$DATE
CD /mybackup
/dev/null">Tar -cjf /root/bakmysql/exter.$DATE.tar.gz2 exter.$DATE >/dev/null
;;
H)
HELPTXT
;;
ESAC
Done
A Mysql backup script的更多相关文章
- Python mysql backup
http://www.linuxidc.com/Linux/2015-02/113057.htm ------------- #!/usr/bin/python#################### ...
- MySQL Backup mysqldump备份流程学习
我们都知道MySQL逻辑备份工具mysqldump可以保证备份数据的一致性,但是它是怎么保持一致性的? 本文不讨论mysqldump具体的选项和用法,一直对mysqldump的工作机制梳理的不太清楚, ...
- MySQL Backup myloader
之前的博文当中提到备份工具mydumper的使用,而软件包中还包含了与之对应的恢复工具myloader,本文就总结下myloader的用法.关于mydumper的安装与使用可以参考之前的博文:MySQ ...
- MySQL Backup in Facebook
本文将较为详细的介绍Facebook对于MySQL数据库的备份策略和方法 文章欢迎转载,但转载时请保留本段文字,并置于文章的顶部 作者:卢钧轶(cenalulu) 本文原文地址:http://cena ...
- keepalived+mysql backup服务器可ping通过vip但telnet vip+3306失败问题
环境: OS:CentOS 7_X64 数据库:mysql-5.7 MASTER:192.168.119.23 BACKUP:192.168.119.24 VIP:192.168.119.138 ke ...
- MySQL Backup mysqldump 常用选项与主要用法
The mysqldump client utility performs logical backups, producing a set of SQL statements that can be ...
- MySQL Backup mydumper
生产环境中有一实例每天使用mysqldump备份时长达到了2个小时53分钟,接近3个小时,还不算上备份文件归档的时间,这个时间对于逻辑备份来说有点久.为了提高逻辑备份效率,打算替换为使用mydumpe ...
- 1950261 - SAP HANA Database Backup Policy Recommendations and Regular Backup Script
=====Symptom For SAP Business One, version for SAP HANA users, SAP HANA provides a range of database ...
- shell for mysql backup in linux
今天上班只有一台linux系统,就学着在linux上写了个脚本,没啥技术含量 省得每天敲代码备份 没有设置自动备份时间,这里可以参照 http://www.th7.cn/db/mysql/201305 ...
随机推荐
- MagicNotes:自我管理中的破窗效应
MagicNotes,思绪随风飞扬,偶尔在这里停留. 在<程序员修炼之道——从小工到专家>这本书里,有这么一段描述: 在市区,有些建筑漂亮而整洁,而另一些却是破败不堪的“废弃船只”.为什么 ...
- ios-消息弹框之UIAlertView, UIActionSheet以及UIAlertController小结
首先storyboard中创建对应按钮并拖线,来演示不同的效果 首先点击了actionSheet按钮效果如图 实现弹框需要遵守设置代理,遵守协议. 效果就是从底部向上弹起来的框框. 通过对按钮的点击输 ...
- thttpd增加gzip压缩响应报文体功能,以减少传输数据量
thttpd thttpd是一个非常小巧的轻量级web server,它非常非常简单,仅仅提供了HTTP/1.1和简单的CGI支持,在其官方网站上有一个与其他web server(如Apache, Z ...
- Java基础之一组有用的类——Observable和Observer对象(Horrific)
控制台程序. Obserable类提供了一个有趣的机制,可以把类对象中发生的改变通知给许多其他类对象. 对于可以观察的对象来说,类定义中需要使用java.util.Observable类.只需要简单地 ...
- Lintcode: Binary Tree Serialization (Serialization and Deserialization Of Binary Tree)
Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a ...
- 创建Java类并实例化的基本过程
package com.sanguosha.java; /* * 面向对象实现的过程 * 1.创建类并设计类的成员(成员变量即属性and成员方法即方法) * 2.通过类来创建类的对象,也称类的实例化 ...
- Codeforce Round #216 Div2
e,还是写一下这次的codeforce吧...庆祝这个月的开始,看自己有能,b到什么样! cf的第二题,脑抽的交了错两次后过了pretest然后system的挂了..脑子里还有自己要挂的感觉,果然回头 ...
- Java基础(38):Calendar类的应用(优于Date类)
Calendar 类的应用 Date 类最主要的作用就是获得当前时间,同时这个类里面也具有设置时间以及一些其他的功能,但是由于本身设计的问题,这些方法却遭到众多批评,不建议使用,更推荐使用 Calen ...
- URAL 1018 Binary Apple Tree(树DP)
Let's imagine how apple tree looks in binary computer world. You're right, it looks just like a bina ...
- JSon_零基础_008_将JSon格式的"数组"字符串转换为List集合
将JSon格式的"数组"字符串转换为List集合. 应用此技术从一个json对象字符串格式中得到一个java对应的对象. JSONObject是一个“name.values”集合, ...