Friday, September 16, 2011

[Windows Backup] Fails with Error code 0x81000031

As you know I care a lot about my data (and trust me, everyone should Sorriso)…so much I setup a backup plan with the internal Windows 7 Tool called “Backup and Restore”.

Setting up this tool is easy, just follow the wizard by calling choosing “Backup and Restore” thru the Start menu.

Back to my issue with this fundamental tools, I had the Backup running smoothly for weeks… one day I say an Alert from Windows Action Center communicating to me the last backup failed Sorpresawith the Error mentioned in the tile “Error 0x81000031”.

I’ve been wandering around the issue for month, trust me, without resolving the whole problem (even by reading the Knowledge base KB 975692).

Finally, one day (today) I decided I have to have the Backup system running at every cost: I read almost all the Microsoft Forum threads about this same problem and, just in one, I found mentioned the possibility to have one or more Libraries (Computer => Libraries) with a non-existent folder included.

Solution

Finally, I found at least THREE of my Libraries with external references to folders of an external drive I don’t use anymore.

Screenshot Backup Error

In order to solve (in my case), I right-clicked on each Library (e.g. Music, Documents, Pictures and so on), and I checked that all folders were existent; eventually, I removed them by clicking on the “Remove” button.

Thursday, August 12, 2010

How to import IIS Logs in SQLServer [Part 2]

In the first part of this two-part-tutorial, we learned how to import a SINGLE IIS Log File into
a SQLServer Table without having to worry about the creation of the table.

In the real-world-scenario, you can face with multiple Web Sites (from a Web Farm) and importing
multiple logs one by one could be a boring work.

Why don’t we let the Computer doing that ?

Step 1. Creating Script to import multiple Logs

As first step, my idea is to write a “simple” script (in VBScript) to let cycle thru a specified
physical directory (normally C:\Windows\system32\Logs\W3SVC1) and running the command I’ve explained
in the first part.

After each “import” step, we can choose to delete the file if there NOT errors.

   1: Option Explicit
   2:  
   3: Call Main()
   4:  
   5: Sub Main()
   6:  
   7:     Dim cmdArgs, logFiles, logFile, logFolder, fso, isImported
   8:     Dim currentLogFileName, currentExtension, fullLogFilePath
   9:     Dim allowedExtension
  10:     
  11:     allowedExtension = "log"    
  12:     
  13:     Set cmdArgs = WScript.Arguments
  14:     logFolder = cmdArgs(0)
  15:     
  16:     Set fso = CreateObject("Scripting.FileSystemObject")
  17:     
  18:     If Not IsNull(logFolder) Then
  19:         If Not IsEmpty(logFolder) Then                        
  20:             
  21:             Set logFiles = GetFiles(logFolder)
  22:             
  23:             currentLogFileName = GetCurrentLogFile()
  24:             currentLogFileName = GetFullPath(logFolder, currentLogFileName)
  25:  
  26:             WScript.Echo "Current Log File " + currentLogFileName
  27:             
  28:             For Each logFile in logFiles
  29:                 
  30:                 fullLogFilePath = logFile 'GetFullPath(logFolder, logFile)
  31:             
  32:                 WScript.Echo "Analyzing File Name: " + logFile + vbCrLf
  33:                 
  34:                 currentExtension = Right(logFile,3)
  35:             
  36:                 If currentLogFileName <> logFile And currentExtension=allowedExtension Then
  37:                                     
  38:                 
  39:                     isImported = RunLogParser(fullLogFilePath)
  40:                     
  41:                     If IsImported Then
  42:                     
  43:                         DeleteFile(fullLogFilePath)
  44:                         
  45:                     End If
  46:                 End If
  47:             
  48:             Next
  49:             
  50:             
  51:         End If
  52:     End If
  53:     
  54:     Set fso = Nothing
  55:  
  56: End Sub
  57:  
  58: Function GetFullPath(folderPath, fileName)
  59:  
  60:     If Right(folderPath,1) <> "\" Then
  61:         
  62:         folderPath = folderPath + "\"
  63:     
  64:     End If
  65:     
  66:     GetFullPath = folderPath + fileName
  67:  
  68: End Function
  69:  
  70: Function GetFiles(strFolder) 
  71:     Dim fso, fld 
  72:       Set fso = CreateObject("Scripting.FileSystemObject")
  73:       Set fld = fso.GetFolder(strFolder)
  74:       Set GetFiles = fld.Files
  75:     Set fso = Nothing
  76:     Set fld = Nothing
  77: End Function
  78:  
  79: Function DeleteFile(strFileName)
  80:     Dim fso, fil 
  81:     Set fso = CreateObject("Scripting.FileSystemObject")
  82:       Set fil = fso.getfile(strFileName)
  83:       fil.Attributes = 0
  84:       fil.Delete
  85:     Set fil = Nothing
  86:     Set fso = Nothing
  87: End Function
  88:  
  89: Function GetCurrentLogFile()
  90:  
  91:     Dim currentDate, currentYear, currentMonth, currentDay, currentLogFileName
  92:     
  93:     currentDate = Now()
  94:     
  95:     currentYear = Right(CStr(Year(currentDate)),2)
  96:     currentMonth = CStr(Month(currentDate))
  97:     If Month(currentDate) < 10 Then
  98:         currentMonth = "0" & currentMonth        
  99:     End If
 100:     'currentMonth = Month(currentDate)
 101:     currentDay = CStr(Day(currentDate))
 102:     If Day(currentDate) < 10 Then
 103:         currentDay = "0" & currentDay
 104:     End If    
 105:     
 106:     currentLogFileName = "ex" + currentYear + currentMonth + currentDay + ".log"
 107:     
 108:     GetCurrentLogFile = currentLogFileName
 109:     
 110:  
 111: End Function
 112:  
 113: Function RunLogParser(logFile)
 114:  
 115:     Dim oShell, iRC, ShellString
 116:  
 117:     WScript.Echo "Importing File " + logFile + vbCrLf
 118:     
 119:     ShellString = """C:\Program Files\Log Parser 2.2\LogParser.exe"" ""SELECT * INTO IISLogs FROM " + logFile + """ " + " -i:W3C -o:SQL -server:DEV-S04 -database:Logs -driver:""SQL Server"" -username:euclidlogs -password:euclidlogspassword -createTable:OFF "
 120:  
 121:     'WScript.Echo vbTab + "Shell String " + ShellString + vbCrLf
 122:     
 123:     Set oShell =  WScript.CreateObject("WScript.Shell")
 124:     
 125:     iRC = oShell.Run(Shellstring, 1, True)        
 126:     
 127:     RunLogParser = (iRC=0)
 128:     'RunLogParser = False
 129: End Function

Moreover, the script filters for all files with a given file extensions (“.log” in my case).

Step 2. Calling the VBScript script from a Batch one

In order to let it schedule easily (in case you need to Archive / Cycle the logs) from the Windows Task Scheduler,
you can put the call in a simple batch script as below:

   1: @echo off
   2:  
   3: pushd "C:\AdminScripts\Maintenance Scripts"
   4:  
   5: cscript IISLogImporter.vbs C:\WINDOWS\system32\LogFiles\W3SVC1\
   6:  
   7: popd

Conclusions:

A production Web / Web Farm generates Gigabytes of Logs over the time and they’re useless if you can’t analyze them.

Moreover, Web Servers’ disk space is not infinite so you need to archive such logs; what’s better than a Database server ?

Logging DIRECTLY into the Database (from IIS) could lead to a slowdown of the whole set of hosted applications.

The scripts above will help you to do so once every few weeks or every day.

Tuesday, July 27, 2010

How to import IIS Logs in SQLServer [Part 1]

Often, especially in a Web Farm, we have more than a Web Server (with IIS) and we need to analyze its logs in a quicker and simpler way than
importing them manually in an Excel Sheet.

The solution comes from Microsoft (as usual) with a tool made to manipulate IIS Logs: Log Parser (version 2.2 at the time I’m writing).

Log Parser is a command-line tool with multi-source / multi-target log parsers; the flexibility of the tool has to be paid with a complex syntax.

In my daily job I had the need of importing IIS Logs into a SQLServer Db for analyzing it: here’s the command line I used to accomplish the task.

"C:\Program Files\Log Parser 2.2\LogParser.exe" "SELECT * INTO IISLogs FROM ex20100726.log -i:W3C -o:SQL -server:DB01 -database:Logs -driver:"SQL Server" -username:DbUser -password:DbPassword -createTable:ON

Naturally, the command HAS TO BE customized with:

  • File Name of the Log File from the IIS Server [ex20100726.log in my example]
  • Database coordinates (Server Name, Db Name,Login, Password) [DB01, Logs, DbUser, DbPassword in my example]
  • Table [IISLogs in my case]

Be aware of the parameter createTable:ON that will create a table with the schema needed to import the Log.

In case you need to import Logs with different columns (e.g. you needed to have the Time Taken field later than
production day), as my personal suggestion, do it in different tables.

In the next part of the micro-series, I’ll explain how to do a simple script to import (and eventually delete) multiple files thru
Log Parser.

Wednesday, January 6, 2010

New Year, New IT Resolutions ?

Here we are, a new year is on and we all need to set new resolutions as usual.

The ones I’m sharing with you are regarding my next “steps” in improving my home AND my professional computing life.

