Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

Reply
Forums Veteran II
AndyDufresne
Posts: 2,744
Registered: ‎04-01-2008
My Device: Bold

Script to perform a scheduled BESMgmt DB Backup & FTP to remote server

First, lets backup the database and give it a unique name:

 

 

@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 code 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-2008-09-05-Fri-08-31.bak.  You can schedule this, and then use a regular flat-file backup agent to pick up the database backup, and no need for a SQL Agent on the server.

 

Now lets use the built-in windows ftp client application to ship the file elsewhere:

 

Here are the variables I've used as an example in the script:

 

Username: andy
Password: dufresne
Hostname: my.server
Directory to upload file on ftp server: put/file/here
Local directory to fetch from: C:\BlackBerryDBBackup
files to send: BESMgmt*.bak

 

create a file called script.ftp with the following contents:

 

 

andy dufresne binary prompt n cd put/file/here lcd C:\BlackBerryDBBackup mput BESMgmt*.bak quit

 

 Then create a file in the same directory as script.ftp called ftpit.cmd (schedule it too if you want) with the following contents:

 

 

ftp -s:script.ftp my.server

 

 You could use the command xxcopy in your backup script to purge files older than a certain amount of days.  You could even redirect all output to a text file and use blat.exe to email you a report nightly; all sorts of options.
------------------------------
If you've found a solution through a post; please mark it as a solution.
If someone's was particularly helpful, give them kudo's!.


Get busy living, or get busy dying.

http://blog.port3101.org/hdawg/
New Contributor
chedda
Posts: 3
Registered: ‎12-16-2008
My Device: Not Specified

Re: Script to perform a scheduled BESMgmt DB Backup & FTP to remote server

Whats a good method of restore for this type of backup?

 

Thanks in advance!

~C

New Contributor
kristjan
Posts: 8
Registered: ‎01-08-2009
My Device: Not Specified

Re: Script to perform a scheduled BESMgmt DB Backup & FTP to remote server

thanks Andy for the backup script, I use it to backup database for tsm

 

I scheduled the script to run once a week and to remove older .bak files (>1 day since last modified) from folder with this line I added to your script:

  

forfiles /p c:\BlackBerryDBBackup /m *.bak /d -2 /c "cmd /c del @path"