Рейтинг@Mail.ru

MS SQL backup и др.


 

Скрипт BackUp MS SQL всех баз сразу.

Настроиваем под себя переменные.

 

@ECHO OFF
SETLOCAL
 
SET backuppath=D:\backup_SQL
SET sqlserver=1c-server
SET NowDate=%DATE:~-2%_%DATE:~3,2%_%DATE:~0,2%

REM Build a list of databases to backup
SET DBList=%backuppath%\db_List.txt
1 > %DBList%
SqlCmd -E -S %sqlserver% -h-1 -W -Q "SET NoCount ON; SELECT Name FROM master.dbo.sysDatabases;" > %DBlist%

REM delete old buckups
del %backuppath%\*.bak

REM Backup each database, prepending the date to the filename
FOR /F "tokens=*" %%I IN (%DBList%) DO (
ECHO Backing up database: %%I
SqlCmd -E -S %sqlserver% -Q "BACKUP DATABASE [%%I] TO DISK = '%backuppath%\%NowDate%_%%I.bak'"
ECHO.
)

REM pack backup
::7z a %backuppath%\%NowDate%.zip %backuppath%\*.bak 
::del %backuppath%\*.bak
REM send to ftp
::"C:\Program Files (x86)\WinSCP\WinSCP.exe" /log=d:\winscp.log /command "open ftp://user:password@192.168.0.1/" "put %backuppath%\%NowDate%.zip /sql/ " "exit"
  
 
ENDLOCAL
 



Другие варианты запуска потока.

Поделиться: