Thoughts on the World

Using Volume Shadowing with Ntbackup Under Vista

The brain-dead backup function under Vista is enormously annoying, but fortunately you can easily get the trusty old ntbackup program running. See this excellent article on the Petri IT knowledgebase for details.

However, this basic solution has two major limitations:

I think I've found a solution to the latter problem, and possibly the first one as well.

To enable volume shadowing you'll need a copy of the VShadow tool, which is part of the free Microsoft VSS (Volume Shadow Copy) SDK. You'll also need a copy of the little utility dosenv.exe, which comes as part of various SDKs, or which can be downloaded directly from various utility websites. I learned about both of these from another excellent site, the Antimail Blog.

The solution is to wrap ntbackup in a pair of command scripts. The first, master script first invokes the system restore utility so you can optionally write a system restore point to disk (in lieu of a proper system state option). It then just invokes Vshadow to create the shadow copies, writes a set of environment variables describing them to a temporary script, and passes control to an inner script. The shadows only persist while this inner script is running, and are then torn down:

REM Backup script to set volume shadow copy for
REM ntbackup under Vista

REM First Create a dedicated system restore point
C:\Windows\System32\rstrui.exe

REM The following creates the volume shadows, and
REM passes control to BackupScript2.cmd.
REM This exits when that does.
"C:\Program Files\Microsoft\VSSSDK72\Tools\VSSReports\vshadow.exe" -script=backupenv.cmd -exec=BackupScript2.cmd C: F:

The second script first runs the temporary script to set environment variables describing the shadows. It then uses dosdev to map these to drive letters, and then passes control to ntbackup. When the backup is complete it does a bit of tidying up, then exits:

REM Backup script to use volume shadow copy with
REM ntbackup under Vista
REM Called by BackupScript.cmd, which creates the
REM shadow copy

REM This creates the environment variables with the shadow details
call backupenv.cmd

REM Now Map the DOS drives
dosdev Y: %SHADOW_DEVICE_1%
dosdev Z: %SHADOW_DEVICE_2%

REM Run the backup(s)
ntbackup

REM Tidy up
dosdev -r -d Y: %SHADOW_DEVICE_1%
dosdev -r -d Z: %SHADOW_DEVICE_2%

You use the volume shadows by backing up the mapped drives, not the original ones - you still need to "disable" volume shadowing in the ntbackup user interface.

There are a couple of weaknesses with this, and I'd welcome any suggestions for improvement:

  1. This works well with some files, e.g. SQL/Server databases, but not others, e.g. Google Desktop's indexes.
  2. The backup reports permission problems on some files, whereas there's no problem with the equivalent files on the master disk.
  3. You still need to manually "disable" volume shadowing in ntabckup.
  4. You can backup the "system state" by making sure you include the latest files in the System Volume Information folder on each drive. However, it's not clear whether you can then effectively restore the whole system state by restoring these from the backup.

Any ideas?

Comments

If you'd like to comment on this article, with ideas, examples, or just to praise it to the skies then I'd love to hear from you.

Comment on this article

Please share: All Addthis servicesTweet thisFacebook thisLink thisYam thisShare on Google