Recursive Folder Copying on Windows

Last week, I had a rather simple task – copy a user-folder from an old laptop to a new laptop – preserve folder structure and keep all metadata (such as file-creation date, last edited etc.).
Right-click copy and paste does not fullfill the needs and usually is rather slow, so I tried to use Windows‘ built-in robocopy.

Doing a quick read over the documentation, I came up with

robocopy C:\SRCDIR D:\DSTDIR /e /dcopy:dat

which I thought would do, what I want – it should copy all files recursively and preserve file attributes and timestamps.

I started the process and expected it to be done after a few minutes – however, the process ran and ran.
The destination directory grew in size, way beyond what it should – according to the size of the source directory.

This prompted me to stop the process and investigate – the source folder was around 5GB, while the destination folder already was over 60GB – what happened?

At first glance, the destination folder looked completely normal, so I used TreeSize to analyze where the increase in size could come from.
A hidden folder (namely ...User\Application Data) was unreasonably big. It’s content: Itself. And itself. After some searching on stackoverflow, I found the reason: Robocopy follows symlinks, so it will basically recurse forever. Adding the /sl flag solves that problem and tells robocopy to create a copy of the symbolic link instead of following it. Lesson learned.