I believe that many of the small partners will use the MySQL database, the following provides a script to share with gentlemen.
#!/bin/bash
script_dir=$ (dirname)
Backup_dir= "/data1/mysqlbackup"
backup_days=480
RM-RF ${backup_dir}/*
db_ip= '/sbin/ifconfig-a|grep inet|grep-v 127.0.0.1|grep-v Inet6|awk ' {print $} ' |tr-d ' addr: ' |head-1 '
Backup_type= ' Xtra_full '
For i in ' Ps-ef |grep port= |grep-v grep|cut-d "="-F 10 '
Do
db_port= $i
New_dir= "/data1/mysqlbackup/${db_port}"
If [-E "$NEW _dir"]
Then
echo "$NEW _dir was created"
Else
mkdir $NEW _dir
Fi
backup_today= "/data1/mysqlbackup/${db_port}/${db_ip}_ ' Date +%y%m%d%h%m '"
#find ${backup_dir}-mindepth 2-type d-cmin +${backup_days}-exec rm-rf {} \;
/usr/bin/mysql-h127.0.0.1-p${db_port}-uroot-e "GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT on * * to ' mysqlbackup ' @12 7.0.0.1 identified by ' abc123 ' "
/usr/bin/mysql-h127.0.0.1-p${db_port}-uroot-e "Grant replication Slave on * * to [email protected] ' 10.37.53.% ' IdentiFi Ed by ' Password '
/usr/bin/mysql-h127.0.0.1-p${db_port}-uroot-e "Grant all on * * to [e-mail protected] ' 10.37.53.% ' identified by ' password '
/usr/bin/mysql-h127.0.0.1-p${db_port}-uroot-e "Grant all on * * to [e-mail protected] ' 127.0.0.1 ' identified by ' password '
Innobackupex--user=mysqlbackup--password=abc123--host=127.0.0.1--port=${db_port}--defaults-file=/etc/mysql/my$ {db_port}.cnf--no-timestamp $BACKUP _today 2>/var/log/mysql${db_port}.log
This article from "Snail Taunt" blog, reproduced please contact the author!
Use Xtrabackup for database backup Sunday full + daily Incremental backup script