Saturday, February 6, 2010

Backup outlook using Volume Shadow Copy

Shadow Copy (a.k.a Volume Snapshot Service or VSS for short), is a Windows feature that can access files even when they are locked. It has many great uses, and this time I want to talk about backing up outlook. When outlook is running, it locks the PST files it uses, making them impossible to backup. One workaround is to close outlook before the backup, but that has several disadvantages, and may be hard to automate. Many backup utilities use shadow copy to help, but what if you don’t want to spend money? As usual, I’m here to help.

To use Shadow Copy, you would need a little utility called VSHADOW. I wish I could offer it as a direct download from here, but unfortunately, you’ll have to download the Windows SDK for that. It’s quite a hefty download – an ISO image that is over 1 GB long and takes FOREVER to install. Once you’re done with that, go to c:\program files\Microsoft SDKs\Windows\v6.1\Bin\vsstools and find VSHADOW.EXE there. It would be a 226K file – run it once to make sure it displays the right version – 3.0:

clip_image002

Copy this file to somewhere safe, and you may now uninstall the SDK to save on some disk space (approx 1.3 GB to be exact). If you had some virtual machine to do this install on, even better.

To actually make a backup, you need to perform 4 steps:

1. Use Vshadow to create a “snapshot” – this captures a drive the way it is at a certain point of time.

2. Mount the snapshot as another drive

3. Copy the files from the newly mounted drive to somewhere else (the backup destination).

4. Erase the snapshot.

Erasing the snapshot at the end is not really critical – you can leave it there for eternity, but since it’s frozen in time, there isn’t much point in making another backup from it in the future. You can mount multiple snapshots, but you’ll run out of drive-letters pretty fast.

To be more technical, here’s what you do:

1. Open a CMD prompt, which must have Administrative privileges.

2. Go to where you saved VSHADOW.EXE, and run the following command. If the files you want to backup are on a drive other than C, substitute it’s letter with c:

Vshadow –nw –p c:

3. On the output of this command, note the line that says SNAPSHOT ID:

clip_image004

If you get an error message like “Access denied”, that means you are not an administrator, or that you have ran your CMD not as an administrator.

4. Run the following command to map the drive letter, using the proper snapshot ID. You can use any letter you want, if J is already in use:

vshadow.exe -el={57b7248c-e086-46fc-848d-f449fb4c0ae3},j:

5. Now, use your favorite file copy method to copy any files you want from that temporary drive to anywhere else. I use ROBOCOPY and copy to my external USB drive, but you can do anything you want, really.

6. Once done with the file copy, use this command to un-mount the temporary drive and delete the snapshot. This does NOT do anything to the original files – just gets rid of the shadow copy and frees up the drive letter and system resources. Note that we are using the same snapshot ID as before:

vshadow.exe -ds={57b7248c-e086-46fc-848d-f449fb4c0ae3}

7. That’s it! Now you are ready to do this again tomorrow.

As you may or may not know, I don’t like to do so many things manually, so I wrote a VBScript to do the same as above, automatically. I use the WScript.Shell object and its RUN method to execute the various commands, and VBScript’s INSTR to find the snapshot ID. Other than that, the script is pretty straightforward:

'Create the Objects

set oWshell = CreateObject("WScript.Shell")

set oFSO = CreateObject("Scripting.FileSystemObject")

'Create the snapshot

oWshell.run "%COMSPEC% /C c:\vshadow -nw -p d: >c:\vshadow.txt", 0, TRUE

'Read the output and find the Snapshot ID

set oFile = oFSO.openTextFile("c:\vshadow.txt", 1, TRUE)

sOutput=oFile.readall

oFile.close

sSnapshotID=mid(sOutput,instr(sOutput,"SNAPSHOT ID")+14,38)

'Mount the Drive

wshell.run "%COMSPEC% /C c:\vshadow -el=" & sSnapshotID & ",j:", 0, TRUE

'Copy the files. Note that I'm using double-quotes because the path has a space in it

wshell.run "%COMSPEC% /C c:\Robocopy ""j:\My Documents"" ""x:\My Documents"" *.pst", 0, TRUE

'Destroy the snapshot

wshell.run "%COMSPEC% /C c:\vshadow -ds=" & sSnapshotID, 0, TRUE

You may adjust the script for different drive letters and folders. That’s it! Now, just use the Windows Task Scheduler to run this daily, and you’re done!

Saturday, January 16, 2010

Pick it up

A few months ago, I discussed a technique to fix LCD monitors, but since then I received a lot of questions with regards to how to actually OPEN the LCD’s plastic casing. Unfortunately, the front and back plastic shells are usually attached using snap-locking plastic notches, and these can be very hard to open. Here are two techniques that you can use to open such cases.

The basic technique is to simple use force – the plastic notches will come undone if you apply enough force to them, although some of them might break. Before going there, remove any screws that are in place, and inspect the back well to make sure there are no screws hiding under a warrenty sticker, or under the monitor’s leg. Then, place the screen on a table with the screen itself pointing upward, and the “top” of the screen facing you.

With your fingertips (of both hands), grab the plastic panel of the top part and try to slide your fingers underneath it, while pulling towards you. There will be resistance, often significant one, but with enough force, the frame will open. The hard part is to find the right balance so as to not break the LCD panel, so you might want to practice on a screen that you care less about. If you are not an experienced guitarist, expect some finger pain after this process.

Once the top comes open, slide your fingers a bit more inwards, and then slide them sideways towards the corners, still applying force, to open the notches that are in the corner, and then keep sliding along the sides towards the bottom of the screen. A typical screen has about 10-15 clasps along the frame, and they will snap open one by one. The snaps that are along the bottom part of the frame should be the easiest to open, as you should have most of the frame loose by now, and can apply a lot of leverage easily. Note that the monitor’s button panel is usually part of the front-frame, and wired to the main body, so be careful not to rip these wires or panel off when you open the panel. Most monitors’ internal body is separate from the plastic frame, and once you pop it open, the main body will come out easily, but be careful still – in some cases, the main body is connected with screws to the front or back frame, and you need to be careful not to break those.

If applying force, as described in paragraph 3 does not work, or you are very concerned about keeping the monitor in pristine condition, another technique is to pry the snaps open with a wedge. The problem is that the frame is usually soft plastic, so if you apply a screwdriver to it, it will cause very ugly damage. The right way to do it is use a plastic wedge. I recommend using a thick guitar pick – get a bunch of them – at least 3, and don’t get the expensive kind. This procedure might destroy them.

Take one pick, and push it between the front and back frame as much as you can, about 1 inch to the left or right of the middle of the frame (the middle point itself would probably have a snap, so you can push anything in there). The pick will separate the frames a bit, so now you can push another one next to it. Now, slide the 2nd pick sideways towards the corner, and the pressure will pop-open the snaps without causing any damage. You might have to experiment with several picks until you find ideal ones – some might be too soft to force the screen open, and others might be too thick to easily insert between the panels.