[转载]Back up all of your mysql databases nightly
原文地址:http://www.linuxbrigade.com/back-up-all-of-your-mysql-databases-nightly/
Put the following into something like /usr/local/bin/mysql_backup.sh and since it has MySQL’s root password in it, make sure that you chmod 700 to it so no one else can read it.
#!/bin/bash DB_BACKUP="/backups/mysql_backup/`date +%Y-%m-%d`"
DB_USER="root"
DB_PASSWD="secretttt"
HN=`hostname | awk -F. '{print $1}'` # Create the backup directory
mkdir -p $DB_BACKUP # Remove backups older than days
find /backups/mysql_backup/ -maxdepth -type d -mtime + -exec rm -rf {} \; # Backup each database on the system
for db in $(mysql --user=$DB_USER --password=$DB_PASSWD -e 'show databases' -s --skip-column-names|grep -viE '(staging|performance_schema|information_schema)');
do mysqldump --user=$DB_USER --password=$DB_PASSWD --events --opt --single-transaction $db | gzip > "$DB_BACKUP/mysqldump-$HN-$db-$(date +%Y-%m-%d).gz";
done
By the way, we’re skipping tables ‘performance_schema’ and ‘information_schema’…
Then just call it from cron by creating a root cron entry:
* * * /usr/local/bin/mysql_backup.sh
(完)
[转载]Back up all of your mysql databases nightly的更多相关文章
- MySQL: How to support full Unicode in MySQL databases
How to support full Unicode in MySQL databases Published 30th July 2012 · tagged with MySQL, securit ...
- 转载的在DOS下操作mysql
转载原文地址:http://www.server110.com/mysql/201309/1070.html 一.连接MYSQL. 格式: mysql -h主机地址 -u用户名 -p用户密码 1.例1 ...
- 【转载】在使用JDBC连接MySql时报错:You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support
在使用JDBC连接MySql时报错:You must configure either the server or JDBC driver (via the serverTimezone config ...
- [转载]centos7 快速安装 mariadb(mysql)
http://blog.csdn.net/default7/article/details/41973887 从最新版本的linux系统开始,默认的是 Mariadb而不是mysql! yum ins ...
- 【转载】LVS+MYCAT+读写分离+MYSQL主备同步部署手册(邢锋)
LVS+MYCAT+读写分离+MYSQL主备同步部署手册 1 配置MYSQL主备同步…. 2 1.1 测试环境… 2 1.2 配置主数据库… 2 1.2.1 ...
- (转载)Linux下安装配置MySQL+Apache+PHP+WordPress的详细笔记
Linux下安装配置MySQL+Apache+PHP+WordPress的详细笔记 Linux下配LMAP环境,花了我好几天的时间.之前没有配置过,网上的安装资料比较混乱,加上我用的版本问题,安装过程 ...
- [转载自阿里丁奇]各版本MySQL并行复制的实现及优缺点
MySQL并行复制已经是老生常谈,笔者从2010年开始就着手处理线上这个问题,刚开始两三年也乐此不疲分享,现在再提这个话题本来是难免"炒冷饭"嫌疑. 最近触发再谈这个话题,是 ...
- 【转载】通过sql server 连接mysql
http://www.cnblogs.com/goole/p/5291286.html 1.在SQL SERVER服务器上安装MYSQL ODBC驱动; 驱动下载地址:http://dev.mysql ...
- (转载)Unity3D连接本地或局域网MySQL数据库
准备工作: 1.打开 Unity3D 安装目录,到这个路径下 Editor > Data > Mono > lib > mono > 2.0 拷贝出下图的五个动态链接库, ...
随机推荐
- Java中MyEclipse快捷键整理
************************************ MyEclipse 快捷键1(CTRL) ************************************ Ctrl ...
- Linux定时任务Crontab详解
原文地址:http://edu.codepub.com/2011/0104/28518.php 今天做了个数据库的备份脚本,顺便系统得学习一下Linux下定时执行脚本的设置.Linux下的定 ...
- 基于Angular2的前端框架CoreUI开发使用说明
开源地址:https://github.com/mrholek/CoreUI-Free-Bootstrap-Admin-Template/tree/master/Angular2_CLI_Starte ...
- cloudera learning7:Hadoop资源管理
Linux Control Groups(cgroups):在操作系统级别进行资源分配,可通过Cloudera Static Service Pools配置. YARN调度器配置:对运行在YARN上的 ...
- 在Hyper-V中安装和配置Ubuntu网络
http://www.abcde.cn/knowledgebase/845/Hyper-VUbuntu.html (文中的nameserver要改成自己路由器的IP:我的是192.168.2.1.) ...
- 常用git命令纪录
git branch xxx 新建分支xxx git branch -a 查看所有分支(包括远程) git remote add origin http://xxx.git 在本地添加一个远程仓库, ...
- 经历alidns在国外的严重延时
有个域名,是在国外1und1申请的,但dns的解析,国外的空间的功能弱爆了. 之前是放在dnspod,后来又试过dnspod的海外, 最后放回alidns,之前一直都很好的. 这2天国内没问题,在德国 ...
- SpringMVC整合Hibernate实现增删改查之按条件查询
首先我贴出我项目的结构,只完成了条件查询的相关代码,增删改没有写. 1.新建一个动态Web工程,导入相应jar包,编写web.xml配置文件 <context-param> <par ...
- SQL用先进先出存储过程求出库数量
create table t( id ,), name ),--商品名称 j int, --入库数量 c int, --出库数量 jdate datetime --入库时间 ) ,,'2007-12- ...
- UVALive 7147 World Cup(数学+贪心)(2014 Asia Shanghai Regional Contest)
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=6 ...