Alibabacloud.com offers a wide variety of articles about mysql backup shell script, easily find your mysql backup shell script information here online.
Tags: User name linux database MySQL Local
Create a backup directory/bak/mysqlbak
Writing Run scripts
vim/home/bakmysql.shCode:#!/bin/bashBackupdir=/bak/mysqlbakTime= "$ (date +"%y%m%d%h%m ")"/usr/local/mysql/bin/mysqldump-u xxxx (user name)-pxxxx (password) XXXX (database name) | gzip > $backupdir/xxxx (Custom ID) $time. sql.gzFind $backupdir-n
Linux automatically backs up the MySQL database and uploads the shell script to the FTP server.#! /Bin/bash# Mysql autobackup shell### -------------- Set the mysql login parametersDbuser = rootDbpasswd =Dbserver = localhostDbname
backup, and the third is the executing program of the backup#Juge the exec user authorIf [$UID-ne 0];thenecho "must to is use the root for exec shell."ExitFi#以上的语句主要是用于判断是否用root用户执行#Juge If backup existsif [!-D $BAK _dir];thenMkdir-p $BAK _dirEcho-e "\033[32mthe $BAK _dir creat successfully!\033[0m"Elseecho "This $BAK
On the Internet to read a few scripts based on the Internet slightly modified under, slightly more prepared point, is missing something#!/bin/bash# Large Backup number backup_max_files=20# database backup directory working_dir=$ (dirname "$") Export working_dir=$ (cd-p "$WORKING _dir"/ >/dev/null; PWD) #数据库IP地址, account number, password db_host= "XXXXXXX" db_user= "XXXXXX" db_password= "XXXXXXX" #需要备份的数据库Da
Tags: mysql#!/bin/bash
#Time: 2016-11-8
#owner: Fujinzhou
#scriptname: mysqlback.sh
#要备份的数据库名, multiple databases separated by spaces
db= (Zabbix reboot10)
#备份目录
backuppath= "/data/backup/"
if [!-D "$BACKUPPATH"]; then
mkdir-p "$Backuppath "
fi
#循环DB for
DB in ${db[*]}
do
cd $BACKUPPATH
#备份并打包数据库生成的sql文件
/bin/nice-n 19/usr/bin/mysqldump--defaults-file=/root/.my.cnf $db > ${db}_$ (Date +%y%m%d). SQL Tar zPc
#!/bin/bash#file:mysql_backup.sh#date2016-1-9backdes=/data/msyql_back/' date+%Y-%m-%d ' //Create the directory that holds the backup data backname= ' date+%y-%m-%d ' //backup name, You can omit the database=test//backed up database mysqluser=root// The user name at the time of backup #mysqlsec=//the password at the time of b
after the execution of the script, our website and database are backed up into the/www/backup and then uploaded to the FTP space using the script lftp.
Second, edit the backup script
The code is as follows
Copy Code
Compile a shell script in CentOS to monitor MySQL master-slave replication,
Objective: To regularly monitor whether the MySQL master-slave database is synchronized. If not, record the fault time and execute commands to restore the master-slave database to the synchronization state.
1. Create a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.