@echo off
IF "%1"=="" GOTO DISPLAYHELP
IF "%1"=="/?" GOTO DISPLAYHELP
IF "%1"=="?" GOTO DISPLAYHELP
::move the backups to the next folder up (1 to 2, 2 to 3, etc.)
rmdir /S /Q D:\\backup\\%1\\%2
FOR /L %%A in (1 1 %2) do (
ren D:\\backup\\%1\\%%A C
ren D:\\backup\\%1\\B %%A
ren D:\\backup\\%1\\C B
)
mkdir D:\\backup\\%1\\1
::backup the database
DBToolv3.exe backup %1 D:\\backup\\%1\\1
REM mysqldump -P 3308 %1 > D:\\backup\\%1\\1\\%1.sql
::if it\'s a harvester, backup up the data files
IF "%1"=="harvester" (
xcopy C:\\CA\\NFA\\Netflow\\datafiles\\ReaperArchive15 D:\\backup\\%1\\ReaperArchive15 /M /E /C /Q /Y /I >> DBToolLog-backup.txt
echo %date% %time% >> DBToolLog-backup.txt
)
IF "%1"=="harvester" (
xcopy C:\\CA\\NFA\\Netflow\\datafiles\\HarvesterArchive D:\\backup\\%1\\HarvesterArchive /M /E /C /Q /Y /I >> DBToolLog-backup.txt
echo %date% %time% >> DBToolLog-backup.txt
)
IF "%1"=="harvester" (
xcopy C:\\CA\\NFA\\Netflow\\datafiles\\ReaperArchive D:\\backup\\%1\\ReaperArchive /M /E /C /Q /Y /I >> DBToolLog-backup.txt
echo %date% %time% >> DBToolLog-backup.txt
)
::if it\'s a DSA, backup the data files
IF "%1"=="nqrptr" (
xcopy C:\\CA\\NFA\\Netflow\\datafiles\\ReaperArchive15 D:\\backup\\%1\\ReaperArchive15 /M /E /C /Q /Y /I >> DBToolLog-backup.txt
echo %date% %time% >> DBToolLog-backup.txt
)
::put the backup log with the backup
copy DBToolLog-backup.txt D:\\backup\\%1\\%date:~-4,4%%date:~-10,2%%date:~-7,2%_%1_backup.log
GOTO:EOF
:DISPLAYHELP
@echo off
echo Created by Stuart Weenig (sweenig@gmail.com stuart.weenig.com)
echo (C)2012-2014 Stuart Weenig. All Rights Reserved.
echo This script may be used by anyone as long as the code between
echo the :DISPLAYHELP and :EOF labels remains unchanged.
echo.
echo Version 1.5 Last Updated 2/27/2014
echo.
echo Purpose: This script uses DBTools3\'s DBtool.exe to backup NetQoS
echo databases on Windows servers using MySQL 5.1.
echo.
echo.
echo Usage: This script requires two arguments, the first is the name
echo of the database to be backed up. The second is the number of
echo backups to retain.
echo.
echo Example syntax:
echo nqbackup.bat nms2 3
echo.
echo This would create a backup of the nms2 database in
echo D:\\backup\\nms2\\1. If a backup exists there, it will be moved to
echo D:\\backup\\nms2\\2. If a backup exists there, it will be moved to
echo D:\\backup\\nms2\\3, and so on.
echo.
echo Note: You must have DBToolv3.exe installed in the default directory
echo (D:\\installers\\).
echo.
echo.
pause