BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-07-2007, 09:32 AM   #1 (permalink)
BlackBerry Genius
 
hdawg's Avatar
 
Join Date: Aug 2006
Model: hdawg
PIN: port3101.org
Carrier: hdawg
Posts: 6,632
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Script to perform a scheduled BESMgmt DB Backup & FTP to remote server

Please Login to Remove!

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 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-2007-10-07-Sun-09-25.bak.

I needed something quick for customers that used MSDE, and I wanted the filename to be as descriptive as possible. 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.

Last edited by hdawg : 10-07-2007 at 01:01 PM. Reason: modified Title to include full thread discussion
Offline  
Old 10-07-2007, 12:23 PM   #2 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2007
Location: Southern California
Model: 8900
Carrier: T-Mobile
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank You!!!! Much better than the .bat I was using. Now all i need to do is ftp the file to a server that is backed up on TSM. I'm having problem with the command line doing it unattended.
Offline  
Old 10-07-2007, 12:43 PM   #3 (permalink)
BlackBerry Genius
 
hdawg's Avatar
 
Join Date: Aug 2006
Model: hdawg
PIN: port3101.org
Carrier: hdawg
Posts: 6,632
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by jviola_simi View Post
Thank You!!!! Much better than the .bat I was using. Now all i need to do is ftp the file to a server that is backed up on TSM. I'm having problem with the command line doing it unattended.
Try this ... here is some sample data:

Username: bob
Password: monkey
Hostname: server.local
Directory to upload file on ftp server: my/stuff/here
Local directory to fetch from: C:\BlackBerryDBBackup
files to send: BESMgmt*.bak

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

Code:
bob
monkey
binary
prompt n
cd my/stuff/here
lcd C:\BlackBerryDBBackup
mput BESMgmt*.bak
quit
Then create a file in the same directory as script.ftp called ftpit.cmd with the following contents:

Code:
ftp -s:script.ftp server.local
You could use the command xxcopy in your backup script to purge files older than a certain amount of days. Good luck; hope this helps.
Offline  
Old 10-07-2007, 12:44 PM   #4 (permalink)
BlackBerry Genius
 
hdawg's Avatar
 
Join Date: Aug 2006
Model: hdawg
PIN: port3101.org
Carrier: hdawg
Posts: 6,632
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

You could even redirect all output to a text file and use blat.exe to email you a report nightly; all sorts of options.
Offline  
Old 10-07-2007, 01:05 PM   #5 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2007
Location: Southern California
Model: 8900
Carrier: T-Mobile
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

You guys are studs!!!! Thank you for helping my lazy butt out.
Offline  
Old 10-30-2007, 03:30 PM   #6 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2006
Location: Canada
Model: 7290
Carrier: Rogers
Posts: 35
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks all for the tips. Much appreciated.

Che
__________________
Che
Offline  
Old 06-19-2008, 05:46 PM   #7 (permalink)
Thumbs Must Hurt
 
Join Date: Dec 2005
Location: Austin, Tx
Model: 9000
Carrier: AT&Tingular
Posts: 192
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dug this up from the dead...

I REALLY need to get my server backed up. Its been in production for almost 3 years with no backup.. 912 users. Yikes.

Anyways, just want to know if this script will take the DB offline or anything while its running?

If someone that uses this, or OSQL in general, could let me know, I would appreciate it...

Thanks much,
Greg
Offline  
Old 06-19-2008, 08:02 PM   #8 (permalink)
Thumbs Must Hurt
 
Join Date: Dec 2005
Location: Austin, Tx
Model: 9000
Carrier: AT&Tingular
Posts: 192
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nevermind, gents. I just tried it myself on a lab machine and it works without taking anything offline.

This is a god send. Thanks to the OP!

Greg
Offline  
Old 06-19-2008, 09:53 PM   #9 (permalink)
BlackBerry Genius
 
hdawg's Avatar
 
Join Date: Aug 2006
Model: hdawg
PIN: port3101.org
Carrier: hdawg
Posts: 6,632
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

glad to hear it works for you.
Offline  
Old 06-19-2008, 10:00 PM   #10 (permalink)
iPhone Convert
 
juwaack68's Avatar
 
Join Date: Oct 2005
Location: Tulip City - MI
Model: iP5
OS: 6.0.2
PIN: to beans
Carrier: I'm not
Posts: 13,875
Post Thanks: 3
Thanked 72 Times in 55 Posts
Default

Wow. Three years with no backup. And I thought 8 months was long.... I just implemented this on 3 of my servers.

The Monkey rulz!
__________________
No longer a BES Admin, but it was fun while it lasted!
Offline  
Old 08-04-2008, 06:24 PM   #11 (permalink)
Thumbs Must Hurt
 
jeffro01's Avatar
 
Join Date: Oct 2006
Location: 67235
Model: 9700
OS: 5.0.0.423
PIN: 2277C472
Carrier: At&t (Company)
Posts: 173
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by hdawg View Post
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 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-2007-10-07-Sun-09-25.bak.

I needed something quick for customers that used MSDE, and I wanted the filename to be as descriptive as possible. 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.
Whats a good method of restore for this type of backup?

Jeff
Offline  
Old 08-14-2008, 10:51 AM   #12 (permalink)
Knows Where the Search Button Is
 
Join Date: May 2008
Model: 8320
PIN: N/A
Carrier: T-mobile
Posts: 49
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry to drag this up from the dead, but the other thread this morning made me double check my backups and I just realized that when I switched to a new box and SQL 2005 from MSDE that this script quit working.

