?
Solved

Robocopying data from one server to three new ones

Posted on 2016-09-15
6
Medium Priority
?
32 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

777 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