MYSQL實現自動備份

來源:互聯網
上載者:User

Mysql自動備份:

首頁,需要建立備份存放目錄。如:D:\Data\db_bak\資料庫檔案夾(建議與資料庫同名,以便識別)

找到資料庫檔案所在目錄的檔案夾。如:D:\MysqlData\資料庫檔案夾

在備份的目錄下,建立bat檔案,名稱可自訂,如db_back_aa.bat檔案,輸入以下代碼,(請注意更改成你實際的目錄)

net stop mysql

xcopy Data\db_bak\資料庫檔案夾\*.* D:\MysqlData\資料庫檔案夾\%date:~0,10%\ /y

c:\progra~1\winrar\winrar a -k -r -s D:\MysqlData\資料庫檔案夾\%date:~0,10%.rar D:\MysqlData\資料庫檔案夾\%date:~0,10%\

rd D:\MysqlData\資料庫檔案夾\%date:~0,10%\ /S /Q

net start mysql

說明:

net stop mysql  代錶停止mysql

xcopy D:\MysqlData\資料庫檔案夾\*.* D:\MysqlData\資料庫檔案夾\%date:~0,10%\ /y 將目錄檔案複製到備份目錄,並以日期命名

c:\progra~1\winrar\winrar a  -k -r -s D:\MysqlData\資料庫檔案夾\%date:~0,10%.rar D:\MysqlData\資料庫檔案夾\%date:~0,10%\  將剛剛複製過來的目錄壓縮。

rd D:\MysqlData\資料庫檔案夾\%date:~0,10%\ /S /Q  刪除剛剛的臨時目錄,保留了壓縮檔

net start mysql 開啟服務。

儲存bat檔案。

開啟任務計劃(開始-程式-附件-系統工具-任務計劃,新增工作計劃),將剛剛的bat放入裡面,並設定執行循環,什麼時候執行。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.