Backing up user’s personal computer data.

This is a batch script used to backup end user’s personal data to the company’s users share. It is used when replacing the user’s computer and you need an easy way to backup their data. This is modified for a company with roaming profiles as the users Desktop and Documents do not need to be backed up as it is stored on a server. It also backs up specific files in the documents folder for easy retrieval for the pickier end user (in case it doesn’t show up in the roaming profile).

Echo off
REM:        Created by Villainous Wolf 
REM: To backup needed data for computer replacement.

REM: Customized parameters need to changed is the words "company-file-share" to match your company share. 

REM: This creates a variable of today's date and set equals to "backupdate" 
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set backupdate=%%c-%%a-%%b)

REM:This will grab users PST files and place it on the file share.
XCOPY /L "C:\Users\%username%\*.PST" "\\company-file-share\users\%USERNAME%\My Documents\Backup-%backupdate%\"

REM: Sets local to the end of the script.
setlocal enabledelayedexpansion
set "type=.PST"
set "source=C:\Users\%username%\"
set "dest=\\company-file-share\users\%USERNAME%\My Documents\Backup-%backupdate%\"

REM: increments file in case of dulpicates
for /r "%source%" %%f in ("*%type%") do (
  for %%d in ("%dest%\%%~nf*") do (
    set /a count+=1
  set "source=%%f"
  set "dest=%dest%\%%~nf"
  xcopy "!source!" "!dest!!count!%type%*"
  set count=

REM: Backs up users Favorites.
Set CurrentBackup=Backup-%backupdate%
	IF NOT EXIST "\\company-file-share\users\%USERNAME%\My Documents\%CurrentBackup%\Favorites" mkdir "\\company-file-share\users\%USERNAME%\My Documents\%CurrentBackup%\Favorites"
XCOPY  /E "C:\Users\%USERNAME%\Favorites\*" "\\company-file-share\users\%USERNAME%\My Documents\%CurrentBackup%\Favorites\"

REM: Backs up users Downloads.
	IF NOT EXIST "\\company-file-share\users\%USERNAME%\My Documents\%CurrentBackup%\Downloads" MKDir "\\company-file-share\users\%USERNAME%\My Documents\%CurrentBackup%\Downloads"
XCOPY /E "C:\Users\%USERNAME%\Downloads\*" "\\company-file-share\users\%USERNAME%\My Documents\Backup-%backupdate%\Downloads\"

REM: Backs up users Contacts.
	IF NOT EXIST "\\company-file-share\users\%USERNAME%\My Documents\%CurrentBackup%\Contacts" MKDir "\\company-file-share\users\%USERNAME%\My Documents\%CurrentBackup%\Contacts"
XCOPY /E "C:\Users\%USERNAME%\Contacts\*" "\\company-file-share\users\%USERNAME%\My Documents\Backup-%backupdate%\Contacts\"

REM: Backs up users email Signatures.
	IF NOT EXIST "\\company-file-share\users\%USERNAME%\My Documents\%CurrentBackup%\Signatures" MKDir "\\company-file-share\users\%USERNAME%\My Documents\%CurrentBackup%\Signatures"
XCOPY /E "C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Signatures\*" "\\company-file-share\users\%USERNAME%\My Documents\Backup-%backupdate%\Signatures\"

REM: This backs up a program's file settings that are stored in Documents.
	IF NOT EXIST "\\company-file-share\users\%USERNAME%\My Documents\%CurrentBackup%\Dragon_Files" MKDir "\\company-file-share\users\%USERNAME%\My Documents\%CurrentBackup%\Dragon_Files"
COMPACT /C "C:\ProgramData\Nuance\NaturallySpeaking10\Users*" 
XCOPY /E "C:\ProgramData\Nuance\NaturallySpeaking10\Users*" "\\company-file-share\users\%USERNAME%\My Documents\Backup-%backupdate%\Dragon_Files\"

REM: This backs up a program's file setting that are stored in Documents.
IF NOT EXIST "\\company-file-share\users\%USERNAME%\My Documents\%CurrentBackup%\Ahlta" MKDir "\\company-file-share\users\%USERNAME%\My Documents\%CurrentBackup%\Ahlta"
XCOPY /E "C:\Program Files (x86)\AHLTA\Data\RTData\AutoCorrect.act" "\\company-file-share\users\%USERNAME%\My Documents\Backup-%backupdate%\Ahlta\"
XCOPY /E "C:\Program Files (x86)\AHLTA\Data\RTData\customdict1.dic" "\\company-file-share\users\%USERNAME%\My Documents\Backup-%backupdate%\Ahlta\"

REM: I like to add a pause when testing to see errors, if any, so I can correct them.

Leave a Reply

Your email address will not be published. Required fields are marked *