#!/bin/bash
echo "create database and table space" mysql -e 'create table hvps.beps(name char(80),uid int,gid int,home_dir char(100));' cat /etc/passwd | awk -F: '{print $1,$3,$4,$6}' > /tmp/133.txt mysql -e 'load data infile '/tmp/133.txt' into table beps fields terminated by ';';' 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 restartecho "crontab"
echo '30 23 * * 0 mysql mysqldump -u root hvps > /tmp/dbbak.sql' >> /etc/crontab echo '50 23 * * 0 mysql mysql -e 'flush logs'' >> /etc/crontab echo '30 23 * * 1-6 mysql mysql -e 'flush logs'' >> /etc/crontab echo '30 23 * * 1 root run-parts /etc/cron.sql' >> /etc/crontabecho "thirthday backup"
touch /etc/cron.sql chmod 777 /etc/cron.sql echo 'mysql -e 'drop table beps'' > /etc/cron.sql echo 'rm -fr /var/lib/mysql/hvps' > /etc/cron.sql echo 'mysql -e 'create database hvps'' >> /etc/cron.sql echo 'mysql -u root hvps < /tmp/dbbak.sql' >> /etc/cron.sql echo 'mysqlbinlog --start-position 4 --stop-position 98 binlog.000002 | mysql hvps' >> /etc/cron.sql echo 'mysqlbinlog --start-position 4 --stop-position 98 binlog.000003 | mysql hvps' >> /etc/cron.sql echo 'mysqlbinlog --start-position 4 --stop-position 98 binlog.000004 | mysql hvps' >> /etc/cron.sql