亚洲韩日午夜视频,欧美日韩在线精品一区二区三区,韩国超清无码一区二区三区,亚洲国产成人影院播放,久草新在线,在线看片AV色

您好,歡迎來到思海網(wǎng)絡(luò),我們將竭誠為您提供優(yōu)質(zhì)的服務(wù)! 誠征網(wǎng)絡(luò)推廣 | 網(wǎng)站備案 | 幫助中心 | 軟件下載 | 購買流程 | 付款方式 | 聯(lián)系我們 [ 會員登錄/注冊 ]
促銷推廣
客服中心
業(yè)務(wù)咨詢
有事點擊這里…  531199185
有事點擊這里…  61352289
點擊這里給我發(fā)消息  81721488
有事點擊這里…  376585780
有事點擊這里…  872642803
有事點擊這里…  459248018
有事點擊這里…  61352288
有事點擊這里…  380791050
技術(shù)支持
有事點擊這里…  714236853
有事點擊這里…  719304487
有事點擊這里…  1208894568
有事點擊這里…  61352289
在線客服
有事點擊這里…  531199185
有事點擊這里…  61352288
有事點擊這里…  983054746
有事點擊這里…  893984210
當前位置:首頁 >> 技術(shù)文章 >> 文章瀏覽
技術(shù)文章

備份MySQL數(shù)據(jù)庫的Bash腳本

添加時間:2011-1-28  添加: admin 

【如果你管理有運行在在Apache/MySQL/PHP棧上自己的博客或基于Web的應用,你應當有一個備份系統(tǒng),以保證MySQL數(shù)據(jù)庫中數(shù)據(jù)的安全。當然有一些好辦法,但沒一個比得上一個簡單的Bash腳本。那是我再一則博客評論上偶然發(fā)現(xiàn)的。一下就是美盡在其中的那一腳本:】

  #!/bin/bashNOW=`date +"%Y-%m"`;BACKUPDIR="location/of/your/backup/dir/$NOW";### Server Setup ####* MySQL login user name *#MUSER="user";#* MySQL login PASSWORD name *#MPASS="pass";#* MySQL login HOST name *#MHOST="your-mysql-ip";MPORT="your-mysql-port";# DO NOT BACKUP these databasesIGNOREDB="information_schemamysqltest"#* MySQL binaries *#MYSQL=`which mysql`;MYSQLDUMP=`which mysqldump`;GZIP=`which gzip`;# assuming that /nas is mounted via /etc/fstabif [ ! -d $BACKUPDIR ]; then mkdir -p $BACKUPDIRelse :fi# get all database listingDBS="$(mysql -u $MUSER -p$MPASS -h $MHOST -P $MPORT -Bse 'show databases')"# SET DATE AND TIME FOR THE FILENOW=`date +"d%dh%Hm%Ms%S"`; # day-hour-minute-sec format# start to dump database one by onefor db in $DBSdo DUMP="yes"; if [ "$IGNOREDB" != "" ]; then for i in $IGNOREDB # Store all value of $IGNOREDB ON i do if [ "$db" == "$i" ]; then # If result of $DBS(db) is equal to $IGNOREDB(i) then DUMP="NO"; # SET value of DUMP to "no" #echo "$i database is being ignored!"; fi done fi if [ "$DUMP" == "yes" ]; then # If value of DUMP is "yes" then backup database FILE="$BACKUPDIR/$NOW-$db.gz"; echo "BACKING UP $db"; $MYSQLDUMP --add-drop-database --opt --lock-all-tables -u $MUSER -p$MPASS -h $MHOST -P $MPORT $db | gzip > $FILE fidone

  The best part is that you only need to specify a handful of parameters to make the work. This includes BACKUPDIR (the destination for storing backups), MUSER (MySQL user), MPASS (MySQL user password), MHOST (the IP address of the MySQL server, e.g. localhost), and MPORT (the port the MySQL database is running on, default is 3306).

  【它的最大優(yōu)點在于,在運行腳本之前,你只需要定義一些參數(shù)。這包括BACKUPDIR(存儲本分的目錄),MUSER(MySQL用戶),MPASS(MySQL用戶密碼),MHOST(MySQL服務(wù)器IP地址,如:localhost),和MPORT(MySQL數(shù)據(jù)庫工作的端口,默認是3306)。】

  You can run the manually, or you can set up a cron job which will perform backups on a regular basis. To do this, run the crontab -ecommand and add the following line (replace the sample path with the actual path and backup name):

  【你可以手動運行這一腳本,或者設(shè)置一個計劃作業(yè)(a cron job)以使備份按計劃自動進行。設(shè)置計劃作業(yè)的方法是,運行crontab -e命令,并加入以下代碼(請用實際路徑和備份腳本名替換示例路徑):】

  @daily /path/to/mysqlbackup.sh

  Don't forget to make the executable using the chmod a+x mysqlbackup.sh command.

  【別忘了使用chmod a+x mysqlbackup.sh命令將腳本可執(zhí)行化。】
關(guān)健詞:Bash,腳本

分享到:

頂部 】 【 關(guān)閉
版權(quán)所有:佛山思海電腦網(wǎng)絡(luò)有限公司 ©1998-2024 All Rights Reserved.
聯(lián)系電話:(0757)22630313、22633833
中華人民共和國增值電信業(yè)務(wù)經(jīng)營許可證: 粵B1.B2-20030321 備案號:粵B2-20030321-1
網(wǎng)站公安備案編號:44060602000007 交互式欄目專項備案編號:200303DD003  
察察 工商 網(wǎng)安 舉報有獎  警警  手機打開網(wǎng)站