09-05-2008 08:33 AM
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:
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.
01-11-2009 09:00 AM
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"