Shadow Copies and Transactional NTFS

High-end databases have long supported the idea of the transaction, a collection of data modificationsinserts, deletions, updates, and so ontreated as a unit, meaning that either all of the modifications occur or none of them does. For example, consider a finance database system that needs to perform a single chore: transfer a specified amount of money from one account to another. This involves two discrete steps (I'm simplifying here): debit one account by the specified amount and credit the other account for the same amount.

If the database system did not treat these two steps as a single transaction, you could run into problems. For example, if the system successfully debited the first account but for some reason was unable to credit the second account, the system would be left in an unbalanced state. By treating the two steps as a single transaction, the system does not commit any changes unless both steps occur successfully. If the credit to the second account fails, the transaction is rolled back to the beginning, meaning that the debit to the first account is reversed and the system reverts to a stable state.

What does all this have to do with the Vista file system? It's actually directly related because Vista implements an interesting new technology called Transactional NTFS, or TxF, for short. TxF applies the same transactional database ideas to the file system. Put simply, with TxF, if some mishap occurs to your datait could be a system crash, a program crash, an overwrite of an important file, or even just imprudent edits to a fileVista enables you to roll back the file to a previous version. It's kind of like System Restore, except that it works not for the entire system, but for individual files, folders, and volumes.

Windows Vista's capability to restore previous versions of files and folders comes from two new processes:

  • Each time you start your computer, Windows Vista creates a shadow copy of the volume in which Vista is stored. A shadow copy is essentially a snapshot of the volume's contents at a particular point in time.
  • After the shadow copy is created, Vista uses transactional NTFS to intercept all calls to the file system, and Vista maintains a meticulous log of those calls so that it knows exactly which files and folders in the volume have changed.

Together these processes enable Vista to store previous versions of files and folders, where a previous version is defined as a version of the object that changed after a shadow copy was created. For example, suppose you reboot your system three mornings in a row, and you make changes to a particular file each day. This means that you'll end up with three previous versions of the file: today's, yesterday's, and the day before yesterday's.

Reverting to a Previous Version of a Volume, Folder, or File

Windows Vista offers three different scenarios for using previous versions:

  • If a system crash occurs, you might end up with extensive damage to large sections of the volume. Assuming that you can start Windows Vista, you might then be able to recover your data by reverting to a previous version of the volume (although this means that you'll probably lose any new documents you created since then). Note, however, that this means that every file that changed since the associated shadow copy was created will be reverted to the previous version, so use this technique with some care.
  • If a system crash or program crash damages a folder, you might be able to recover that folder by reverting to a previous version.
  • If a system crash or program damages a file, or if you accidentally overwrite or misedit a file, you might be able to recover the file by reverting to a previous version.

To revert to a previous version, open the property sheet for the object you want to work with and then display the Previous Versions tab. Clicking a version activates the following three command buttons:

  • Open - Click this button to view the contents of the previous version of the volume or folder, or to open the previous version of the file. This is useful if you're not sure which previous version you need.
  • Copy - Click this button to make a copy of the previous version of the volume, folder, or file. This is useful if you're not sure you want to restore all of the object, so by making a copy you can restore just part of it (say, a few files from a volume or folder, or a section of a file).
  • Restore - Click this button to roll back changes made to the volume, folder, or file to the previous version.