Автор: tankistua
Дата сообщения: 23.07.2013 16:00
так бекапь все по очереди
Код:
IF %DATE:~3,2% EQU 1 set MM-1=12
IF %DATE:~3,2% EQU 2 set MM-1=01
IF %DATE:~3,2% EQU 3 set MM-1=02
IF %DATE:~3,2% EQU 4 set MM-1=03
IF %DATE:~3,2% EQU 5 set MM-1=04
IF %DATE:~3,2% EQU 6 set MM-1=05
IF %DATE:~3,2% EQU 7 set MM-1=06
IF %DATE:~3,2% EQU 8 set MM-1=07
IF %DATE:~3,2% EQU 9 set MM-1=08
IF %DATE:~3,2% EQU 10 set MM-1=09
IF %DATE:~3,2% EQU 11 set MM-1=10
IF %DATE:~3,2% EQU 12 set MM-1=11
set YYYY-MM-1-DD=%DATE:~6,4%-%MM-1%-%DATE:~0,2%
set YYYY-MM-DD=%DATE:~6,4%-%DATE:~3,2%-%DATE:~0,2%
set p_backup=E:\1c-backup
set p_backupnet=\\nas\backup\1c
set p_rar="C:\Program files\Winrar\rar.exe"
set p_sqlcmd="C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe"
set sql_server=local
set sql_username=sa
set sql_userpass=sapassword
IF NOT EXIST %p_backup%\%YYYY-MM-DD% MKDIR %p_backup%\%YYYY-MM-DD%
IF NOT EXIST %p_backupnet%\%YYYY-MM-DD% MKDIR %p_backupnet%\%YYYY-MM-DD%
IF %DATE:~0,2% NEQ 01 IF EXIST %p_backup%\%YYYY-MM-1-DD% RMDIR %p_backup%\%YYYY-MM-1-DD% /s /q
IF %DATE:~0,2% NEQ 01 IF EXIST %p_backupnet%\%YYYY-MM-1-DD% RMDIR %p_backupnet%\%YYYY-MM-1-DD% /s /q
FOR %%i IN (
base1
base2
base3
master
) DO %p_sqlcmd% -S (local) -U "%sql_username%" -P "%sql_userpass%" -d "%%i" -Q "BACKUP DATABASE [%%i] TO DISK = N'%p_backup%\%YYYY-MM-DD%\%%i-%YYYY-MM-DD%.bak' WITH INIT , NOUNLOAD , NOSKIP , STATS = 10, NOFORMAT" & %p_rar% a -ep -df %p_backup%\%YYYY-MM-DD%\%%i-%YYYY-MM-DD%.rar %p_backup%\%YYYY-MM-DD%\%%i-%YYYY-MM-DD%.bak & xcopy /q /h /r /y %p_backup%\%YYYY-MM-DD%\%%i-%YYYY-MM-DD%.rar %p_backupnet%\%YYYY-MM-DD%\