So I wrote a little script to backup the mysql database. Here it is (with appreciation to the manuals and help I got from our Integrator):
rem ----------------------------------------------------------------------------------------------------------------------
-------      
rem backupshoretel.bat      
rem      
rem Author - Scott Rolf      
rem Version - 1.0      
rem Description - This script automatically backs up the shoretel mysql database      
rem ----------------------------------------------------------------------------------------------------------------------------- 
rem Create Archive folder if it does not exist     
if exist c:\shoretelbackup goto Label1      
echo creating shoretelbackup      
md c:\shoretelbackup 
:Label1     
rem Parse out the current date to a system variable      
for /f "tokens= 1,2,3,4 delims=/ " %%I in ('date /t') do Call :MakeString %%J %%K %%L 
rem Make new folder based on date in archive folder     
md c:\shoretelbackup\%DateString% 
rem Backup mysql     
c:      
cd \Program Files\Shoreline Communications\ShoreWare Server\MySQL\MySQL Server 5.0\bin      
mysqldump.exe --add-drop-table --routines --user=root --password=yourpass --database shoreware > c:\\shoretelBackup\%DateString%\ShoretelBackup.sql 
goto :Cleanup
:Cleanup     
rem CLEANUP..dump dir of c:\shoretelbackup to a text file and delete old      
set T=0      
dir c:\shoretelbackup /b /o:-n > c:\scripts\edir.txt      
for /F %%I in (c:\scripts\edir.txt) do Call :Killold %%I      
goto END1 
rem Function that set the environment variable DateString     
:MakeString      
Set DateString=%1%2%3      
goto :EOF 
:Killold - this subroutine kills logs older then 30 days     
set /a T = 1+%T%      
if %T% LEQ 30 goto :Killold_exit      
rd /S /Q c:\shoretelbackup\%1      
:Killold_exit      
goto :EOF 
:END1     
goto :EOF      
rem -------------------      
rem End of Script      
rem -------------------
Watch out for line breaks in this as a simple cut and paste may not work correctly. I've scheduled it to run every morning and it only keeps the last 30 days worth of backups. Also change "yourpass" above to your mysql password. (The default password is in the manual.)
Enjoy the scripty goodness...
I noticed you haven't posted any Shoretel info. As of late, but wondered if you have any Shoretel SQL backup scripts. I noticed in your 2008 script, you weren't stopping the Shoretel services first, and isn't stopping the services needed for a clean backup since MySQL doesn't have a built in VSS Writer?
ReplyDeleteI'm just learning about SQL, so I apologize if incorrect!
Mark
By the way... I have read almost all your Blog's tonight, and really appreciate you sharing your knowledge and findings with the open community! Great stuff and thanks again!
ReplyDeleteMark