時(shí)間:2015-06-28 00:00:00 來(lái)源:IT貓撲網(wǎng) 作者:網(wǎng)管聯(lián)盟 我要評(píng)論(0)
1.添加backupmysqleveryday.sh(vi /data/shell/backupmysqleveryday.sh)
#!/bin/sh
#this shell is user for backup mysql data everyday
#author:www.ieliwb.com
#path-config
base_mysql_path=/data/webserver/mysql/
mysql_dump_path=/data/mysqlbackup/
mnt_back_path=/mnt/web/mysqlbackup/
ftp_back_path=mysql_data_backup/
#mysql-config
mysql_user="root"
mysql_pass="*******"
#ftp-config
ftp_host="ip"
ftp_user="********"
ftp_pass="********"
backup_name=`date +%Y%m%d%H%M%S`
cd ${mysql_dump_path}
#mysqldump
${base_mysql_path}bin/mysqldump -u${mysql_user} -p${mysql_pass} -all-database > ${backup_name}.sql
#pack
tar zcf ${backup_name}.tar.gz ${backup_name}.sql
rm -f ${backup_name}.sql
#backup to mnt
cp ${backup_name}.tar.gz ${mnt_back_path}${backup_name}.tar.gz
#ftp to other host
ftp -n<
open ${ftp_host}
user ${ftp_user} ${ftp_pass}
bin
prompt off
cd ${ftp_back_path}
passive
put ${backup_name}.tar.gz
close
byea
!
2.添加定時(shí)計(jì)劃(vi /etc/crontab)
01 0 * * * root /data/shell/backupmysqleveryday.sh
每天0:01點(diǎn)執(zhí)行
關(guān)鍵詞標(biāo)簽:Linux,mysql定時(shí)自動(dòng)備
相關(guān)閱讀
熱門(mén)文章 Xbox Game Pass 10款MySQL數(shù)據(jù)庫(kù)客戶(hù)端圖形界面管理工具推薦 MySQL常用維護(hù)管理工具 MySQL數(shù)據(jù)庫(kù)啟動(dòng)失敗1067進(jìn)程意外終止的解決辦法總結(jié)
人氣排行 10款MySQL數(shù)據(jù)庫(kù)客戶(hù)端圖形界面管理工具推薦 MySQL數(shù)據(jù)庫(kù)啟動(dòng)失敗1067進(jìn)程意外終止的解決辦法總結(jié) Mysql 1045錯(cuò)誤解決辦法 MySQL服務(wù)器進(jìn)程CPU占用100%解決辦法 MySQL導(dǎo)出導(dǎo)入命令的用例 MySQL連接字符串的實(shí)際操作步驟匯總 MySQL無(wú)法啟動(dòng)、無(wú)法停止各種解決方法總結(jié) 三種常用的MySQL建表語(yǔ)句