Monday, July 6, 2009

Auto rename Upgrade.log [SPS 2003-MOSS 2007 Upgrading] (Developer)

If you are planning for in upgrading your SharePoint 2003, you are probably first trying to give it shot in the test or development environment. That would lead to running several test upgrade trials until you perfect your upgrade. Every time you perform your upgrade, MOSS 2007 will generate the Upgrade.log (under the 12\Logs hive).

Every subsequent Upgrade activities will use the same Upgrade.log and will continue to append the log to the same Upgrade.log. Apart from upgrade jobs, the same Upgrade.log is also used by activities such as the initial steps used by upgrade configuration “Set target web application” , installation of hot fixes and Service Packs which are observed by the MOSS as an Upgrade job.

This will lead to a bloated Upgrade.log file (depending on your upgrading content log can vary) which would be much heavier for slow for the Notepad.exe (default) to load and do a quick check.

In order to simplify, I ended up writing a simple batch script that would rename the Upgrade.log file to something else ( I used appending date and time to the file name). There by after every unit of test I did I would simply run my RenameUpgradeLog.bat script. This would give me an empty Upgrade.log. Remember, you will need an existing Upgrade.log file for the Upgrade job kick in, otherwise you will see the appropriate error.

Anyway, here is the script I have used, you can paste the below text and make up your own filename renaming script.

:: ------------------------------------------
:: Author : Rajesh Agadi
:: Date Version Update
:: 2/25/2008 1
:: -----------------------------------------
ECHO ">>>Begin Script Rename Upgrade Log"

SET WSS12Hivepath=C:\Program Files\Common Files\Microsoft Shared\web server extensions\12

::----------------------Get Current date time for filename-------------
for /f "tokens=1,2" %%u in ('date /t') do set d=%%v
for /f "tokens=1" %%u in ('time /t') do set t=%%u
if "%t:~1,1%"==":" set t=0%t%
set timestr=%d:~0,2%-%d:~3,2%-%d:~6,4%-%t:~0,2%-%t:~3,2%
::---------------------Rename old Update.log--------------------------------
ECHO "Renaming Upgrade.log to >>Upgrade-%timestr%.log<<..."
COPY "%WSS12Hivepath%\LOGS\Upgrade.log" "%WSS12Hivepath%\LOGS\Upgrade-%timestr%.log"
ECHO > "%WSS12Hivepath%\LOGS\Upgrade.log"

ECHO "<<<END Script Rename Upgrade Log"

No comments: