Syncstuff.kix
From espinola.net
This is a subscript of my Kixtart logon script environment.
On This Page |
syncstuff.kix
Header
;2345678901234567890123456789012345678901234567890123456789012345678901234567890 ; ;------------------------------------------------------------------------------; ; File Name : syncstuff.kix ; Last Edit : XX/XX/XXXX XX:XX AM/PM ; Edited by : username ; Description : Synchronization script for backing up and restoring user data ;------------------------------------------------------------------------------; ; Call "@LDRIVE\precursor.kix"
Cleanup Mis-Configured Folder Structures
This segment is for removing defunct folder structures from previous synchronization/backup script use. It is not a requirement, and is only listed as a reference in case of a specific need to remove old folders.
This process is listed before the actual backup scripts because it will save time/bandwidth to delete these folders and files prior to performing another backup of the same data.
;------------------------------------------------------------------------------;
; Cleanup mis-configured folder structure
;------------------------------------------------------------------------------;
;
If Exist ("$HomeDrive2\%COMPUTERNAME% Backups\.")
Run '%COMSPEC% /C RD /S /Q "$HomeDrive2\%COMPUTERNAME% Backups"'
EndIf
Restore User Files from Profile Recreation
This segment is useful for automatically restoring previously saved profile folders, if for any reason a users profile needs to be recreated. This segment is dependent on the $TempMarker variable listed in the precursor.kix file.
To create a new logon profile and automatically restored the file that were backed up in the backup portion of the script, logon on an alternate administrative account and rename the logon profile directory in question with the suffix ".$TempMarker" (with $TempMarker substituted with what is specified in precursor.kix).
The next time the use logs on, a new profile with the original folder name will be created. This script segment will detect the existance of the original renamed folder, and will automatically restore the contents of the prior backup of the system that the logon script is running on. After the restore is complete, a marker file named "touched.txt" will be created in the renamed profile directory to prevent this restoration from happening again. This is necessary because while the user can create a new file within their old profile directory structure - they do should not have the NTFS rights to delete the directory structure.
This process is listed before the actual backup scripts because these files should be restored before anything is then backed up.
;------------------------------------------------------------------------------;
; Restoration After Recreated Profile
;------------------------------------------------------------------------------;
;
If Exist ("%USERPROFILE%.$TempMarker\.")
If Exist ("%USERPROFILE%.$TempMarker\touched.txt")
Else
Shell '@LDRIVE\robocopy "%USERPROFILE%.$TempMarker\Cookies" "%USERPROFILE%\Cookies" /E /V /R:0 /W:0'
Shell '@LDRIVE\robocopy "%USERPROFILE%.$TempMarker\Desktop" "%USERPROFILE%\Desktop" /E /V /R:0 /W:0'
Shell '@LDRIVE\robocopy "%USERPROFILE%.$TempMarker\Favorites" "%USERPROFILE%\Favorites" /E /V /R:0 /W:0'
Shell '@LDRIVE\robocopy "%USERPROFILE%.$TempMarker\Start Menu" "%USERPROFILE%\Start Menu" /E /V /R:0 /W:0'
Shell '@LDRIVE\robocopy "%USERPROFILE%.$TempMarker\Templates" "%USERPROFILE%\Templates" /E /V /R:0 /W:0'
Shell '@LDRIVE\robocopy "%USERPROFILE%.$TempMarker\Application Data" "%APPDATA%" /E /V /R:0 /W:0'
; Shell '@LDRIVE\robocopy "%USERPROFILE%.$TempMarker\Local Settings\Application Data" "%USERPROFILE%\Local Settings\Application Data" /E /V /R:0 /W:0'
If Open( 3 , "%USERPROFILE%.$TempMarker\touched.txt" , 5 ) = 0
$x = WriteLine( 3 , @WkSta + "," + @UserID + "," + $MyDocuments + "," + @Date + "," + @Time + @CRLF)
EndIf
EndIf
Restore User Files
This segment is for manually restoring backups of specific folder structures. If the "Restore" directory is present within the "Backups" folder structure, the specific folders listed will be restored to the machine that the logon script it running against. This can be useful for easily restoring such things as Internet Explorer favorites and Outlook signatures. The backup procedure is located in the following script segment below. These segments are useful if you do not use roaming profiles.
This process is listed before the actual backup scripts because these files should be restored before anything is then backed up.
;------------------------------------------------------------------------------;
; Restore Saved Files
;------------------------------------------------------------------------------;
;
If Exist ("$HomeDrive2\Backups\Restore\.")
Shell '@LDRIVE\robocopy "$HomeDrive2\Backups\Restore\Favorites" "%USERPROFILE%\Favorites" /S /NP /NJH /NJS /NDL /R:0 /W:0'
Shell '@LDRIVE\robocopy "$HomeDrive2\Backups\Restore\Templates" "%USERPROFILE%\Templates" /S /NP /NJH /NJS /NDL /R:0 /W:0'
Shell '@LDRIVE\robocopy "$HomeDrive2\Backups\Restore\Signatures" "%APPDATA%\Microsoft\Signatures" /S /NP /NJH /NJS /NDL /R:0 /W:0'
Shell '@LDRIVE\robocopy "$HomeDrive2\Backups\Restore\Office Templates" "%APPDATA%\Microsoft\Templates" /S /NP /NJH /NJS /NDL /R:0 /W:0'
Shell '%COMSPEC% /C RD /S /Q "$HomeDrive2\Backups\Restore"'
EndIf
Backup User Files
This segment is for making backups of specific folder structures. In this example, we are specifically looking at folders that are within the user profile such as Internet Explorer favorites and Outlook signatures - items that are important for the personalization and ease of use for your users. Backups of this nature can be very helpful if you do not use roaming profiles.
;------------------------------------------------------------------------------; ; Backup User Files ;------------------------------------------------------------------------------; ; Shell '@LDRIVE\robocopy "%USERPROFILE%\Favorites" "$HomeDrive2\Backups\%COMPUTERNAME%\Favorites" /MIR /NP /NJH /NJS /NDL /R:0 /W:0' Shell '@LDRIVE\robocopy "%USERPROFILE%\Templates" "$HomeDrive2\Backups\%COMPUTERNAME%\Templates" /MIR /NP /NJH /NJS /NDL /R:0 /W:0' Shell '@LDRIVE\robocopy "%APPDATA%\Microsoft\Signatures" "$HomeDrive2\Backups\%COMPUTERNAME%\Signatures" /MIR /NP /NJH /NJS /NDL /R:0 /W:0' Shell '@LDRIVE\robocopy "%APPDATA%\Microsoft\Templates" "$HomeDrive2\Backups\%COMPUTERNAME%\Office Templates" /MIR /NP /NJH /NJS /NDL /R:0 /W:0'