Use mysqldump of the mysql database to implement automatic backup of mysqldump
Mysql database mysqldump can be used for Database Backup. if crontabs is configured in linux, automatic backup can be implemented!
#! /Bin/bash
# Configure the original database connection information, that is, you are using the machine that needs to be backed up.
SOURCE_USER =-uroot
# If the ip address is on the local machine, that is, SOURCE_HOST =-h127.0.0.1
SOURCE_HOST =-h10.10.10.12
SOURCE_PASS =-padministrator
# Configure the connection information of the backup database, that is, the database machine used for backup
BAK_USER =-uroot
# Ip address of the database machine used for backup
BAK_HOST =-h10.10.10.22
BAK_PASS =-padministrator
# Export the database table content from the original database and generate an SQL file. STATION indicates the database name, and username and files indicates the table name.
/Var/mysql/bin/mysqldump -- add-drop-table -- opt $ SOURCE_USER $ SOURCE_HOST $ SOURCE_PASS STATION username>/tmp/username. SQL
/Var/mysql/bin/mysqldump -- add-drop-table -- opt $ SOURCE_USER $ SOURCE_HOST $ SOURCE_PASS STATION files>/tmp/files. SQL
# Import data to the backup database
/Var/mysql/bin/mysql $ BAK_USER $ BAK_HOST $ BAK_PASS STATION
/Var/mysql/bin/mysql $ BAK_USER $ BAK_HOST $ BAK_PASS STATION