Friday, June 12, 2015

Volume Shadow Copies and PowerShell

I manage a number of files servers, each of which has a number of volumes that have user data on them.  In addition to conventional backup and recovery procedures, I also enable Volume Shadow Copies, so that the end users or the service desk can perform trivial file restores without escalating a ticket to the backup and recovery (of which I am a member!).  The size of the data volumes vary, as does the level of activity on each.  Plus, to throw in one more variable, some of the volumes contain files that are, individually, very large, digital videos, for example.

The management interface for shadow copies lets you select the drive on which shadow copies are stored, the "on" parameter in vssadmin, and how much of that drive to use for protected volume, ether as a percentage of the or as an absolute number of mega-, giga-, terabytes.

Once enabled, and let's assume for the moment that we're using the default schedule, VSS collects a point-in-time snapshot twice a day at 7am and noon.  What I have found, in my environment, is that you can still end up with different numbers of copies being retained for each protected volume.  From a customer service perspective I think I should provide the same number of copies, or put another way the same 'depth' of history.

So with this in mind I set out to come up with a way to determine the NUMBER of shadow copies that are being held for each volume on a given server.

I started with knowing that I could get a list of the shadow copies on a server with

Get-WMIObject Win32_ShadowCopy

But if you look at the data for one shadow copy you can see that it identifies the volume with a UID path in the property "VolumeName"

VolumeName         : \\?\Volume{220a4c15-1da3-4c12-8992-e7ff6b68a1e3}\

PS C:\Windows\system32> $shad = (Get-WmiObject win32_shadowcopy)[0]
PS C:\Windows\system32> $shad


__GENUS            : 2
__CLASS            : Win32_ShadowCopy
__SUPERCLASS       : CIM_LogicalElement
__DYNASTY          : CIM_ManagedSystemElement
__RELPATH          : Win32_ShadowCopy.ID="{8D75F263-A3D7-4AC3-AB51-1A0178D42552}"
__PROPERTY_COUNT   : 28
__DERIVATION       : {CIM_LogicalElement, CIM_ManagedSystemElement}
__SERVER           : CAINFPW002
__NAMESPACE        : root\cimv2
__PATH             : \\CAINFPW002\root\cimv2:Win32_ShadowCopy.ID="{8D75F263-A3D7-4AC3-AB51-1A0178D42552}"
Caption            :
ClientAccessible   : True
Count              : 1
Description        :
DeviceObject       : \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy49
Differential       : True
ExposedLocally     : False
ExposedName        :
ExposedPath        :
ExposedRemotely    : False
HardwareAssisted   : False
ID                 : {8D75F263-A3D7-4AC3-AB51-1A0178D42552}
Imported           : False
InstallDate        : 20150501120034.213457-300
Name               :
NoAutoRelease      : True
NotSurfaced        : False
NoWriters          : True
OriginatingMachine : CAINFPW002.hcgg.fr.co.hennepin.mn.us
Persistent         : True
Plex               : False
ProviderID         : {B5946137-7B9F-4925-AF80-51ABD60B20D5}
ServiceMachine     : CAINFPW002.hcgg.fr.co.hennepin.mn.us
SetID              : {4EF826D1-D1CA-46AA-90D7-023041C8C80D}
State              : 12
Status             :
Transportable      : False
VolumeName         : \\?\Volume{220a4c15-1da3-4c12-8992-e7ff6b68a1e3}\
PSComputerName     : CAINFPW002

While consistent, that UID isn't very friendly.  Get-Volume will give us the linkage between drive letters and the UID, if we want it.
PS C:\Windows\system32> get-volume -DriveLetter C | fl


DriveLetter     : C
DriveType       : Fixed
FileSystem      : NTFS
FileSystemLabel : C Drive
HealthStatus    : Healthy
ObjectId        : \\?\Volume{8f79d014-b218-11e4-80c8-806e6f6e6963}\
Path            : \\?\Volume{8f79d014-b218-11e4-80c8-806e6f6e6963}\
Size            : 42580570112
SizeRemaining   : 18876383232
PSComputerName  : 
 Let's say for this discussion we do.  So let's stash that away for later reference.
 
$volumes = Get-Volume
And while we're at it, let's store the collection of ShadowCopy objects, too.
$shadows = gwmi win32_shadowcopy
So we want to count the number of shadow copies for each volume. For this exercise I decided to use calculated properties, but for a production script, I probably would create a custom object for the output.
$shadows `
    | select volumename,
             @{n="drive";e={$vol=$_.volumename;($volumes | where {$_.path -eq $vol}).DriveLetter}},
             @{n="Date";e={$_.converttodatetime($_.installdate)}} `
    | Group-Object -Property Drive

