Categories
Windows 2008

Windows Server: Folder Redirection – Migration

Windows Server: Folder Redirection – Migration

I recently had to migrate a load redirected folders from one server to NetApp CIFS vFiler. The redirected folders were being access via a DFS NameSpace, had Exclusive Rights for users and contained up to 20GB per user, with some files having specific ACL’s that prevented even the SYSTEM account from accessing them! Needless to say this wasn’t a simple process.

Firstly let me point out a simple way of doing this in a smaller environment. If you update your Group Policy Folder Redirection Options  (or apply a new policy with higher precedence), if the Redirection Policy is configured to “Move the contents of xxxx to the new location” then at logon the users files will be moved to the new location…. an automated migration that works well for small amounts of data.

With up to 20GB of data per user the above solution simply wasn’t going to cut it. This would have added hours of delays for users logging on. We opted to pre stage the data, which meant we had to disable the “Move the contents of xxxx to the new location” for each folder we were pre-staging – this is an important step! You should allow a week or two for all users to get this change before proceeding with your migration.

Next problem, how to pre-stage the data! Well RoboCopy failed miserably due to the ACL’s and exclusive rights, so we used a tool called SecureCopy which worked really well – to a point; open files, and files with specific ACL’s which users had set were not pre-staged. The number of these files totalled around 2,300!

We needed to pre-stage these files are many of them were current, business related documents… welcome back to the fight RoboCopy! We deployed a script (below) to run at user logon, as the user, that would copy the missing files (using /MIR to mirror the folder contents) from the Windows box to the NetApp CIFS. This ran for a few days to minimise the amount of missing data when we ‘flipped the switch.’

Finally, with the data pre-staged we change the GPO folder redirection options to point to the vFiler shares. The RoboCopy script was still running, so when users logged on they got the migrated, pre-staged redirected folders that were up-to-date 🙂

All-in-all the process took a few days (weeks if you include the initial step to disable “Move folder contents…”) but the end result was minimal interruption to users – which in the world of infrastructure is a good thing.

In short, the process was:

  1. Disable “Move the contents of xxxx to the new location” for each redirected folder
  2. Wait a week or two!
  3. Use SecureCopy to pre-stage most of the data
  4. Deploy a RoboCopy user logon script to mirror the user data on the old Windows box to the CIFS vFiler folder containing the users’ data.
  5. Wait a few days to minimise the amount of un-synched data
  6. Change the folder redirection policy / deploy a new GPO with higher precedence

{code lang:php title:”Copy Script” lines:false hidden:false}Option Explicit
On Error Resume Next
‘———————–
‘——– Define Variables
‘———————–
Dim objNetwork, strUserName, fso, objFSO, objFolder, objFiles, fldName, checkFile, logFile, logPath
Dim srcSrv, myDocShare, myFaveShare, myDeskShare
Dim dstSrv, myDocDst, myFaveDst, myDeskDst

Set objNetwork = WScript.CreateObject(“WScript.Network”)
Set objFSO = CreateObject(“Scripting.FileSystemObject”)

‘———————–
‘——– Obtain User Logon Name
‘———————–
strUserName = objNetwork.UserName
‘Share path to create log files for each RoboCopy opperation
logPath = “\\SERVER\Share\Folder\”

‘———————–
‘——– Define redirected folders to check
‘———————–
‘Source
srcSrv = “\\Server or DFS NameSpace Root\”
‘Destination
dstSrv = “\\Server or DFS Name Space Root\”

‘Source Share Paths, add more if required, be sure to define variables at the top of the script
‘and destination paths below
myDocShare = “MyDocuments\” & strUserName
myFaveShare = “MyFavourites\” & strUserName
myDeskShare = “MyDesktop\” & strUserName
‘Destination Share Paths
myDocDst = “MyDocuments\” & strUserName
myFaveDst = “MyFavourites\” & strUserName
myDeskDst = “MyDesktop\” & strUserName

‘———————–
‘——– Check User Has Not Been Processed Already
‘———————–
If NOT(objFSO.FileExists(dstSrv & myDocShare & “\SharesMirrored”)) Then
        ‘———————–
        ‘——– Check Redirected Folders, add any additional shares created above
        ‘———————–
        CheckFolder(myDocShare)
        CheckFolder(myFaveShare)
        CheckFolder(myDeskShare)
        
        ‘———————–
        ‘——– Subs/Functions
        ‘———————–
        Sub CheckFolder(fldName)
            Dim objShell, logName
         Set objShell = CreateObject(“WScript.Shell”)
         ‘Hide and run all copies async.
            
         If inStr(fldName,”Documents”) > 1 Then
             LogName = “Docs”
            ElseIf inStr(fldName,”Desktop”) > 1 Then
                    LogName = “Desktop”
            ElseIf inStr(fldName,”Favourites”) > 1 Then
                    LogName = “Faves”
            End If
            
            ‘Perform Validation
            If strUserName = “” or srcSrv = “” or fldName = “” or dstSrv = “” Then
                ‘Do Nothing
         Else
             objShell.Run “robocopy.exe ” & Chr(34) & srcSrv & fldName & chr(34) & ” ” _
                 & Chr(34) & dstSrv & fldName & Chr(34) & ” /COPY:DAT /E /XX /XO /R:1 /W:5 /LOG:” & chr(34) _
                 & logPath & strUserName & “-” & logName & “.txt”,0,false
            End If
        End Sub
                
        ‘———————-
        ‘——– Create Log File
        ‘———————-
        ‘Set checkFile = objFSO.CreateTextFile(dstSrv & myDocShare & “\SharesMirrored”, True)
Else
        Wscript.Quit
End If{/code}

 

Leave a Reply

Your email address will not be published. Required fields are marked *