When doing a file level migration, care must be taken to
copy the data from the source to destination.
A common mistake is the tool used to copy the data. A standard Windows copy to move data, while
very simple to execute will strip out much of the metadata and in some cases
the metadata is just a crucial to the files as the data themselves. To solve this problem, one tool that can be
used is robocopy.
First, let’s show what happens with a windows copy when
trying to migrate a few files.
I created a folder with a Word Doc and a change to the NTFS
permissions of the file.
The user account “NoAccess” has a full Deny access on this
file. We will then go ahead and move the
file with the Windows Copy tool.
We will then look at the target folder and we do see the
file as expected. The contents of the
file are the same. However, when we look
at the file security properties on the target side, we see the following.
The security information of the file is missing. This is because the contents of the file are
lost when you use a Windows Copy. The
user doing the copying becomes the owner and it inherits the security
information from that user. If there are
any special permissions, groups, or other security metadata on the file, they
are lost in a Windows Copy migration.
In comes robocopy. Here,
we can copy the file over to the target with the security info intact. Here, I will recopy the data, but this time
with a couple of switches to retain the metadata.
Here, we can see that I copied over the Word file. Checking on the security info of the file, we
see that the security info of the file did indeed copy over with the file.
This is because robocopy has the ability to copy over the
metadata of the files it copies.
The basic syntax for robocopy is simple.
Robocopy <source folder> <target folder> [files
to copy default is *.*] [switches]
The first two options are the source and target folders. Then you can specific files if you wish to
only copy a subset of the data in the files.
The switches that I used for a simple, one time copy are as
follows.
/Z makes this job restartable. If the job fails part way though, such as a
network error, ctrl-C, I will be able to pick up where I left off without
recopying all of the data over again.
For a simple 1 file test such as this, it may seem silly, but if you are
copying millions of files to move a large file system from one system to
another, having the ability to restart after an unplanned failure is a great
peace of mind.
/E Will copy the subdirectories in the source to the
target. This will include empty subdirectories.
/SEC will copy the files’ security information to the target
files.
/R:3 and /W:1 is for the number of retries on files that the
command can not copy, and how long to wait between retries. Although optional, the default values is to
wait 30 seconds between retries and will retry a whopping 1 million times! If you are copying live data that is being
accessed by the user community, you will probably encounter a few files that
you will not be able to copy due to it being opened by other user. Obviously, we do not want to wait a ridiculous
amount of time for the file to fail out when we can just skip it over and pick
it up on the next run.
Robocopy has a great numbers of options to help with your
file based migrations. Although this is
just scratching the surface, these options you will find to be used in a
majority of your robocopy commands in your migration efforts.