2

This might be a bit of an edge case, but I would dearly like to know if there is a simple way to achieve this.

Suppose I have the following set up (where the latter two are symbolic links to the first):

  • D:\Work\CommonStuff
  • D:\Work\Project1\Stuff -> D:\Work\CommonStuff
  • D:\Work\Project2\Stuff -> D:\Work\CommonStuff

Now suppose I want to make a backup of D:\Work to E:\Work.

I would like the links to be maintained, relatively, resulting in:

  • E:\Work\CommonStuff
  • E:\Work\Project1\Stuff -> D:\Work\CommonStuff
  • E:\Work\Project2\Stuff -> D:\Work\CommonStuff

Of course I understand that if I had:

  • D:\Work\CommonStuff
  • D:\Work\Project1\Stuff -> D:\Work\CommonStuff
  • D:\Work\Project2\Stuff -> D:\Work\CommonStuff
  • D:\Work\Project3\Stuff -> D:\OtherCommonStuff

Then it would complicate matters because if I am just copying D:\Work then what would the copy command do for the last option? In this case I'd like to copy the files directly, losing the symbolic link.

Is there any way robocopy or xcopy or [anyother]copy can achieve this on Windows 10?

1

Take a look at: Ln Command line hardlinks

This tool is kind of a NTFS Swiss Army Knife and can do lots of things, like create SmartCopies, which preserve the inner and outer Hardlink/Junction/SymbolicLink structure, does hardlink based incremental Backups and a lot of other things which can not be found anywhere.

I think what you ask can be achieved by:

ln.exe --unroll --copy --backup D:\Work E:\Work

--Unroll follows Outer Junctions/Symlink Directories and rebuilds the content of Outer Junctions/Symlink Directories inside the hierarchy at the destination location. Unroll also applies to Outer Symlink Files, which means, that unroll causes the target of Outer Symlink Files to be copied to the destination location.

--copy: Smart Copy basically creates a copy of the directory structure from the source location to the destination, but it preserves the inner hardlink structure and inner junction/symbolic link relations of the source, and recreates this inner hardlink structure and inner junction/symbolic link relation at the destination location.

--backup: Using the Backup Mode ACLs aka Access Control Lists, which contain the security for Files, Folders, Junctions or SymbolicLinks, and Encrypted Files are also copied.

ln.exe thus copies

  • Alternative Streams on files and folders
  • EA Records on files and folders (rarely used)
  • Reparse Info
  • File Attributes
  • Timestamps: Creation Time, Last Access Time, Last Write Time
  • Sparse Files and Alternative Sparse Streams
  • Encrypted files
  • ACLs
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.