Using Robocopy to root out PST files

Last Updated on December 4, 2015 by Dave Farquhar

So the word came out that the office is migrating to Windows 7 at some yet-to-be-determined time, but soon. It’s in testing now. (Too bad they didn’t recruit me as part of the testing team, because breaking Windows 7 is one of my superpowers.)

We’ve been told to back up our data. Lots of people are paranoid that they’ll lose their Outlook PST files, and with it, their ability to do top-drawer work. Frequently we have to search our archives to find forgotten details about old projects. It helps to make the new projects go more smoothly.

I came up with a surprisingly easy solution. It doesn’t even require admin rights–which is good. I won’t elaborate.
It involves some command-line hocus-pocus. Fortunately our machines have Robocopy on them. I believe Windows Vista and 7 come with Robocopy; it’s part of the resource kit for earlier versions.

To do this right, you’ll need Robocopy. So if you don’t have it, get a copy of the Resource Kit. You can run Robocopy.exe without installing the Resource Kit, if need be.

First, I strongly suggest closing Outlook. If you’re really paranoid, it’s even better to reboot. Closing Outlook should be sufficient, but I’ve seen files get stuck open and in use before. A reboot is the easiest way to keep it from happening to you. The odds may really be one in a million, but if it’s my data, I’m not taking that chance. It’s a lottery you don’t want to win.

Next, create a directory on your desktop. Since I have to be at a command prompt anyway to run Robocopy, I’ll do it from a command line.

md %userprofile%\desktop\backup

Now here’s the command to have Robocopy scour your entire drive for PSTs and copy them into your new directory/folder.

robocopy c:\ %userprofile%\desktop *.pst *.ost /z /s /r:2 /w:2 /xd %userprofile%\desktop

This command will scour the drive, retry twice if it can’t copy a file for some reason, and, most likely, generate a ton of error messages along the way, especially if you don’t have admin rights. Unlike Windows Explorer or the traditional DOS xcopy, Robocopy will automatically retry the specified number of times, then ignore the error if it persists and keep chugging away.

If it gets interrupted really badly (like a power outage, or a consultant named Bruce walking by and turning off your system), just power the system back on, log in, and run the command again. It will pick up where it left off. Robocopy is really cool like that.

Once it finishes, archive that backup folder off onto DVD, an external drive, or some other media. You can zip the file if you want.

Once the migration happens, root out the PSTs (and possibly the OSTs) from the backup, copy them somewhere that makes sense, and open them inside Outlook.

Easy? Relatively. Obvious? Nope. Knowing about things like Robocopy helps keep me employed.

If you’re not familiar with Robocopy, I strongly suggest you become familiar with it. I’ve used it to copy tens of gigabytes of data across unreliable WAN connections that drop intermittently and without notice. Sometimes I started it on the Friday before a 3-day weekend and it finished around mid-day the following Tuesday, but it got it done. Like a Joshua Tree, it can thrive in the harshest of environments.

If you found this post informative or helpful, please share it!

5 thoughts on “Using Robocopy to root out PST files

  • February 19, 2011 at 4:44 pm

    Wait a minute – Bruce moved down there by you? I used to work with a guy who, if you weren’t in front of your computer, using it, would step into your office and turn it off. He did it to the CEO twice. Never saw him again. Fortunately, I never hired him…

    • February 19, 2011 at 6:04 pm

      There was a guy named Bruce who had a nasty habit of clicking shutdown instead of log off. And he always blamed me. So then I’d have to go into the system logs to prove my innocence. That maneuver came to be known as “Bruce-ing.” So when I’d shut a server down for the last time before decommissioning it, I’d always say, “Yep, I Bruced that box.”

      I wonder if it was the same guy? He tended to move around and change jobs a lot.

  • February 19, 2011 at 10:47 pm

    Thanks Dave. I wasn’t paying attention to Win 7 when you made your previous Robocopy post so I missed it. This looks like an answer for my backup.bat file that my wife’s Win 7 won’t run properly (I’m still on XP where it works fine).

  • February 23, 2011 at 12:48 am

    Sorry to see you endorsing robocopy. One of the worst programs I have ever used, like a bad unix nightmare. Great way to trash a directory of important files by missing a switch. And yes, I am a CLI pro, so I have no issues using the command-line apart from the fact that these sorts of programs thrive on obscure arcana, and have many edge-cases that I have the super-power of being able to find.

    Something that at least gave you a view of what was about to happen, what files were going to change, and how, now that would be a tool worth tooting a horn about. Just my two cents.

    • February 23, 2011 at 7:42 pm

      Kind of like running it beforehand with the /L switch?

      It’s not the most intuitive program in the world, but if I only wrote about things that are easy or obvious, I don’t think too many people would come back.

      But you did inspire a follow-on, so thanks for that. I’ll post that either today or tomorrow.

Comments are closed.

%d bloggers like this: