Page 1 of 1 1
Topic Options
#184692 - 2008-01-18 05:33 PM Advice and Suggestions for a major move script
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
I have been assigned a new project and would really like to hear from those here about the best way to handle this.

The task -
Currently all users have their home drive mapped to K: the mapping is \\OldServer\Username$. Profiles are mapped \\OldServer\Profiles$\Username.pds

All of this is set in AD, and is not scripted

I need to move all of the Home Drives and Profiles to a new server, but do to the # of users we are going to break it up further
\\NewServer\A\Username - \\NewServer\Z\Username

Profiles will follow the same structure

Currently the share is at the username level, The new server it will be at the root level and then will use deep mapping.

Some of the issues that I have thought of, are of course how to handle the copying of the permissions to ensure that whatever ACL is set currently is copied to the new folder, and how to handle "file in use" issues, as we are 24x7 shop.

Along with moving all of the data, I have to update everones AD account to point to the new location.

This project involves moving approx 5 TB of data (all flat files though). so any pointers and tips that you are highly appreciated.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#184697 - 2008-01-18 07:46 PM Re: Advice and Suggestions for a major move script [Re: Gargoyle]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
We did something similar two months ago.
I used something like this to set the homefolder path in AD for all users. I changed it a bit to better fit your needs and did not test after modifying it so you might want to do some test first ;\)

 Code:
Break on
 
$domain = GetObject("WinNT://@LDomain")
$domain.filter = "User",""
For Each $user in $domain
	If InStr($user.homedirectory, "oldservername")
 		$newhome = "\\NewServername\" + SubStr($user.Name,1,1) + "\" + $user.Name
 		$user.put("homedirectory",$newhome)
 		If @ERROR
 			?$user.Name + " had an error."
 			?@ERROR
 			?@SERROR
 		Else
 			?"Home folder for user " + $user.Name + " has been changed."
 		EndIf
		$user.setinfo
	Else
		If Trim($user.homedirectory) = ""
			?$user.Name
			?"No homefolder set for this user"
		Else
			?$user.Name
			?"Wierd homefolder set for this user."
			?$user.homedirectory
		EndIf
	EndIf
Next


As for the in use files the best option would be to let them know that for example users Axxxx to Exxxxx will be moved after regular office hours and force a logoff for them, lock the account do your magic and unlock the account when all is done.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#184698 - 2008-01-18 09:29 PM Re: Advice and Suggestions for a major move script [Re: Mart]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Thanks Mart, how would you go about determing if a user is logged in? Then what machine they were logged into?

My assumption would be to change the LDAP $user.enabled = 1 to temporarily disable their account, and then flip it back to a 0 when done.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#184699 - 2008-01-18 10:03 PM Re: Advice and Suggestions for a major move script [Re: Gargoyle]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Yeah disabling durign the move and enabling when all is done would be the way to go imho.

Never did anything to see if a user is currently logged onto the domain but the LastLogDate UDF might help. Get the last logon and logoff times compare both and see witch one is the most recent.
LASTLOGDATE() - Determine last Logged on or logged off

It must be possible to see from what machine they are logged on but I'm still starting to script stuff in AD so not sure how to do that yet.


Edited by Mart (2008-01-18 10:05 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#184701 - 2008-01-18 10:52 PM Re: Advice and Suggestions for a major move script [Re: Gargoyle]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
What tool do you plan on using to copy the files?
Are the servers on the same LAN segment?

I have some experience with Unison, which is much faster than RoboCopy or XCopy processes. (Syncing a 16G folder structure with tens of thousands of files took 80 minutes to process with Robocopy, and took only 3 minutes with Unison. (same number of file changes to replicate - the big difference was detecting what had changed) It's a free tool, and can even do bi-directional syncs. I'd be glad to give a hand getting it running if you're interested.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#184702 - 2008-01-18 11:02 PM Re: Advice and Suggestions for a major move script [Re: Glenn Barnas]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Ah - also, the way to get this done is to announce an outage for select users.. Any user in the list "will have their open files forcibly closed at 8pm, possibly with loss of data. Users are requested to close all applications and log off before the change window begins!" Then, at the designated time, forcibly close the shared connections. You've got an advantage going from many shares to a common share, since once you disconnect open sessions, you can delete the share and prevent reconnects until you replicate their folder to the new share.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#184703 - 2008-01-18 11:36 PM Re: Advice and Suggestions for a major move script [Re: Glenn Barnas]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
At this time Robocopy / SecureCopy were our two choices. I will check Unison (you talk it up well \:\) ).

We are moving across a LAN so that will ease the pain alot.

In your (or anyone else that wants to speak up) opinion what is the most effective way of closing the connections.

We don't need to worry about "sync" as it will be a full out move.

Currently as I see it,

 Code:
;Script to move Profiles and HomeDrives for all Users
;----------------------------------------------------
;
If Not @LOGONMODE
	     Break On
EndIf

$SO=SetOption("Explicit", "ON")
$SO=SetOption("NoMacrosInStrings", "ON")
$SO=SetOption("NoVarsInStrings", "ON")
$SO=SetOption("WrapAtEOL", "ON")

;Setup Variables and Declerations

Dim $DirToMove, $Directory,$LogFile.$FH,$DN,$SO,$logons
Dim $Logoffs,$File,$FlagOn[],$FlagOff[]


$Logfile="\\AServer\scripthome\logs\FileMove.txt"
$FH = FreeFileHandle()

If Open ($FH,$LogFile,5) = 0


;Begin by creating an array that contains all of the 
;current HomeDirs

	$DirToMove = DirPlus("\\OldServer\home$")

;Now we begin to check each of the entry's int $DirToMove
	For Each $Directory in $DirToMove
	$SO=WriteLine($FH,"Looking up "+$Directory+@CRLF)
;Now we check to see if it is a valid user
		$DN = TranslateName(3,"",3,"ADomain\"+$Directory,1)
		If $DN[1] = 0
	;Is the user logged in?
			$FlagOn = 0,0 ;date,time
			$FlagOff = 0,0
			$Logons = Dirplus("\\AServer\g-drive\KixTrax\Logon", /M $Directory)
			$Logoffs = Dirplus("\\AServer\g-drive\KixTrax\Logoff", /M $Directory)
			For Each $File in $Logons
				If SerialDate(Left(GetFileTime("\\AServer\g-drive\KixTrax\Logon\"+$File),10)) > $FlagOn[0]
					If SerialTime(Right(GetFileTime("\\AServer\g-drive\KixTrax\Logon\"+$File),8)) > $FlagOn[1]
						$FlagOn[0] = SerialDate(Left(GetFileTime("\\AServer\g-drive\KixTrax\Logon\"+$File),10))
						$FlagOn[1] = SerialTime(Right(GetFileTime("\\AServer\g-drive\KixTrax\Logon\"+$File),8))
					EndIf
				EndIf
			Next
			
			For Each $File in $Logoffs
				If SerialDate(Left(GetFileTime("\\AServer\g-drive\KixTrax\Logoff\"+$File),10)) > $FlagOff[0]
					If SerialTime(Right(GetFileTime("\\AServer\g-drive\KixTrax\Logoff\"+$File),8)) > $FlagOff[1]
						$FlagOff[0] = SerialDate(Left(GetFileTime("\\AServer\g-drive\KixTrax\Logoff\"+$File),10))
						$FlagOff[1] = SerialTime(Right(GetFileTime("\\AServer\g-drive\KixTrax\Logoff\"+$File),8))
					EndIf
				EndIf
			Next

		
	;Logoff user
	
	;Lock user account
	
	;Move HomeDir / Profile

	;Unlock user account
		EndIf
	Next
EndIf

;Functions


Where the Logon / Logoff Files are created everytime someone logons to a machine, each user-machine file is overwritten every logon/logoff.

If you see any major flaws in my logic to this point please let me know.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#184704 - 2008-01-19 12:34 AM Re: Advice and Suggestions for a major move script [Re: Gargoyle]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
My colleague just left my office - we have jobs to replicate our web image content between Dev, QA, and Prod that run several times a day. I just migrated the process to use Unison. His words - "the old job is running for 15 minutes already... in that time, I've synchronized 5 other sites to 3 environments with the new scripts!" This is why I recommend this tool..

Couple of other reasons to consider Unison over Robocopy
- Speed
- restartable
- fault tolerant (won't change the target until the copy is complete and verified)
- Client only or Client Server modes

Client/Server is DAMN FAST! 8 seconds to compare our 16G data structure and determine that no replication is needed! Easy to use, too. Copy Unison to both systems. On the target, run "unison -socket 1758" - this sets up a server listening on port 1758. On the source system, simply run
 Code:
unison d:\path1\path2 socket://host:1758/D:\path1\path2 -times -batch -force d:\path1\path2

This will copy everything from D:\path1\path2 on the local system to the target, preserving modification times, and forcing the source to be the winner if there are file conflicts.

Since you will be working in groups of users, your script would create the new home folder and set permissions as you want now, instead of matching possibly incorrect perms. Unison works with profiles - simple text files, so you could add -root "username" entries to the profile, and simply run "unison profname" when your script is done deciding what to do, logging off users, closing connections, and making directories.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#184705 - 2008-01-19 12:44 AM Re: Advice and Suggestions for a major move script [Re: Glenn Barnas]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Maybe I should have mentioned this earlier, but the source and destination are both NetApp appliances.

So really don't have any "servers" to load software on other then the scripting host server.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#184706 - 2008-01-19 01:36 AM Re: Advice and Suggestions for a major move script [Re: Gargoyle]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Well, then you won't be able to take advantage of the socket mode - specify UNC paths for both source and dest and it will work. Just that Socket mode is incredibly fast.

G-
_________________________
Actually I am a Rocket Scientist! \:D

Top
#184737 - 2008-01-22 04:38 PM Re: Advice and Suggestions for a major move script [Re: Glenn Barnas]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Another how to question.

I have been able to determine who is logged in, and where they are logged in, but in many cases this will be on Terminal Servers and I can not just issue a "shutdown" for out TS enviroment. Is there any way to force a "logoff" of a user on a remote system?

This script will be an admin script, so using the usual tricks from a login script are not going to work in this case.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#184738 - 2008-01-22 04:57 PM Re: Advice and Suggestions for a major move script [Re: Gargoyle]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
If you are using NetApp applicances (filers?) talk to your support people about getting an evaluation license of SnapMirror to move the data.

This is how we have moved all our large data about in the past.

Top
#184740 - 2008-01-22 05:40 PM Re: Advice and Suggestions for a major move script [Re: Richard H.]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
We would use SnapMirror, if we were not completly changing the directory structure.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#184778 - 2008-01-23 01:21 AM Re: Advice and Suggestions for a major move script [Re: Gargoyle]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
found some built in utilities that allow me to logoff TS users from a remote location.

QWINSTA and RWINSTA

These come from the Citrix world and are Query WINdows STAtion and Reset WINdows STAtion.

Works well and is great for scripting purposes.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#184782 - 2008-01-23 02:06 AM Re: Advice and Suggestions for a major move script [Re: Gargoyle]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Both are on my Windows XP SP2 and Server 2003 SP2 systems.

 Quote:

RWINSTA
Reset the session subsytem hardware and software to known initial values.

RESET SESSION {sessionname | sessionid} [/SERVER:servername] [/V]

sessionname Identifies the session with name sessionname.
sessionid Identifies the session with ID sessionid.
/SERVER:servername The server containing the session (default is current).
/V Display additional information.


 Quote:

QWINSTA
Display information about Terminal Sessions.

QUERY SESSION [sessionname | username | sessionid]
[/SERVER:servername] [/MODE] [/FLOW] [/CONNECT] [/COUNTER]

sessionname Identifies the session named sessionname.
username Identifies the session with user username.
sessionid Identifies the session with ID sessionid.
/SERVER:servername The server to be queried (default is current).
/MODE Display current line settings.
/FLOW Display current flow control settings.
/CONNECT Display current connect settings.
/COUNTER Display current Terminal Services counters information.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 778 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.071 seconds in which 0.026 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org