windows MySQL數據備份

環境
OS:windows server 2012
Mysql:5.6.33

編寫腳本
新建dump.bat批處理文件

@echo off
forfiles /p "D:\gateway\mysql-5.6.33\backup" /s /m welink*.sql -d -30 /c "cmd /c del /f @path"
set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"
"D:\gateway\mysql-5.6.33\bin"\mysqldump --opt -u root --password=test@2017
database > D:\gateway\mysql-5.6.33\backup\db
%Ymd%.sql
@echo on

說明

"-u"後填入數據庫登錄用戶名,

"–password="登錄用戶密碼,

"database"爲數據庫的名字,

">"後爲備份文件的保存地方。

點擊運行批處理文件,會在對應的文件夾下生成db_20180101.sql這樣的備份文件。

forfiles del 保留最近30天的備份文件,超過30天的刪除

創建定時任務
微軟鍵(鍵盤上的田字鍵)+R調出運行窗口,然後輸入taskschd.msc啓動定時任務設置窗口
windows MySQL數據備份
windows MySQL數據備份
windows MySQL數據備份
windows MySQL數據備份
windows MySQL數據備份
windows MySQL數據備份
windows MySQL數據備份
windows MySQL數據備份

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章