finding Win7 junctions and rsync

Thanks to BigSmoke for informing me on Win7 junction points and how to skip them when using rsync (deltacopy)

Finding junction files in Windows 7 and exclude them with DeltaCopy

To identify junction files, run:

dir /AL /s

Here is an example exclude list for deltacopy for a standard windows 7 machine. Path names are specified assuming every user dir is supplied as separate dir to copy (because there are references to root, like ‘/Mijn documenten’:

--delete-excluded --exclude "/Application Data" --exclude "**/Downloads"
 --exclude "**/AppData/Local/Application Data" --exclude "/Local Settings"
 --exclude "**/Temporary Internet Files" --exclude "**/Flash Player"
 --exclude "**/Temp" --exclude "**/VirtualStore" --exclude "NTUSER.DAT*"
 --exclude "UsrClass.dat*" --exclude "ntuser.dat*" --exclude "parent.lock"
 --exclude "/Mijn documenten"  --exclude "/Mijn afbeeldingen"
 --exclude "/Mijn muziek" --exclude "/Mijn video's"

The ‘Mijn Documenten’ and such is a link to other dirs, so it doesn’t skip them. Be sure not to use these statements when running this on Windows XP…

 

Symbolic links, junction points and mount points are all reparse points:

  1. Symbolic links – kind of a shortcut to a file or folder
  2. Junction points – only points to a folder
  3. Mount points – is a folder that points to disk volume

When doing a backup with Rsync you can exclude junction points but not restore them. A whole separate kind of script would be necessary to copy and restore the junction points. The command MKLINK, first introduced in Vista, can be used but might not completely mimic the junction points preset in Vista and Win7.

The AutoIT user function _FileFindEx can identify reparse points if they exist. It might be possible to run a check for junctions, save them to a file within the directory being backed up (including a batch command to restore them), then run Rsync using that file as an –exclude file.

At http://bryanpendleton.blogspot.com/2010/07/windows-and-file-links.html

The MSDN documentation has a fairly detailed discussion of symbolic links:

Symbolic links can either be absolute or relative links. Absolute links are links that specify each portion of the path name; relative links are determined relative to where relative–link specifiers are in a specified path.

At http://www.autoitscript.com/forum/topic/123943-getting-size-on-disk/ KaFu points out:

FindNextFile : “If the path points to a symbolic link, the WIN32_FIND_DATA buffer contains information about the symbolic link, not the target.”
WIN32_FIND_DATA: “If the dwFileAttributes member includes the FILE_ATTRIBUTE_REPARSE_POINT attribute, this member specifies the reparse point tag.”
IO_REPARSE_TAG_DFS
IO_REPARSE_TAG_DFSR
IO_REPARSE_TAG_HSM
IO_REPARSE_TAG_HSM2
IO_REPARSE_TAG_MOUNT_POINT
IO_REPARSE_TAG_SIS
IO_REPARSE_TAG_SYMLINK

Apparently there is a special Rsync exclude feature that uses *** three astericks, not sure about it.
– All Users***
– Default User***

SUMMARY

Hopefully, some of the preceding information and links can be used to help Rsync backup Vista/Win7 machines, or even XP/Server2003 with hard links (another story, I found that hard links aiming at another volume would delete file on that volume when Rsync went to backup the volume containing the hard links … luckily had backups but it took a long time to locate the problem and restore the files).