BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 11-14-2007, 08:33 PM   #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 zip BES Log files

Please Login to Remove!

RIM has the ability to automatically purge old log files as a part of BES. You can go to BlackBerry Server Configuration and change how long the server will keep the logs before purging them (as seen in the picture attached), but you can't do the same for SMS/PIN/Phone logs.

Regardless, if there's one thing you probably know about me, it's that I'm a log junkie. Much like a scale doesn't lie; the logs don't lie ... and I hate to get rid of them; so much that I really have no problem keeping them for a year or more. There is so much value in them, and they really don't take up all the much space if you zip them up ... even in very busy environment. But, if you leave logs as uncompressed text, you could easily see a volume fill up and you'll be out of space wondering what the heck is going on.

That said, to address a few of my desires:

1) To have logs for as long as possible
2) To not waste disk space unnecessarily
3) To make troubleshooting easier
4) To make planning easier (the next time you need an upgrade you can use the data in these logs to backup your claims / requests)
5) To deliver a script that I promised to a customer that has been patiently waiting

I've put together this mega-simple script which can really be modified to just about anything ... just be gentle with it because if you change things around you could easily be deleting entire file systems instead of just zipping up some aging log files.

Attached is a zip file with 3 files:

zip.exe (duh)
forfiles.exe (command to iterate the zip command)
go.cmd (script that you execute)

... and here is the contents of go.cmd:

-----

@ECHO OFF
REM -- Script to individually zip BES Log files ...
REM -- Place this file along with forfiles.exe and zip.exe in the root directory of your BlackBerry Logs folder
REM -- By Default: C:\Program Files\Research in Motion\BlackBerry Enterprise Server\Logs
REM -- This will zip all TXT files in the current and all sub-directories 10 days old or older
REM -- 4/23/2008 - Updated to delete old files / directories
REM -- Change "-d-90" if you want to delete files at an age different than 90 days
REM -- Uncomment the REM -- lines at the bottom if you actually want it to do deletion

forfiles.exe -p. -s -m*.txt -d-10 -c"zip -m @FILE.zip @FILE"

REM -- forfiles.exe -p. -s -d-90 -m*.txt -c"cmd /c if @ISDIR==FALSE del /q /f @FILE"
REM -- forfiles.exe -p. -s -d-90 -m*.csv -c"cmd /c if @ISDIR==FALSE del /q /f @FILE"
REM -- forfiles.exe -p. -s -d-90 -m*.zip -c"cmd /c if @ISDIR==FALSE del /q /f @FILE"
REM -- forfiles.exe -p. -s -d-90 -m*.* -c"cmd /c if @ISDIR==TRUE rd /q @FILE"
-----

Here's a breakdown of what the command is doing:

