#184703 - 2008-01-18 11:36 PM
Re: Advice and Suggestions for a major move script
[Re: Glenn Barnas]
|
Gargoyle
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,
;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
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
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!
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 778 anonymous users online.
|
|
|