Welcome to Port3101.org : Your BES Connection Mark forums read | View Forum Leaders
Port3101.org : Your BES Connection



Reply
LinkBack (2) Thread Tools Display Modes
Script to perform a scheduled BESMgmt Database backup
 
  2 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 01-11-2009, 08:26 PM
hdawg's Avatar
Proprietor
 
Join Date: Nov 2008
Posts: 2,257
Blog Entries: 147
Default Script to perform a scheduled BESMgmt Database backup

Check this out ...

Backup the database and give it a unique name

Code:
@for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do @set dt=%%l-%%j-%%k-%%i
@for /f "Tokens=1" %%i in ('time /t') do @set tm=-%%i
@set tm=%tm::=-%
@set dtt=%dt%%tm%
@echo Copying backup set: %dtt%.
@echo Please wait...

@if not exist C:\BlackBerryDBBackup mkdir C:\BlackBerryDBBackup
@cd /D C:\BlackBerryDBBackup
@OSQL -E -Q "backup database BESMgmt to disk = 'C:\BlackBerryDBBackup\backup.bak'"
@ren backup.bak "BESMgmt-%dtt%.bak"
Save the script as BESMgmt-backup.cmd and schedule it as a task to run on your BES as BESAdmin. It will output a file as such: BESMgmt-2009-01-11-Sun-19-25.bak. You can schedule this and depending on where you have it save (you could have it save to a mapped network drive / other location ... or even use something like robocopy with the /MIR switch to sync the contents of the directory with one on a network share) ... this is actually what I do in situations where the server the database is on doesn't get backed up daily.
__________________
http://blog.port3101.org/hdawg/
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-11-2009, 08:34 PM
Joolie's Avatar
Super Moderator
 
Join Date: Dec 2008
Location: West Michigan
Posts: 763
Default

I use this on 3 of our servers and it works wonderfully
__________________
You may know me as Juwaack68
Reply With Quote
  #3 (permalink)  
Old 01-15-2009, 08:42 PM
BES Activated
 
Join Date: Jan 2009
Posts: 2
Default

Great script, I just used it and it works great on my 4.1.6 BES. While I am here I am also looking for a script that would delete the files that are more then three days old for example. Anyone have any tips or hints of where I could find such a script? Again thanks for the awsome script.
Reply With Quote
  #4 (permalink)  
Old 01-15-2009, 10:02 PM
hdawg's Avatar
Proprietor
 
Join Date: Nov 2008
Posts: 2,257
Blog Entries: 147
Default

Quote:
Originally Posted by Sherrera View Post
Great script, I just used it and it works great on my 4.1.6 BES. While I am here I am also looking for a script that would delete the files that are more then three days old for example. Anyone have any tips or hints of where I could find such a script? Again thanks for the awsome script.
What are you looking to delete? Anything in specific? Old log files? or just anything?
__________________
http://blog.port3101.org/hdawg/
Reply With Quote
  #5 (permalink)  
Old 01-15-2009, 10:03 PM
Joolie's Avatar
Super Moderator
 
Join Date: Dec 2008
Location: West Michigan
Posts: 763
Default

Format c:/...?
__________________
You may know me as Juwaack68
Reply With Quote
  #6 (permalink)  
Old 01-16-2009, 12:12 PM
BES Activated
 
Join Date: Jan 2009
Posts: 2
Default

Sorry, I want to be able to Schedule the deletion of the old backup files that are older then say 2 or 3 days. That why the daily backups wont fill up the HD someday.

Example:
I now have 2 backup files using this nameing convention
BESMgmt-Year-Month-Day-DayofTheWeek-Time.bak
these are backed up to the folder
D:\BlackBerryDBBackup\
We then save the files to tape everynight.
So I only really need maybe 2 or 3 days worth at any given time.
However I dont want to have to manual delete the files from the folder.
so is there a way to also automate that process?

Last edited by Sherrera; 01-16-2009 at 12:55 PM.
Reply With Quote
  #7 (permalink)  
Old 01-16-2009, 09:55 PM
BES Administrator
 
Join Date: Jan 2009
Posts: 29
Default

here is a mysqldump backup dos script i use as a 5 logrotate and zip it up at the end. you can pair it down to logrotate 4,3,2 etc. whatever. Its a decent enough template to use.

Code:
@echo off

:ONE1
IF EXIST C:\folder\file1.bak goto TWO2
mysqldump --opt dbname > "C:\folder\file1.bak"
IF EXIST C:\folder\file2.bak del C:\folder\file2.bak
goto:7zipit

:TWO2
IF EXIST "c:\folder\file2.bak" goto THREE3
mysqldump --opt dbname > "c:\folder\file2.bak"
IF EXIST "c:\folder\file3.bak" del c:\folder\file3.bak
goto:7zipit

:THREE3
IF EXIST "c:\folder\file3.bak" goto FOUR4
mysqldump --opt dbname > "c:\folder\file3.bak"
IF EXIST "c:\folder\file4.bak" del c:\folder\file4.bak
goto:7zipit

:FOUR4
IF EXIST "c:\folder\file4.bak" goto FIVE5
mysqldump --opt dbname > "c:\folder\file4.bak"
IF EXIST "c:\folder\file5.bak" del c:\folder\file5.bak
goto:7zipit

:FIVE5
IF EXIST "c:\folder\file5.bak" goto ONE1
mysqldump --opt dbname > "c:\folder\file5.bak"
IF EXIST "c:\folder\file1.bak" del c:\folder\file1.bak
goto:7zipit

:7zipit
"c:\Program Files\7-Zip\7z.exe" a c:\zipfiles\files.7z "c:\folder"
goto:EOF
Reply With Quote
  #8 (permalink)  
