4

There's plenty of documentation on btrfs CoW, ZFS deduplication, and whatnot, but theoretically NTFS also has a CoW feature that Windows uses to give you the "previous versions" feature among other things.

I'd like to know how to use this feature manually: Take a folder (full of multi-gigabyte binary files), make something that acts like a copy but is created in a fraction of the time and uses negligible extra space initially, then modify/delete/rename/etc. files in the original folder without affecting the contents of the other (but I fully expect that this will require extra storage) just like if it was a full copy, then eventually delete one of these.

This is not to replace backups, version control, or anything like that, those are dealt with separately so please don't suggest those.

1
  • 1
    Take a look in to the vssadmin tool microsoft provides, it lets you interact with the volume shadow service (the vss in vssadmin) and you may find the tooling you need, but do note the tools are for the whole volume, I don't think it can just do a folder. If you do figure out how be sure to come back here and post a answer and mark it accepted. Dec 22, 2019 at 16:20

2 Answers 2

4

Shadow Copy on Windows works per-volume, because it operates at the block level of the disk/volume. It saves blocks that are changed in the volume, so doesn't distinguish between folders, the Master File Table (where folders and files are defined), or just plain file data.

This is a brute-force solution to disk snapshots that works on the physical disk level. It does not relate at all to the logical level where exist folders and files. Therefore, the question of making it work on a single folder is meaningless in view of its physical-level implementation.

The only way Shadow Copy can apply to a single folder, is if that folder is also a disk/volume.

Windows allows to Mount a drive in a folder. This is done from the Disk Manager, where you may assign a disk to an empty folder, by right-clicking the partition/volume with the folder, click "Change Drive Letter and Paths" and then click "Add" followed by "Mount in the following empty NTFS folder". This is also possible using diskpart.

Instead of a real disk/partition, it might be possible to use a mounted VHD/VHDX file that behaves exactly the same as a physical disk. For more details, see the article How to Mount or Unmount VHD and VHDX File in Windows 10.

2
+50

Shadow Copies don't really work in the way you'd like them to.

First of all, VSS shapshots are for the entire volume. You can't really "make something that acts like a copy" of a folder. Shapshots are also read only, so you can't go about making changes to the folders. Finally, you aren't the only one managing the lifetimes of the snapshots, so something else could come along and delete your snapshots out from under you.

All of that said, if you can find a way to live within all of those constraints, you could probably find a way to get fairly close with information from Making and mounting Vss snapshots in Windows Server 2008:

To make a copy of the (C:) volume:

C:\> vssadmin create shadow /for=c:

To view copies of the (C:) volume:

C:\> vssadmin list shadows /for=c:

To mount a shadow copy as a browseable folder:

C:\>mklink /d <folder name> <shadow copy volume from list>
C:\>mklink /d C:\mycopy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy6

vssadmin create shadow doesn't work on my Windows 10 (Pro 20H2) installation, but you should be able to do something similar with wmic shadowcopy.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .