您好,登錄后才能下訂單哦!
在/server/scripts/目錄中創(chuàng)建備份腳本mysql_backup.sh
#!/bin/bash # --------------------------- # Filename: mysql_backup.sh # Revision: 1.4 # Date: 2016/05/09 # Author: ywliyq # Email: ywliyq@163.com # Website: http://ywliyq.blog.51cto.com/ # Description: mysql backup every day delete before 7days. # Notes: This plugin uses the "" command # ---------------------------- # Copyright: 2016 (c) ywliyq # License: GPL # ---------------------------- # Backup file is saved in the directory, if it does not exist Create basepath='/data/mysql/backup/' if [ ! -d "$basepath" ]; then mkdir -p "$basepath" fi # mysql bakcup to /data/mysql/backup/ /application/mysql/bin/mysqldump -uroot -p'12345677' --events --ignore-table=mysql.events -F -B -A|gzip >$basepath/mysqlbak_$(date +%F).sql.gz # Delete the backup data to 7 days before find $basepath -mtime +7 -name "*.sql.gz" -exec rm -rf {} \;
===============================================================
創(chuàng)建定時(shí)任務(wù),每天凌晨2點(diǎn)執(zhí)行此腳本
# crontab -e
###### mysql backup at 2016/05/09 by ywliyq ######
0 2 * * * /bin/sh /server/scripts/mysql_backup.sh >/dev/null
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。