Let’s start with Home Computing Resolutions:

  • Buy a new personal notebook to let me “Play” with code.
    Normally I don’t use the Work PC to play with my “experiments” and my current desktop is too old to virtualize as much as I want.
    Now the question is: Which brand should I choose ?
  • Improve my contribution to DotDotNet Computer Club. Recently I missed some workshops and I didn’t give them the help they needed.
  • Migrate the current Desktop PC to be a Windows Home Server.
    It’ll share all my photos, music (eventually as iTunes Server) and video. My hope is also to make it a central backup machine for my wife’s (and my) notebook.
    All my 1TB disks will be shared as a single one thanks to the feature from Windows Home Server.
  • Buy a new Notebook for my wife: Will it be the right year to convince her that a 7-year-old (now 8) notebook is OLD ? :-)
  • Improve my working station – office thru new chairs (actually we’re using improper chairs) and a new central light.
  • Improve my “relax station” (A.K.A. family room) with:
    - A new TV set: probably my new one will be kind a 37” or 40”, Internet Access, Full LED…we’ll see
    - A new HiFi Set : here I don’t know where I should start from. It’s a completely new world.
  • Last but not least, Reorganize and decide what my blogging life will be :-).
    Actually I’ve 3 blogs around, some in Italian, this one in English.
    I’m paying moneys for domains and hosting I actually don’t use.
    By now, I’m more convinced I’ll continue to blog here (in English) and keep just the domain name, giving away the hosting plan and all the other domains I’ve.
    What do you suggest?

Regarding my professional IT Resolutions, probably my boss could be happy to know that I’ll (try to)

  • Study for a Certification: I don’t really know if it’s better to follow the path I’ve been put on (IT Pro Track) or switch to the world I love most (Development and Architectures).
    For sure the Virtualization World is the Track I currently like most … but it’s not excluded my DEV part will come up again claiming to study for the new .NET Framework (4.0) stuff :-).
  • Well, even it’s not “strictly” IT-related, I hope to be more polite with my colleagues.

Well, there are a lot of topics and arguments I can start from for my next posts.

What are your IT (and non-IT) Resolutions ?

Wednesday, November 11, 2009

Enlist and export installed HotFix on Windows (7)

Sometimes we need to be sure ALL servers (production ones, by example) are aligned from HotFix point of view; sometimes we are in doubt production servers and Integration ones are NOT aligned with service packs and hotfixes.

Here's a small script (you can run from the Command Line), to generate a .csv file with all information regarding installed HotFix.

wmic qfe list full /format:csv /output:c:\temp\qfe.csv


NOTE:
Windows 7 has a bug with the (some) /format command switch. 
The command above DOES NOT WORK giving the following error : “Invalid XSL format (or) file name.

The following command is a workaround on Windows 7 PCs.

wmic qfe list /format:table >C:\temp\hotfixes.txt

 

Hope this will help managing your Infrastructure.

Tuesday, November 3, 2009

[POLL] What is your Techno wish-list to Santa Claus ?

Christmas is approaching … just less than 2 months to the ever-desired holiday time of the year.

saccoo

As a geek, I Imagine what a “techno-Santa Claus” can bring to me (because I’ve been a good boy ).

What is the (one or more) techno-gadget you’re requesting in the letter (email ? :)) to Santa ?

Here’s my wish-list (sorted by importance):

  1. A Brand new Notebook Dell Studio 15 with Core i7 CPU (unfortunately has been temporarily removed from pricelists)
  2. Yes…I’d like to be a “different one” : iPhone 3GS 16GiB (16GiB is enough for everyone)
  3. A Digital PVR (Personal Video Recorder) capable of recording (digital) TV Shows and reproducing streamed media from my next-to-come Windows Home Server

By now I don’t have other items in the Santa wish-list … Tell me what is yours.

Thursday, October 8, 2009

VMWare Player 3.0 RC … Impressive

vmware Just after the news sent me from my friend Alberto, I started digging’ out to find the “Download Page” for the Public Beta
of VMWare Player 3.0 .

The great news was the possibility to CREATE NEW Virtual Machines instead of “Just Playing” them.

I’ve been always a fan of VMWare but it IS quite expensive for someone wants to use it “at Home” : finally I switched to Virtual PC from Microsoft.

Lastly, I’ve been almost obliged to install the latest Player (2.5.3) to run a VM on my Company’s Notebook: I was impressed on how the VM was running really smoothly

In the meanwhile, the 3.0 Release Candidate went out and … what a wonderful surprise: I can even CREATE VMs smile_regular .

After the download and the installation, I started by creating a new Virtual Machine with WindowsXP SP3 (just for compatibility reason): on my home PC with a "simple”
Athlon64 3500+ and 2 Gig of RAM, it ran very very smoothly.

It seems the CPU was running JUST one O.S. instead of 2 (the host one is Windows 7 Ultimate RC).

Just before shutting everything down, I checked the Player Log : It WAS NOT using the Hardware Acceleration; it stated my CPU (or any other component?) were not
completely compliant .

I’m just investigating about it … and probably it is a bug will be fixed in the final release.

Finally, I’ll adopt it to create my own VMs for development (and fun) purposes .