ms sqlserver备份脚本

ms sqlserver备份脚本,第1张

概述ms sqlserver备份脚本,自动FTP上传。 @ECHO off REM Backup Database Script Log Files SET dbbak_dir=e:backupdir\ if not exist %dbbak_dir% mkdir %dbbak_dir% REM Backup Database Name SET B_Database_Name=model SET B_

ms sqlserver备份脚本,自动FTP上传。

@ECHO off

REM Backup Database Script Log files
SET dbbak_dir=e:backupdir\
if not exist %dbbak_dir% mkdir %dbbak_dir%

REM Backup Database name
SET B_Database_name=model
SET B_DATE=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%
ECHO use master ;>%dbbak_dir%FulL_backup.sql
ECHO go >>%dbbak_dir%FulL_backup.sql
rem ECHO SP_ADDUMPDEVICE 'disK',>>%dbbak_dir%FulL_backup.sql
rem ECHO '%B_Database_name%_%B_DATE%_FulL',>>%dbbak_dir%FulL_backup.sql
rem ECHO '%dbbak_dir%%B_Database_name%_%B_DATE%_FulL.bak'; >>%dbbak_dir%FulL_backup.sql
rem ECHO go >>%dbbak_dir%FulL_backup.sql
ECHO BACKUP DATABASE %B_Database_name% >>%dbbak_dir%FulL_backup.sql
ECHO TO disK = '%dbbak_dir%%B_Database_name%_%B_DATE%_FulL.bak' >>%dbbak_dir%FulL_backup.sql
ECHO WITH INIT,NOUNLOAD ;>>%dbbak_dir%FulL_backup.sql
ECHO go >>%dbbak_dir%FulL_backup.sql
ECHO .

REM osql.exe path
SET Osql_PATH=C:\Program files\Microsoft sql Server\90\Tools\Binn\

REM Database user name and password
SET DBUser=sa
SET DBpassword=1q2w3e4R
ECHO BACKUP DATABASE
"%Osql_PATH%sqlcmd.exe" -i %dbbak_dir%FulL_backup.sql -o %dbbak_dir%%B_Database_name%_%B_DATE%

_FulL.log
if not %errorlevel%==0 exit 1

REM FTP info
set FTP_User=ftp
set FTP_PW=ftp
set FTP_IP=127.0.0.1
set FTP_PORT=21
set FTP_DIR=E:\dir

ECHO %FTP_User%>%dbbak_dir%FTP_CMD.txt
ECHO %FTP_PW%>>%dbbak_dir%FTP_CMD.txt
ECHO bin>>%dbbak_dir%FTP_CMD.txt
ECHO cd %FTP_dir%>>%dbbak_dir%\FTP_CMD.txt
ECHO mput %dbbak_dir%%B_Database_name%_%B_DATE%_FulL.bak>>%dbbak_dir%FTP_CMD.txt
ECHO BYE>>%dbbak_dir%\FTP_CMD.txt
ftp -i -s:%dbbak_dir%\FTP_CMD.txt %FTP_IP%
if not %errorlevel%==0 exit 1

REM Delete old backup files
FORfileS /P %dbbak_dir% /D -7 -M %dbbak_dir%*.bak /C "cmd /c del @file"
FORfileS /P %dbbak_dir% /D -7 -M %dbbak_dir%*.log /C "cmd /c del @file"

REM Delete Temp files DEL /Q %dbbak_dir%FulL_backup.sql DEL /Q %dbbak_dir%FTP_CMD.txt

总结

以上是内存溢出为你收集整理的ms sqlserver备份脚本全部内容,希望文章能够帮你解决ms sqlserver备份脚本所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1177763.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存