1、 首先截取系统中的用户信息添加到表中。
cat /etc/passwd | awl '{print $1 "," $3 "," $4 "," $6}' > /tmp/e.sql
mysql -e show databases;
use test
create table back (user char(20),UID int, GIN int, DIR char(30));
load data infile '/tmp/e.sql into table back fields terminted by ",";
2、安装备份工具
yum install gcc gcc-c++ glib2-devel mysql-devel zlib-devel pcre-devel -y
rpm -ivh cmake-2.6.4-7.el5.i386.rpm tar fvxz mydumper-0.2.3.tar.gz cmake . make make install安装完成后创建备份目录
mkdir -pv /tmp/sqlbak
echo 'log-bin=binlog' >> /etc/my.cnf
echo 'log-bin-index=binlog.index' >> /etc/my.cnf echo 'sync_binlog=0' >> /etc/my.cnf service mysqld restart3 、制定计划任务
echo '* 2 * * 0 mydumper -B test -u rooth localhost -o /tmp/sqlbak -r 1000' >> /etc/crontab
echo '* 1 * * 1-6 mysqlbinlog binlog.0.00001'>> /etc/crontab