Only scripts are provided here, which is exactly the same as the previous "automatic backup of multiple Oracle instances under Aix 5.3,
If you want to add at or crontab, refer to automatic backup of MySQL database under CentOS5.4.
# MySQL User Information
USERNAME = database USERNAME (Information Hiding)
PASSWORD = Database PASSWORD (Information Hiding)
# Back file
FILE_PREFIX = MySQL _
# FTP Server Information
FTP_SERV = FTP Server (Information Hiding)
FTP_USER = FTP User Name (Information Hiding)
FTP_PASS = FTP password (Information Hiding)
FTP_DIR = FTP directory (Information Hiding)
# Back directory
BACKUP_DIR =/opt/databack/MySQL
# MySQL directory
MYSQL_DIR =/usr/local/mysql/bin
# Date Format
DATE = 'date + % Y % m % d'
# MySQL database
MYSQL1 = Name of the first MySQL database (Information Hiding)
MYSQL2 = Second MySQL Database Name (Information Hiding)
MYSQL3 = Name of the third MySQL database (Information Hiding)
# Go to the backup directory
Cd $ {BACKUP_DIR}
# The first instance of the backup
If [-f ${MYSQL1 }_$ {DATE}. SQL]; then
Echo MySQL Database ${MYSQL1 }$ {DATE} backup file already exists.
Else
$ {MYSQL_DIR}/mysqldump-u $ {USERNAME}-p $ {PASSWORD }$ {MYSQL1 }>$ {MYSQL1 }_$ {DATE}. SQL
Fi
# The second instance of the backup
If [-f ${MYSQL2 }_$ {DATE}. SQL]; then
Echo MySQL Database ${MYSQL2 }$ {DATE} backup file already exists.
Else
$ {MYSQL_DIR}/mysqldump-u $ {USERNAME}-p $ {PASSWORD }$ {MYSQL2 }>$ {MYSQL2 }_$ {DATE}. SQL
Fi
# The third instance of the backup
If [-f ${MYSQL3 }_$ {DATE}. SQL]; then
Echo MySQL Database ${MYSQL3 }$ {DATE} backup file already exists.
Else
$ {MYSQL_DIR}/mysqldump-u $ {USERNAME}-p $ {PASSWORD }$ {MYSQL3 }>$ {MYSQL3 }_$ {DATE}. SQL
Fi
# Compressed backup files
If [-f then implements file_prefix?##date=.tar.gz]; then
Echo 'date + % Y-% m-% d' backup File already exists.
Else
Tar-cf ${file_prefix1_1_1_date0000.tar.gz ${MYSQL1 }_$ {DATE}. SQL ${MYSQL2 }_$ {DATE}. SQL ${MYSQL3 }_$ {DATE}. SQL
Fi
# Delete backup files
Rm-rf ${MYSQL1 }_$ {DATE}. SQL ${MYSQL2 }_$ {DATE}. SQL ${MYSQL3 }_$ {DATE}. SQL
# Upload backup file
Ftp-n $ FTP_SERV <
User $ FTP_USER $ FTP_PASS
Passive
Binary
Cd $ FTP_DIR
Put into another file_prefix1_1_date0000.tar.gz then 1_file_prefix1_1_date0000.tar.gz
AUTO_FTP