Count Name                      Group                                                                                                             
----- ----                      -----                                                                                                             
   61 Z                         {@{volumename=\\?\Volume{220a4c15-1da3-4c12-8992-e7ff6b68a1e3}\; drive=Z; Date=5/1/2015 12:00:34 PM}, @{volumen...
   10 Y                         {@{volumename=\\?\Volume{1b7da7ce-3b66-4534-9596-02f96c510df6}\; drive=Y; Date=6/8/2015 7:02:00 AM}, @{volumena...
   31 U                         {@{volumename=\\?\Volume{c12ffb10-8a6f-4041-b326-e0f0c8aa14b2}\; drive=U; Date=5/22/2015 12:01:00 PM}, @{volume...
    6 T                         {@{volumename=\\?\Volume{db23afab-ecce-11e4-80cc-005056b52c40}\; drive=T; Date=6/10/2015 7:03:00 AM}, @{volumen...
   11 V                         {@{volumename=\\?\Volume{86130522-ffe6-4254-8d86-589d508ea67b}\; drive=V; Date=6/5/2015 12:04:22 PM}, @{volumen...
    9 H                         {@{volumename=\\?\Volume{5f22f6d7-e882-11e4-80cc-005056b52c40}\; drive=H; Date=6/8/2015 12:05:37 PM}, @{volumen...
So you can see that in this case, the T and H volumes are only keeping 6 and 9 previous versions respectively. We can move on to look at the current storage settings. That's Up Next!

Friday, April 03, 2009

Nice little VBScript trick

To go from a path like this
D:\_pdf\a\b\c\foo.bar

to a path like this
D:\a\b\c\foo.bar

you can do this
sFile = "D:\_pdf\a\b\c\foo.bar"
sResult = Join(Split(sFile, "_pdf\",-1,1),"")

I just thought I'd share.

Wednesday, June 04, 2008

A half baked idea

I'm not talking about brownies in this case, though in many cases that's all the more cooking brownies need sometimes.

If I we're going to have some say in the design of a new amateur radio transceiver, I think I would do a few things that none of the manufacturers seem to be doing.
1) flash memory - I have a micro SD card from my GPS receiver that holds 2GB of data and cost under $30. 100 memory slots? I think not... how about a 1000 memory slots and memory to, say, record the last hour or so of communications...
2) XML based configuration - It doesn't take much computing power to parse or create an XML, so why not have the whole radio's configuration stored as an XML file. Watchguard firewalls use an XML based configuration, and they have at least as much to store, and arguable much complex combinations of data to store in the XML file
3) USB - Serial ports? Really? I don't disagree that there aren't reasons for a serial port on a radio, but why must we bound to a serial port for configuration.
4) Keypads - most radios these days have dtmf keypads, why not make them available for text input, for labeling the memory slots.

I doubt anyone is going to read this and a tiny fraction of those folks will be HAM radio operators, but if you are and you have a clue as to what I am talking about, leave a comment!

73

Sunday, March 16, 2008

Where do they get these guys from, anyway?

My wife and I had just finished dinner and were doing a little channel surfing the other night when we came across the new "game" show "Amnesia", a game show take on "This is your Life". The first contestant was a guy named Chris, we missed the opening of the show so we didn't catch his last name. Almost instantly I felt I had seen him somewhere else. At first I wrote it off to simply remembering him from the promos for the show, but as the show went on I became convinced that we had seen him on the fourth episode of Feasting on Asphalt with Alton Brown. We popped in the DVD and sure enough! Detective Chris Cognac. We don't have cable so we don't get to watch FoodTV very often, so I had no idea that Chris has been a judge on Iron Chef America, has his own show on FoodTV, and is a food columnist for a small newspaper in Los Angeles.

So all this brings up the question, is Amnesia going to be a game show for celebrities, or did they just get Chris for the first show because they could count on him for being a good showman?

Monday, December 17, 2007

Cider Update

Shame on me, I didn't post about the second batch of Cider I put up this fall. In addition to 5 gallons of fresh cider, I added 1 pound of crushed (squished is more like it) raisins and two pounds of Brown sugar. While the sugar impacted the OG reading, the raisins added a quantity of sugar that wasn't really measurable from the onset. However it bacame clear that the raisins added sugar because the must fermented vigorously for nearly two months. It has only just recently settled down and I will be racking it over to a secondary shortly. I will take a gravity reading on it again at that time, but expect that it will be at or below 1.000. I'll be tasting it too!

Big Moves

You've heard the old saying "big things come in little packages". I'd have hardly guessed how much stuff we could have managed to get into our little old house over the course of 7 years. It's just as well we only went a mile when we moved, as it was it took a 26 foot truck, two mini vans, two trailers (well one trailer twice), two cars and a 10x15 foot storage locker.

"Maybe you should get rid of some stuff!" I hear you say... Believe me, we had a pretty good purge before the move. In only just a couple of weeks, though, we've managed to fill 5 moving boxes full of stuff for the spring garage sale.

Gotta start thinking about how we accumulate "stuff"

Saturday, September 15, 2007

Cider 2007 - Day 1

This year's batch(es) of hard cider start today.

The first five gallons were purchased today at the Minneapolis Farmer's Market from Fireside Orchards. The fresh cider has a Specific Gravity of 1.051. It's a pretty simple process... I simply pour the cider into a carboy with a vial of Whilte Labs' #775 English Cider yeast, and stop it up with an airlock.

The plan is to let this go in the primary for about 4 weeks. Then when it is racked over to the secondary, and the yeast is all wiped out, I'll make up the difference of what is lost to sediment with some fresh, pasteurized apple cider. The cider has some of its own yeast, so it is pasteurized so the fermentation process doesn't take off again. All of the sugar in apple juice (cider) is fermentable, so we want to add some back to sweeten the end product.

I'll be back with updates!

Wednesday, June 06, 2007