I'm a big fan of being productive by not losing work. I don't care how optimized your system and development tools are; if you have to do work to get back to where you were at a half hour ago, you're going backwards. I've previously written about using TimeSnapper as screen recorder so I can retrace my steps to anything that's happened on my screen in the past month. TimeSnapper continues to be one of the first tools I install on a new system.
But there are some things that slip through the cracks. For instance, what happens if a file gets corrupted, or if I accidentally save some new modifications over an old file which was previously working? We've got the recycle bin for accidentally deleted files, but until now if a file was overwritten the original version was just gone.
That's when I turn to a sadly ignored but very cool feature in Windows Vista: Previous Versions (a.k.a. Shadow Copy). If you're running Vista Ultimate or Business editions, you've got Shadow Copy and can right click any file or folder to look for a previous version, as pictured below. Previous Versions is like an informal source control system for files you hadn't thought to back up.
Note: If you're running another version of Windows Vista that doesn't have Shadow Copy, don't lose heart - there are still ways to take advantage of this feature. We'll get to those in a bit.
So if an important file like applicationHost.config is corrupted, the first thing I do is check for a previous version. In the above case, I had 11 backup copies of the folder in three months, so it's likely that I could find a good copy. I could either just restore (the file or the entire folder) or I wanted to be a little more sure of things I could open or copy the files in question and compare them with the current version. It's easy to just make a copy of the folder at a point in time and merge it with the current version using a merge tool (e.g WinMerge).
Not Just For Klutzes
I'm often using Previous Versions to recover files I didn't personally overwrite. For example:
- My team was installing software on demo machines late at night before a conference when some application specific files got overwritten. We were looking at having to reinstall a lot of software, which would have taken an hour or more. I recommended that we check for a previous version of the folder. Sure enough, it was there, and we were back in business within two minutes.
- I rely on Firefox's session restore pretty heavily. I've had my session store get corrupted a few times over the past year. Each time, I've been able to recover it by restoring the following file: "C:\Users\[Username]\AppData\Roaming\Mozilla\Firefox\Profiles\[random].default\sessionstore.js"
- I make incorrect assumptions on what Visual Studio Team System will do with my files based on my background using Subversion. I think the basic problem is that I'll make changes to files outside of Visual Studio, so Team System doesn't know I've made changes and overwrites without prompting the next time I do a checkout. I think I've learned my lessons here, but there have been several times this past year that I've recovered overwritten changes by restoring a Previous Version
- Occasionally I'll shift-delete a bunch of files (shift-delete destroys the files immediately, bypassing the recycle bin), then realize I needed the file for some reason. Yeah, that's a klutz move. Previous Versions works there, too.
Hey, this sounds like System Restore
You're right! Previous Versions is related to System Restore since Windows uses the Volume Shadow copy service to create backups used by both System Restore and Previous Versions. System Restore is used for operating system specific files, while Previous Versions is used for everything else. System Restore was actually included in Windows ME, but don't hold that against it. System Restore is a great way to save a good computer gone bad.
I was first shown this when my wife's cousin and his friends - a bunch of college kids - stayed at our house a few years ago. I'd thoroughly borked our family's Media Center 2004 computer and was anticipating weeks of late nights trying to find stable drivers, when I came home from work to find the spring break kids watching TV. When I asked how they'd fixed the computer, they gave me the same look I probably give my parents when they lose e-mail attachments and said, "We just restored to a few days ago." Uh, right, I was planning to do that... Truth is, I'd bought the line the hipsters were selling me and had ignored System Restore. But in this case, it was exactly the right answer - rather than spend a week trying to manually restore my system to the way it had been the day before, they spent 10 minutes restoring the files and made it in time for Wapner.
What's Not To Like?
I've had discussions with friends who continue to dismiss the Previous Versions feature, and recommend turning it off. I don't think any of the arguments make sense, especially when you've lost a file you need. Here's a brief rundown on the pro's and con's:
Volume Shadow Copy performance impact
It's minimal, because it usually only runs when your machine is idle. System upgrades or software installation can request a restore point be created, which could take a few seconds. Bottom line - I haven't seen any facts behind the urban legend that Previous Versions or System Restore actually affect system performance in a negative way. I know that, like Raymond Chen, when I find the occasional use for them, they save me days of work. That seems like a pretty solid bet.
Volume Shadow Copy uses up disk space
By default, Vista uses 15% of the drive or 30% of the free space (whichever is less). That might be an issue if disk space wasn't so cheap as to be essentially free. But even if you're stuck on a small drive, you can modify the space Windows uses for System Restore with a simple registry tweak.
It's only included in Vista Business and Vista Ultimate
That's a bit of a a setback. Vista's got way too many versions, and if yours isn't Business or Ultimate, you've got a lousy deal in the Volume Shadow Copy area. That's because Vista still ships with the Volume Shadow Copy service enabled, but without a user interface to access it. So it's filling up 15% of your drive with files you can't access, which is less than optimal.
But we're not going to let a roadblock like that stop us, are we? Those files are there, and we're totally going to get them.
Option One - Shadow Explorer
Shadow Explorer is a free program which provides a user interface to your Previous Version files. It's not pretty, but we want our file pretty bad so we'll let it slide.
Option Two - Show the files in Explorer with two Console Commands
Probably the quickest solution is to use some command-line trickery to make the Volume Shadow copies show up in Explorer. Adi Oltean wrote a nice post on this a bit ago - I'll summarize the steps, but you should really read his post to understand what he's doing. While the actual commands may look a bit scary, it's actually incredibly easy. There are just three steps:
- From an elevated command prompt, run the following: vssadmin list shadows |more
- Find the shadow copy set with the creation date you want and copy the Shadow Copy Volume line from set, which should look like this: \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy10
- Create a symbolic to the the above path, with the following command (substituting in the correct info): mklink /d c:\shadowcopy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy10\
Pay attention to that last line! You've got to get the /d switch (to create a directory link) and you need to get that trailing backslash. But, you should be able to do the above three steps in about a minute, at which point you can browse through the shadow copy via command-line or the Windows Explorer.
This all works because the files were always stored on your hard drive, they just weren't visible because they weren't associated with a drive letter. Creating a symbolic link takes care of that. When you're done, just delete the folder in Explorer and the link is destroyed.
Option Three - Upgrade to Vista Business or Ultimate
You can use Vista Anytime Upgrade to upgrade to a version of Vista which includes the Previous Versions user interface. Remember that Vista's been making these file snapshots since you installed it, it just hasn't provided you a user interface to get to them. Upgrading will take care of that, and if you've got the budget or really need the files, it might be worth the $159 to $199 (depending on your current version) to just get to Ultimate.
There are three ways to look at this:
- How thoughtful of Vista to make shadow copies for me in all versions of Vista, so if I upgrade I'll have a backup history!
- Data recovery is a lame feature to use as an upsell - it should have been in all versions.
- This is "data blackmail" since someone who's lost a file is kind of being extorted into upgrading to get the files back.
Take your pick. I think I wind up on the second one - the Previous Versions UI should be in all versions. But again, this argument is academic when you've lost a file and want it back.