亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Linux自動(dòng)備份MySQL數(shù)據(jù)庫(kù)腳本代碼

 更新時(shí)間:2013年11月07日 11:10:50   作者:  
下面這段Linux的Shell腳本用于每日自動(dòng)備份MySQL數(shù)據(jù)庫(kù),可通過(guò)Linux的crontab每天定時(shí)執(zhí)行
在腳本中可設(shè)置需要備份的數(shù)據(jù)庫(kù)表清單,并且會(huì)將備份文件通過(guò)gzip壓縮。需要注意的是,這段腳本僅適用數(shù)據(jù)一致性要求不高的環(huán)境。
復(fù)制代碼 代碼如下:

#!/bin/bash
mysql_pwd="password"
mysql_dump="/usr/local/mysql/bin/mysqldump"
cur_year=$(date +"%Y")
cur_month=$(date +"%m")
cur_day=$(date +"%d")
dump_path="/usr/backup/mysql/$cur_year-$cur_month/$cur_day"
arr_tables=(
"table_1"
"table_2"
"table_3"
)
if [ ! -d "$dump_path" ]; then
mkdir -p "$dump_path"
fi
for cur_table in ${arr_tables[*]}; do
$mysql_dump -uroot -p$mysql_pwd --opt mydb $cur_table | gzip > $dump_path/$cur_table.sql.gz
done

相關(guān)文章

最新評(píng)論