Chinaunix首页 | 论坛 | 博客
  • 博客访问: 373230
  • 博文数量: 55
  • 博客积分: 3195
  • 博客等级: 中校
  • 技术积分: 712
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-01 18:45
文章分类

全部博文(55)

文章存档

2011年(14)

2010年(41)

分类: Mysql/postgreSQL

2010-08-02 11:19:15

#!/bin/sh
#
# File name:increment backup
#
# Backup mysql's increment data after daily backup.
#
# Usage:
# If you database name is t_girl and you want to backup from 2010-07-30 08:20:20.
# ./backup_increment t_girl 20100730082020
#
# You can simple put this file into crontab in order to work automatically.
#
# Put your own database name here.
DBNAME=$1

# You own specific datatime.
# For example,2008-09-16 08:13:26 should be replaced with 20080916081326 here.
#
USERDATETIME=$2

# You own backup directory.
BACKUPDIR=/home/shawnLee/backupdb

# You own backup user.
# He must have lock tables,select,super privileges.
# Also replication client privileges if your mysqld was set up as Master/Slave.
USERNAME=backup_user
PASSWD=123456

# Socket path.
SOCKET=/tmp/mysql_3306.sock

# All the binary logs.
LOG=/usr/local/mysql/data/mysql-bin.[0-9]*

# Backup file name.
TARNAME="$BACKUPDIR"/incrementbackup"$1""$2"

# Copy all the binary logs here to prevent failed backup.
cp -rf `echo $LOG` /home/shawnLee/logs

# Change the current directory.
# If you have aready put mysql into your environment variable named path,you can comment this line and use simple mysql instead of /bin/mysql.
#
cd /usr/local/mysql

bin/mysql -u$USERNAME -p"$PASSWD" -S$SOCKET -e "purge master logs before ${USERDATETIME}"
bin/mysqlbinlog -u$USERNAME -p"$PASSWD" -S$SOCKET -d$DBNAME `echo $LOG` --start-datetime="$USERDATETIME"> "$TARNAME"

阅读(849) | 评论(0) | 转发(0) |
0

上一篇:MySQL安装详解

下一篇:Chrome各个版本集合

给主人留下些什么吧!~~