跳到主要內容

發表文章

目前顯示的是有「資料庫」標籤的文章

MsSQL資料庫簡易備分

由於工作需要必須在很短的時間製作一個資料庫自動備份的機制,所以很簡單的利用Dos Command的指令做了一個bat檔,加入自動排程,定時執行。 echo ################ Backup the DB ################ osql -U UserName -P Password -S ServerName -n -Q "BACKUP DATABASE DBName TO DISK='d:\temp\%date:~0,4%%date:~5,2%%date:~8,2%.bak'" echo ################ Zip the Backup File ################ "C:\Program Files\WinRAR\WinRAR.exe" a -r -ep1 "d:\temp\%date:~0,4%%date:~5,2%%date:~8,2%.rar" "d:\" echo ################ Delete the source ################ del d:\temp\*.* /F /Q echo ################ move the source ################ move d:\temp\*.* \\192.168.1.1\