Old 01-22-2009, 08:59 PM
hdawg's Avatar
Proprietor
 
Join Date: Nov 2008
Posts: 2,257
Blog Entries: 147
Default

Quote:
Originally Posted by Sherrera View Post
Sorry, I want to be able to Schedule the deletion of the old backup files that are older then say 2 or 3 days. That why the daily backups wont fill up the HD someday.

Example:
I now have 2 backup files using this nameing convention
BESMgmt-Year-Month-Day-DayofTheWeek-Time.bak
these are backed up to the folder
D:\BlackBerryDBBackup\
We then save the files to tape everynight.
So I only really need maybe 2 or 3 days worth at any given time.
However I dont want to have to manual delete the files from the folder.
so is there a way to also automate that process?
Attached to this, is forfiles.exe; great little app.

Try this out. The last line will purge files 5 days old

Code:
@for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do @set dt=%%l-%%j-%%k-%%i
@for /f "Tokens=1" %%i in ('time /t') do @set tm=-%%i
@set tm=%tm::=-%
@set dtt=%dt%%tm%
@echo Copying backup set: %dtt%.
@echo Please wait...

@if not exist C:\BlackBerryDBBackup mkdir C:\BlackBerryDBBackup
@cd /D C:\BlackBerryDBBackup
@OSQL -E -Q "backup database BESMgmt to disk = 'C:\BlackBerryDBBackup\backup.bak'"
@ren backup.bak "BESMgmt-%dtt%.bak"
forfiles -p C:\BlackBerryDBBackup -s -m *.bak -d -5 -c "cmd /c del @file"
more information on forfiles
Attached Files
File Type: zip forfiles.zip (22.2 KB, 110 views)
__________________
http://blog.port3101.org/hdawg/
Reply With Quote
  #9 (permalink)  
Old 09-08-2009, 11:57 AM
BES Activated
 
Join Date: Apr 2009
Location: kansas
Posts: 6
Default

Quote:
Originally Posted by Mr. E View Post
Check this out ...

Backup the database and give it a unique name

Code:
@for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do @set dt=%%l-%%j-%%k-%%i
@for /f "Tokens=1" %%i in ('time /t') do @set tm=-%%i
@set tm=%tm::=-%
@set dtt=%dt%%tm%
@echo Copying backup set: %dtt%.
@echo Please wait...

@if not exist C:\BlackBerryDBBackup mkdir C:\BlackBerryDBBackup
@cd /D C:\BlackBerryDBBackup
@OSQL -E -Q "backup database BESMgmt to disk = 'C:\BlackBerryDBBackup\backup.bak'"
@ren backup.bak "BESMgmt-%dtt%.bak"
Save the script as BESMgmt-backup.cmd and schedule it as a task to run on your BES as BESAdmin. It will output a file as such: BESMgmt-2009-01-11-Sun-19-25.bak. You can schedule this and depending on where you have it save (you could have it save to a mapped network drive / other location ... or even use something like robocopy with the /MIR switch to sync the contents of the directory with one on a network share) ... this is actually what I do in situations where the server the database is on doesn't get backed up daily.
Does this need to be ran on the SQL server or the BES server? I tried running it on my BES server but the only thing it does is make the directory for the backup. Where would I feed it the database connections if we are running a remote sql 2005 box for our DB?
Reply With Quote
  #10 (permalink)  
Old 09-08-2009, 09:09 PM
hdawg's Avatar
Proprietor
 
Join Date: Nov 2008
Posts: 2,257
Blog Entries: 147
Default

This needs to be run on the SQL server, or you need to add a -S SERVERNAME to the OSQL statement ... such as:

@OSQL -E -S SQL01 -Q "backup database BESMgmt to disk = 'C:\BlackBerryDBBackup\backup.bak'"

REMEMBER: You need to make sure though that you run the script as a user that has permissions on the database.
__________________
http://blog.port3101.org/hdawg/
Reply With Quote
  #11 (permalink)  
Old 08-04-2011, 08:06 AM
BES Activated
 
Join Date: Aug 2011
Posts: 1
Default

Thanks for the great script!

I'm trying to run the backup on a separate server, using all of what you have suggested, but it's not quite working out right; was hoping if you could give some suggestions. I see that it creates the folder, but it doesn't run the backup, the cmd window pops up and then closes briefly.

Any ideas?
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


LinkBacks (?)
LinkBack to this Thread: http://www.port3101.org/scripts-tools-hints-tricks/250-script-perform-scheduled-besmgmt-database-backup.html
Posted By For Type Date
Best way to backup BESMgmt? - BlackBerry Forums Support Community This thread Refback 05-20-2014 04:59 PM
MSDE to SQL - BlackBerryForums.com : Your Number One BlackBerry Community This thread Refback 06-02-2009 12:58 PM

Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing an SQL Besmgmt database over the top arthurlandry Port 3101: The BES Admin Bar & Grill 0 04-27-2010 03:58 PM
BESMgmt SQL Database Mirroring mahoward Port 3101: The BES Admin Bar & Grill 7 03-05-2010 06:29 PM
KB03315 - Perform a wired organizer data synchronization and database backup hdawg Featured BlackBerry KB Articles 1 08-30-2009 12:34 PM
KB11633 - Perform a backup of information on the BlackBerry Enterprise Server hdawg Featured BlackBerry KB Articles 0 08-30-2009 12:01 PM
Script to perform offline database maintenance. (Domino) SteveO86 Scripts & Tools / Hints & Tricks 6 02-19-2009 06:47 AM


All times are GMT -4. The time now is 02:17 AM.
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.


 

SEO by vBSEO 3.3.2 PL2