SHARE
TWEET

NQ Backup

sweenig Jan 14th, 2014 (edited) 2,642 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. IF "%1"=="" GOTO DISPLAYHELP
  3. IF "%1"=="/?" GOTO DISPLAYHELP
  4. IF "%1"=="?" GOTO DISPLAYHELP
  5. ::move the backups to the next folder up (1 to 2, 2 to 3, etc.)
  6. rmdir /S /Q D:\backup\%1\%2
  7. FOR /L %%A in (1 1 %2) do (
  8. ren D:\backup\%1\%%A C
  9. ren D:\backup\%1\B %%A
  10. ren D:\backup\%1\C B
  11. )
  12. mkdir D:\backup\%1\1
  13. ::backup the database
  14. DBToolv3.exe backup %1 D:\backup\%1\1
  15. REM mysqldump -P 3308 %1 > D:\backup\%1\1\%1.sql
  16. ::if it's a harvester, backup up the data files
  17. IF "%1"=="harvester" (
  18.         xcopy C:\CA\NFA\Netflow\datafiles\ReaperArchive15 D:\backup\%1\ReaperArchive15 /M /E /C /Q /Y /I >> DBToolLog-backup.txt
  19.         echo %date% %time% >> DBToolLog-backup.txt
  20. )
  21. IF "%1"=="harvester" (
  22.         xcopy C:\CA\NFA\Netflow\datafiles\HarvesterArchive D:\backup\%1\HarvesterArchive /M /E /C /Q /Y /I >> DBToolLog-backup.txt
  23.         echo %date% %time% >> DBToolLog-backup.txt
  24. )
  25. IF "%1"=="harvester" (
  26.         xcopy C:\CA\NFA\Netflow\datafiles\ReaperArchive D:\backup\%1\ReaperArchive /M /E /C /Q /Y /I >> DBToolLog-backup.txt
  27.         echo %date% %time% >> DBToolLog-backup.txt
  28. )
  29. ::if it's a DSA, backup the data files
  30. IF "%1"=="nqrptr" (
  31.         xcopy C:\CA\NFA\Netflow\datafiles\ReaperArchive15 D:\backup\%1\ReaperArchive15 /M /E /C /Q /Y /I >> DBToolLog-backup.txt
  32.         echo %date% %time% >> DBToolLog-backup.txt
  33. )
  34. ::put the backup log with the backup
  35. copy DBToolLog-backup.txt D:\backup\%1\%date:~-4,4%%date:~-10,2%%date:~-7,2%_%1_backup.log
  36. GOTO:EOF
  37. :DISPLAYHELP
  38. @echo off
  39. echo Created by Stuart Weenig (sweenig@gmail.com stuart.weenig.com)
  40. echo (C)2012-2014 Stuart Weenig. All Rights Reserved.
  41. echo This script may be used by anyone as long as the code between
  42. echo the :DISPLAYHELP and :EOF labels remains unchanged.
  43. echo.
  44. echo Version 1.5 Last Updated 2/27/2014
  45. echo.
  46. echo Purpose: This script uses DBTools3's DBtool.exe to backup NetQoS
  47. echo databases on Windows servers using MySQL 5.1.
  48. echo.
  49. echo.
  50. echo Usage: This script requires two arguments, the first is the name
  51. echo of the database to be backed up. The second is the number of
  52. echo backups to retain.
  53. echo.
  54. echo Example syntax:
  55. echo nqbackup.bat nms2 3
  56. echo.
  57. echo This would create a backup of the nms2 database in
  58. echo D:\backup\nms2\1. If a backup exists there, it will be moved to
  59. echo D:\backup\nms2\2. If a backup exists there, it will be moved to
  60. echo D:\backup\nms2\3, and so on.
  61. echo.
  62. echo Note: You must have DBToolv3.exe installed in the default directory
  63. echo (D:\installers\).
  64. echo.
  65. echo.
  66. pause
RAW Paste Data
Top