forfiles.exe (The forfiles command, to iterate through all the log files)
-p. (The starting point for the filelist. "." means the current working directory that forfiles.exe is located in)
-s (Recurse subdirectories)
-m*.txt (Process all .TXT files)
-d-10 (10 days old or older)
-c"zip -m @FILE.zip @FILE" (The command to execute on each file. @FILE represents the current file being processed. zip -m tells it to zip the file and move the file into the zip, therefore removing the original .TXT file. Then the next time this gets run it won't have to zip the file again.)

Put these 3 files in the root of your BES Logs directory ... by default it is: "C:\Program Files\Research in Motion\BlackBerry Enterprise Server\Logs" and schedule go.cmd as a task to run nightly; you'll keep the last 10 days of logs easily accessible and older logs on the file system, just compressed.

I had thought about having each day zip into a single file, but then the structure of what is there gets modified ... I wanted to keep it simple, keep the directory / file structure as it was, but just compress the files.

Alternatively, you could enable file compression on the file system and ignore this script totally ... but I like this better.

Last edited by hdawg : 09-21-2008 at 06:22 PM.
Offline  
Old 11-14-2007, 08:35 PM   #2 (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

Your knowledge of this stuff is downright scary..... but you RULE!
__________________
No longer a BES Admin, but it was fun while it lasted!
Offline  
Old 11-15-2007, 11:22 AM   #3 (permalink)
x14
BlackBerry Extraordinaire
 
Join Date: Jul 2005
Location: NYC
Model: 9800
OS: 6.0.0.546
Carrier: AT&T
Posts: 2,344
Post Thanks: 0
Thanked 17 Times in 16 Posts
Default

Quote:
Originally Posted by hdawg View Post
I had thought about having each day zip into a single file, but then the structure of what is there gets modified ... I wanted to keep it simple, keep the directory / file structure as it was, but just compress the files.
Here's a script I have for creating 1 per day. You will need WinZip and the Command Line Support Add-On.
Attached Files
File Type: zip ZipLogs.zip (25.1 KB, 15 views)
__________________
Exchange 2007/BES 5.0.2 MR2
Offline  
Old 04-04-2008, 09:41 AM   #4 (permalink)
New Member
 
Join Date: Apr 2008
Model: 7290
PIN: N/A
Carrier: tmobile
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am unable to download either of the scripts on this page or the jpeg file. If anyone has them and can send me them I would greatly appreciate it. Thanks for the help and here is my email [email address]
Offline  
Old 04-04-2008, 12:52 PM   #5 (permalink)
Knows Where the Search Button Is
 
bincarnato's Avatar
 
Join Date: Mar 2006
Model: 8310
Carrier: AT&T
Posts: 20
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Can't Download

hdawg,
I am not able to download either.
__________________
BES 4.1.x Exchange
9 Users
Offline  
Old 04-04-2008, 12:57 PM   #6 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2007
Model: Z10
OS: 10.1.0.19
Carrier: Fido
Posts: 1,068
Post Thanks: 6
Thanked 30 Times in 29 Posts
Default

Same here
Offline  
Old 04-04-2008, 01:29 PM   #7 (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

I've re-attached the zip file; should be good now.
Offline  
Old 04-08-2008, 04:30 PM   #8 (permalink)
CrackBerry Addict
 
qc_metal's Avatar
 
Join Date: Mar 2005
Location: Rockford, IL
Model: 9530
OS: 4.7.x
Carrier: Verizon
Posts: 590
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by x14 View Post
Here's a script I have for creating 1 per day. You will need WinZip and the Command Line Support Add-On.
If anyone wants to use something that is freeware, which includes command-line support, I recommend IZArc. Does a great job, and supports about twice as many compression algorithms.

I might have to also check these scripts out! Thanks guys!
__________________
Provision, maintain, and report on users via web: the NEW BerryStats | FAQ
Offline  
Old 04-08-2008, 07:51 PM   #9 (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

hdawg, add in configurable support for folder/file removal after 'x' (user input) days and consider it installed in my environment. i was thinking of installing some win32-compiled utilities for this purpose alone. the above would be EXTREMELY simple in unix command-line. this is one HUGE annoyance about RIM's solution that i hate - it may purge the files (most of them), but it does nothing for the folders it leaves.
__________________
In the beginning the Universe was created. This has made a lot of people very angry and is widely regarded as a bad move.

Last edited by jibi : 04-08-2008 at 07:53 PM.
Offline  
Old 04-08-2008, 08:48 PM   #10 (permalink)
Thumbs Must Hurt
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: Telstra
Posts: 55
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

hdawg you are good...

though i ended up writing a simple c# service that reads a config file, backs up the BES Database and zip's it up, zips all the Domino State Databases, Zip's up the logs and uploads them to the san to be backuped...

cant trust the Windows Scheduler...
__________________
Pearl 4.2.1.101 - Telstra Australia
BES 4.1.5 Domino 7.0.3.1 (with issues)
Offline  
Old 04-23-2008, 09:08 AM   #11 (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

updated to support deletion of files with certain age ... enjoy.
Offline  
Old 10-07-2008, 10:16 AM   #12 (permalink)
Talking BlackBerry Encyclopedia
 
hayabusa's Avatar
 
Join Date: Aug 2006
Location: Kansas
Model: 9000
Carrier: Cingular
Posts: 251
Post Thanks: 0
Thanked 0 Times in 0 Posts
Cool Do you still have this script it doesn't seem to be on the forum anymore

I'm not seeing an attachment anymore and I am needing a way to delete log files after a certain period
Offline  
Old 10-07-2008, 11:13 AM   #13 (permalink)
BlackBerry Elite
 
knottyrope's Avatar
 
Join Date: Jan 2008
Location: Massachusetts
Model: Z30
OS: 10.2.1
PIN: t of blood has been taken
Carrier: AT&T-US with I dee ten tee errors
Posts: 6,643
Post Thanks: 264
Thanked 269 Times in 255 Posts
Default

This looks like a lot like this post and the download links work.

BlackBerry Support Community Forums - Script to zip BES Log files - BlackBerry® Enterprise Solution - BlackBerry Support Community Forums
__________________
irony : many old timer posters have de-evolved into the trolls they once fought
I am on http://supportforums.blackberry.com
BES 10 running sweet for my Z30, Z10 and Q10
Online  
Old 10-08-2008, 11:45 AM   #14 (permalink)
Thumbs Must Hurt
 
m4ilm4n's Avatar
 
Join Date: Oct 2006
Location: Loony bin
Model: 8800
Carrier: T-Mobile
Posts: 111
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

That's precisely what I was looking for - a method to traverse the log directories; it only took two hours to zip up our two years worth of log files.

Thanks!!!!
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.