?
Solved

Robocopying data from one server to three new ones

Posted on 2016-09-15
6
Medium Priority
?
41 Views
Last Modified: 2016-10-05
We've got some Citrix home directories on one server, call it "citrixhome", that are mapped to authenticated users' U:. The new server, "newhome", will now house their home directories and be mapped to H:.
i.e. H: maps to \\newhome\Shares\HomeDirs\username

We wish to move over all of the data in their Citrix home directories (U:) to (H:).
H: already houses containers with identical usernames, but there are some with out Citrix data.
Ideally we could run this command to not move but copy the data to seed it on \\newhome, and then run the copy one last time to synch it before telling Citrix to use those drives instead of on \\citrixhome.
Note: This is one of three new servers for home drives, so really there would be three destinations for the data depending on job role.  This I was thinking robocopy may need a test file to parse of the users and where to send the data.
i.e. \\newhome1\Shares\HomeDirs\username is for one dept
\\newhome2\Shares\HomeDirs\username is for another dept
\\newhome3\Shares\HomeDirs\username is for a third dept

I'm relatively new to using robocopy and I'd figured someone on here would have a quick and simple response.  Thanks very much for any input or direction you can provide.
0
Comment
Question by:machine74
  • 3
  • 2
6 Comments
 
LVL 25

Expert Comment

by:NVIT
ID: 41800146
If the folder structure is the same, just use like..

Robocopy /e /dcopy:t /mir /r:3 /w:1 /log:c:\results.txt \\oldhome1\Shares\HomeDirs \\newhome1\Shares\HomeDirs

When you run it a second time, it will just copy what's needed and skip all else
0
 

Author Comment

by:machine74
ID: 41800166
So that will mirror whatever is in the Citrix directories onto the new servers. Cool--but unfortunately the list of people getting data out of their Citrix folders will have to be separated to go to the correct server.  Can you pass robocopy a text file with those parameters?
0
 
LVL 25

Assisted Solution

by:NVIT
NVIT earned 1000 total points (awarded by participants)
ID: 41800499
Here's a CopyUserDirs.bat that works.
- Change folder names of the source and target folders set SrcDir and set TgtDir to your needs. Maybe like:

set SrcDir=\\oldhome1\Shares
set TgtDir=\\newhome1\Shares

Open in new window


- It is in test mode, which just echos the commands, for verification reasons. When you are satisfied it should work, remove the ECHO word on line 10
@echo off
setlocal enabledelayedexpansion

set SrcDir=C:\local\test\FROM
set TgtDir=C:\local\test\TO
set FNCopyDirs=c:\local\test\UserDirs.txt

FOR /f "tokens=*" %%A in ('type "%FNCopyDirs%"') DO (
  set Dir=%%A
  ECHO robocopy /mir /copy:datsou /np /ndl /nfl /r:0 /w:0 /dcopy:t "%SrcDir%\!Dir!" "%TgtDir%\!Dir!"
)

Open in new window

- Make a UserDirs.txt file of user folder names.
- As a test, just do 1 or 2 user folders. When satisfied, you can add the rest on another run.
- Mine looks like:
userHasFull
userHasRead

Open in new window


My source folder has 3 folders: userNoCopy, userHasFull, and userHasRead
When I ran it, it just copied folders: userHasFull, and userHasRead. Also, the correct Security permissions are applied to the files and folders.

Open a CMD window.
Type: CopyUserDirs.bat to run it.
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

Author Comment

by:machine74
ID: 41800516
Hmph, interesting. I'm going to give this a go, thanks very much!
0
 
LVL 85

Accepted Solution

by:
oBdA earned 1000 total points (awarded by participants)
ID: 41801102
So you want to distribute the home folders from one old server to three new ones? This will do it all in one go.
It needs a "user to server" mapping file build like "<UserName><Blank><NewHomeServer>":
User1	NewHome1
User2	NewHome2
User3	NewHome3
User4	NewHome1

Open in new window

It will create one robocopy log file per user in a log folder, and a summary log file in csv format.
It's in test mode and will only echo the robocopy commands it would normally run; remove the uppercase ECHO in line 17 to run it for real.
@echo off
setlocal enabledelayedexpansion
set Source=\\OldServer\Shares\HomeDirs
set NewShare=Shares\HomeDirs
set MapFile=C:\Temp\Map.txt
set LogFolder=C:\Temp\Logs
set LogFile=%LogFolder%\summary.log
set RobocopyOptions=/mir /copyall /dcopy:t /ndl /nfl /r:0 /w:0

for /f "tokens=1,2" %%a in ('type "%MapFile%"') do set NewServer[%%~a]=%%~b
if not exist "%LogFolder%" md "%LogFolder%"
set /a ErrorCount=0
for /d %%a in ("%Source%\*.*") do (
	set User=%%~nxa
	if defined NewServer[!User!] (
		echo [!Date!][!Time: =0!] Processing '!User!' --^> '!NewServer[%%~nxa]!' ...
		ECHO robocopy.exe "%%~a" "\\!NewServer[%%~nxa]!\%NewShare%\!User!" %RobocopyOptions% /np /log+:"%LogFolder%\!User!.log"
		set EL=!ErrorLevel!
		if !EL! LSS 4 (
			echo [!Date!][!Time: =0!] ... OK.
			set Result=OK
		) else (
			echo [!Date!][!Time: =0!] ... ERROR: !EL!
			set Result=ERROR !EL!
			set /a ErrorCount += 1
		)
	) else (
		echo [!Date!][!Time: =0!] ERROR: '!User!' has no server mapping.
		set Result=NO SERVER MAPPING
		set /a ErrorCount += 1
	)
	>>"%LogFile%" echo "!Date!","!Time: =0!","!User!","!Result!"
)
echo.
echo [!Date!][!Time: =0!] Done; there were %ErrorCount% error^(s^)
echo See the summary log file '%LogFile%'

Open in new window

0
 
LVL 25

Expert Comment

by:NVIT
ID: 41829533
Question is answered.
0

Featured Post

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
This article explains how to install and use the NTBackup utility that comes with Windows Server.
The viewer will learn how to count occurrences of each item in an array.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses
Course of the Month17 days, 2 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question