Dienstag, 28. Juni 2011

Using Shadow Copy to back up folders in Windows 7

It is always a good idea to keep backups of your stuff. Unfortunately, some folders like %APPDATA% can not be copied while Windows has locked files inside. That's where the Volume Shadow Copy Service (VSS) comes into play. It basically creates a consistent snapshot of the data and allows to access it regardless of file locks. I wrote a small batch script for Windows 7 that does the following:

  1. Create snapshot of folder
  2. Mirror the folder to another place
  3. Destroy snapshot

The script relies on three tools, only one of which ships with the vanilla Windows 7 installation. These are the dependencies:

You can download the batch file below. It creates a backup of your own user's %APPDATA% folder (C:\Users\USERNAME\AppData\Roaming) to the target folder D:\Backup\AppData. The script needs to run as Administrator in order to create snapshots.

Download: backup_appdata.cmd