Any suggestions on how to get this to work? I just manually backed up my DB, but would like to get it automated again.
Offline  
Old 08-14-2008, 12:02 PM   #13 (permalink)
CrackBerry Addict
 
Join Date: Jan 2008
Model: 9700
PIN: N/A
Carrier: Rogers
Posts: 709
Post Thanks: 0
Thanked 8 Times in 8 Posts
Default

I would venture to guess that if you simply copied the task, you need to supply the credentials again in the task scheduler - the passwords don't carry over. I've even had to recreate the task from scratch for it to work.
Offline  
Old 08-15-2008, 06:14 AM   #14 (permalink)
Talking BlackBerry Encyclopedia
 
DavidAdams's Avatar
 
Join Date: Sep 2007
Location: Belfast
Model: NotYe
PIN: N/A
Carrier: O2
Posts: 470
Post Thanks: 2
Thanked 0 Times in 0 Posts
Default

Not sure where the problem lies but if I backup my database using this script its 20Mb in size, give or take a wee bit, but if I backed up using the option from SQL Studio Management Express it used to be 200Mb in size.

Well it was but isn't anymore. Just backed up from SSME and it's now the same size.

What gives?
__________________
BES, 4.1.7, was SBE now full BES
Domino v7.0.2
Windows Server 2003, standalone

Last edited by DavidAdams : 08-15-2008 at 07:03 AM.
Offline  
Old 02-22-2009, 12:05 PM   #15 (permalink)
New Member
 
Luukr's Avatar
 
Join Date: Feb 2009
Location: Holland
Model: 8310
OS: 4.2.2.173
PIN: N/A
Carrier: Vodafone
Posts: 11
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

How can i restore this backup ?

Thanks in advance!
__________________
______________________________________
Luuk Ros, Consultant for Reitsma Telecom
Offline  
Old 02-22-2009, 04:57 PM   #16 (permalink)
CrackBerry Addict
 
Join Date: Jan 2008
Model: 9700
PIN: N/A
Carrier: Rogers
Posts: 709
Post Thanks: 0
Thanked 8 Times in 8 Posts
Default

Just thought I'd add that here's a freeware version with email notification as well as rotating your backups out:

Free SQL Server database backup, Zip and FTP software

Very easy to use.
Offline  
Old 02-22-2009, 05:17 PM   #17 (permalink)
BlackBerry God
 
jibi's Avatar
 
Join Date: Oct 2004
Location: Jibi's Secret Place
Model: 8900
OS: 4.6.1.174
Carrier: AT&T
Posts: 11,310
Post Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by Luukr View Post
How can i restore this backup ?

Thanks in advance!
As the script is using OSQL to backup the database, you would use the same tool to restore it, only with a slightly different command:

OSQL -E -Q "restore database BESMgmt from disk = 'C:\BlackBerryDBBackup\backup.bak'"

...or you could restore it using Microsoft SQL Studio Express, as well.

@DavidAdams, are you using the backups were 200MB in size and not the actual database (MDF file)? The BES database starts out at 100MB, although the backups can be as small as 5MB. Another thought is that perhaps your transaction logs were truncated at some point, which would affect the backup size.
__________________
In the beginning the Universe was created. This has made a lot of people very angry and is widely regarded as a bad move.
Offline  
Old 02-24-2009, 09:17 AM   #18 (permalink)
Knows Where the Search Button Is
 
Join Date: Feb 2009
Model: n/a
PIN: N/A
Carrier: n/a
Posts: 17
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can anyone come up with an additional code in this script to then COPY the new backup file to another drive? I have the sript working great, but I'd like to also make a copy to a share on another server (in this case Z for redundancy.

I am awful at scripting, so I can't figure out how to do this.
Offline  
Old 02-24-2009, 09:58 AM   #19 (permalink)
Thumbs Must Hurt
 
Join Date: Dec 2005
Location: Austin, Tx
Model: 9000
Carrier: AT&Tingular
Posts: 192
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I use robocopy (Free Utility) to copy them to another server. You can download it.

My code is below:

Code:
cd\
robocopy c:\blackberrydbbackup \\<DestinationServerName>\D$\BlackBerryBackup /E /XO
cd blackberrydbbackup
del bes*
I put this code into a file I called "MoveFilesAfterBackup.cmd" and run it as a scheduled task approx 30 minutes after my backup completes. I ran a backup first to see how long it takes, then scheduled my task accordingly.

On the destination server, I run a zdel script to delete backups that are 3+ days old.
Offline  
Old 05-08-2009, 03:16 PM   #20 (permalink)
Knows Where the Search Button Is
 
Join Date: Feb 2009
Model: n/a
PIN: N/A
Carrier: n/a
Posts: 17
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Very odd thing happened. For some reason this script - which was working perfectly fine for months - all of a sudden stopped working on 4/1 and hasn't run since. When I double-click on teh script the window just flashes and nothing happens. I'm not even getting any errors in the Event Viewed, which doesn't help me.

Any ideas on what to try?

EDIT: I'm trying to manually run osql -E in the command prompt and I'm getting "'osql' is not recognized as an internal or external command, operable program or batch file."

Uh-oh....

Edit 2: In looking back at that day, the server crashed and there's a chance that's when I re-installed BES.

Last edited by dcomiskey : 05-08-2009 at 04:19 PM.
Offline  
Closed Thread


Thread Tools

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

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





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.