Monday, April 11, 2011

Backup Windows Part 3 -- xcopy

Let's briefly discuss a quick way to backup Windows. I use a batch file that I wrote to quickly backup clients' PCs.

Here it is:

xcopy /c /d /e /h /i /r /y "%USERPROFILE%\Favorites" "%COMPUTERNAME%\%USERNAME%\Favorites"
xcopy /c /d /e /h /i /r /y "%USERPROFILE%\Desktop" "%COMPUTERNAME%\%USERNAME%\Desktop"
xcopy /c /d /e /h /i /r /y "%USERPROFILE%\My Documents" "%COMPUTERNAME%\%USERNAME%\My Documents"
xcopy /c /d /e /h /i /r /y "%USERPROFILE%\Documents" "%COMPUTERNAME%\%USERNAME%\Documents"
xcopy /c /d /e /h /i /r /y "%USERPROFILE%\AppData\Local\Microsoft\Outlook\*.pst"
xcopy /c /d /e /h /i /r /y "%USERPROFILE%\Local Settings\Application Data\Microsoft\Outlook\*.pst"

echo Backup Complete!
@pause


This quick script copies the user's Favorites, Desktop, My Documents(Documents in the case of Vista and Windows 7) and the Outlook .pst file.

This script will work for either XP or Vista/Windows 7. The /c switch tells xcopy to continue even if it confronts an error. Therefore, when running this script on Windows 7, xcopy simply moves on when it does not find the My Documents folder. Of course, the inverse is true when running the script on XP.

This can be used for migrations or as a regular backup. The /d switch tells xcopy to only copy files that have changed since a certain date. If no date is given, as above, only the files that have a newer source time than the destination will be copied.

Obviously, changes can be made to customize the script as needed. For instance, the entire user profile can be backed up. Also, additional folders, such as the Firefox profile, can be added.

I run this script from an external USB drive and all of the data is copied to that drive. Again, customize the script to copy files to a different location.

Be sure to type xcopy /? at a command prompt to learn what each switch does and also to learn about the switches not included in the above.

If you want to use the above backup script, copy and paste it into notepad and save it as backup.bat. Double-click the file and you're backing up.

2 comments: