Description of related parameters in the mysql_back.sh script. The-c in the CT-c is the meaning of the command, that is, the-c is followed by the relevant commands, but these commands must
Description of related parameters in the mysql_back.sh script. The-c in the CT-c is the meaning of the command, that is, the-c is followed by the relevant commands, but these commands must
I. Environment Description (using rsync for mysql Incremental Backup)
192.168.0.2 is the backup server.
192.168.0.3 is the mysql database that needs to be backed up frequently.
Ii. Main Configuration
1. Backup Server Configuration
Useradd mysql_db-d/data/bak
Passwd rsync_server
# The password I configured is "123"
2. mysql Server Configuration
Vi mysql_back.sh
Export PATH =/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
Binlog_dir =/data/mysql/3306/logs
# Delete old binlog FileList
If [-f $ binlog_dir/mysql-bin.index]; then
Rm-f $ binlog_dir/mysql-bin.index
Fi
Passwd = "123"
Ls-l $ binlog_dir | grep mysql-bin | awk '{print $8}'>/data/mysql/3306/logs/binlog/mysql-bin.index
Rsync_exec (){
CT-c"
Set timeout 600;
Spawn rsync-rpogtv -- progress -- files-from = $ binlog_dir/binlog/mysql-bin.index $ binlog_dir mysql_db@192.168.0.2:/data/bak
CT {
\ "* Yes/no * \" {send \ "yes \ r \"; exp_continue}
\ "* Password * \" {send \ "$ passwd \ r \";}
}
CT eof ;"
}
Rsync_exec
3. Grant mysql_back.sh the right to execute and add a scheduled task.
// Explain the parameters in the mysql_back.sh script. The-c in CT-c is the meaning of the command, that is, the-c is followed by the relevant commands, but these commands must be caused. Set timeout sets the script timeout to 600 seconds, and spawn sets the start mode for running system commands. In rsync-rpogtv, r indicates recursively entering the directory, p indicates retaining the original permissions of the file, o indicates retaining the original owner of the file, and g indicates retaining the original group of the file ,, t indicates the time when the file was originally created or modified, v indicates that the lengthy information is added, and -- progress indicates that the rsync process is displayed. -- files-from indicates where to obtain the file for rsync. Objective CT is used here to avoid interaction. The Escape Character of \ "* yes/no * \" is followed by \ at both ends, and * is an arbitrary match, eof indicates the end of the program.