- 帖子
- 56
- 积分
- 264
- 技术
- 0
- 捐助
- 0
- 注册时间
- 2009-7-3
|
本帖最后由 qwertl 于 2011-11-25 11:25 编辑
win2003+mssql server)压缩sql数据库后上传到ftp:
在论坛学习到的,给有用得着的参考下。
代码如下:
net stop SQLSERVERAGENT
ping -n 10 127.1>nul
net stop MSSQLSERVER
ping -n 10 127.1>nul
"C:\Program Files\7-Zip\7z.exe" a -p111222 d:\rardata\sql1_%date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%.7z d:\sqldata\sql1*.*
"C:\Program Files\7-Zip\7z.exe" a -p111222 d:\rardata\sql2_%date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%.7z d:\sqldata\sql2.mdf d:\sqldata\sql2_log.ldf
ping -n 10 127.1>nul
net start MSSQLSERVER
ping -n 10 127.1>nul
net start SQLSERVERAGENT
d:\software\autodel 60 d:\rardata
set desfolder=d:\rardata
dir %desfolder% /b /aa-d>nul 2>nul
if %errorlevel% equ 1 (
echo No archiving file to FTP
ping -n 10 127.1>nul
goto :eof
)
set FtpFile=%temp%\TempAcc.txt
>"%FtpFile%" echo account
>>"%FtpFile%" echo pwd
>>"%FtpFile%" echo cd subdir
>>"%FtpFile%" echo bin
for /f "tokens=*" %%a in ('dir "%desfolder%" /b /aa-d') do (
>>"%FtpFile%" echo put "%desfolder%\%%a"
)
>>"%FtpFile%" echo bye
echo. >>d:\software\arlog.txt
echo sql包上传ftp时间:%date% %time%>>d:\software\arlog.txt
ftp -v -i -s:"%FtpFile%" ftpSRV_IP>>d:\software\arlog.txt
echo. >>d:\soft\arlog.txt
time /t >>d:\software\arlog.txt
echo sql压缩包数据上传FTP完成== >>d:\software\arlog.txt
echo. >>d:\software\arlog.txt
echo. >>d:\software\arlog.txt
ping -n 2 127.1>nul
attrib -a "%desfolder%"\*.*
ping -n 6 127.1>nul
delete %temp%\TempAcc.txt
exit |
|