High-end databases have long supported the idea of the transaction,
a collection of data modifications—inserts, deletions, updates, and so
on—treated as a unit, meaning that either all 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
data—it could be a system crash, a program crash, an overwrite of an
important file, or even just imprudent edits to a file—Vista 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
creating the shadow copy, Vista uses transactional NTFS to intercept
all calls to the file system. 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 that 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 creation of the associated shadow copy 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 miss-edit 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. Figure 1 shows the Previous Versions tab for a volume, whereas Figure 2 shows the Previous Versions tab for a file.
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 that you want to
restore all of the object. By making a
copy, you can restore just part of the object (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.