windows 批處理 備份SQL數據 而且建立壓縮文件

@ECHO ON
set d=%date:~0,10%
set d=%d:-=%
set t=%time:~0,8%
set t=%t::=%
set stamp=%p%%d%%t%
set bakupfolder=E:\BackDB_DongLin\
rem 1按子目錄保存備份文件;0不按 
set lay_in_subfolder=0 
call :backupone DB_DongLin
goto :EOF 
@ECHO OFF 
:backupone 
setlocal 
echo %1 
set dbname=%1 
if not exist %bakupfolder%%dbname% mkdir %bakupfolder%%dbname%
if %lay_in_subfolder%==1 ( 
set subfolder=%dbname%\
)else set subfolder=
rem echo %bakupfolder%%subfolder%%dbname%%stamp%.bak 
sqlcmd -U sa -P "qazwsx123,." -S .\MSSQL2005 -Q "backup database %dbname% to disk='%bakupfolder%%subfolder%%dbname%%stamp%.bak'" 
"E:\Program Files\WinRAR\RAR.exe" a -ep1 -r -o+ -m5 -s -df "%bakupfolder%%subfolder%%dbname%%stamp%".rar "%bakupfolder%%subfolder%%dbname%%stamp%.bak" 
pause
endlocal&goto :EOF 

可利用 百度網盤實現自動備份 可確保數據萬無一失sql

相關文章
相關標籤/搜索