@ECHO OFF
SETLOCAL
DEL D:\MercuryDBBackup\DBBACKUP\Mercury.bak
echo Deleting Mercury.bak finished at %date% %time%
DEL D:\MercuryDBBackup\DBBACKUP\SalesDW_Mercury.bak
echo Deleting SalesDW_Mercury.bak finished at %date% %time%
DEL D:\MercuryDBBackup\DBBACKUP\Mercury_Scope.bak
echo Deleting Mercury_Scope.bak finished at %date% %time%
REM Build a list of databases to backup
SET DBList=%SystemDrive%\SQLDBList.txt
SqlCmd -E -S 192.168.50.52\MERCURY -h-1 -W -Q "SET NoCount ON; SELECT Name FROM master.dbo.sysDatabases WHERE [Name] IN ('Mercury','SalesDW_Mercury','Mercury_Scope')" > "%DBList%"
REM Backup each database, prepending the date to the filename
FOR /F %%I IN (%DBList%) DO (
ECHO Backing up database: %%I
SqlCmd -E -S 192.168.50.52\MERCURY -Q "BACKUP DATABASE [%%I] TO Disk='D:\MercuryDBBackup\DBBACKUP\%%I.bak'"
ECHO.
)
REM Clean up the temp file
IF EXIST "%DBList%" DEL /F /Q "%DBList%"
echo Completed Successfully at %date% %time%>>_date_.txt
SETLOCAL
DEL D:\MercuryDBBackup\DBBACKUP\Mercury.bak
echo Deleting Mercury.bak finished at %date% %time%
DEL D:\MercuryDBBackup\DBBACKUP\SalesDW_Mercury.bak
echo Deleting SalesDW_Mercury.bak finished at %date% %time%
DEL D:\MercuryDBBackup\DBBACKUP\Mercury_Scope.bak
echo Deleting Mercury_Scope.bak finished at %date% %time%
REM Build a list of databases to backup
SET DBList=%SystemDrive%\SQLDBList.txt
SqlCmd -E -S 192.168.50.52\MERCURY -h-1 -W -Q "SET NoCount ON; SELECT Name FROM master.dbo.sysDatabases WHERE [Name] IN ('Mercury','SalesDW_Mercury','Mercury_Scope')" > "%DBList%"
REM Backup each database, prepending the date to the filename
FOR /F %%I IN (%DBList%) DO (
ECHO Backing up database: %%I
SqlCmd -E -S 192.168.50.52\MERCURY -Q "BACKUP DATABASE [%%I] TO Disk='D:\MercuryDBBackup\DBBACKUP\%%I.bak'"
ECHO.
)
REM Clean up the temp file
IF EXIST "%DBList%" DEL /F /Q "%DBList%"
echo Completed Successfully at %date% %time%>>_date_.txt
No comments:
Post a Comment