Perforce hot-copy on Windows

Yep, I’m writing this here in the hopes that the next person who needs to resolve this issue will be able to find a solution through Google without getting stuck in the vile pit of hell that is the site WindowsIT Pro. Not that I have an opinion on it…

So the problem:

I am running Perforce Server on Windows (pity me), and I want to make a file-based copy of the entire repository for the purposes of maintaining a hot-copy backup, as well as a place to run trial upgrades, obliterates, etc. In the future, maybe even use that to do off line checkpoints.

The problem is that when I attempt to copy the files to another machine, the folder structure is so deep that I run into a limitation of Windows where it can’t deal with a path name longer than about 260 characters. In the case of using the venerable RoboCopy (read Rsync for Windows), the error that is returned is “can’t find file”.

The solution is to make some creative use of drive mapping (the “net use” command) and drive aliases (the “subst” command) to shorten the path lengths so that it can all fit. Obviously, this will only gain you so much – it’s feasible that the names still won’t fit if your structure is deep enough. In that case, move to Linux or Unix for running the server. You’ll probably be better off that way anyway…

The detail in a recipe:

subst p: e:perforce_root

net use q: \targetmachineperforce_root_copy

robocopy p: q: /MIR /r:5 /w:5 /XF db.* /LOG:c:logsrobocopy_perforce_log.txt

Make sure you exclude the db.* files if you’re doing this during the day. Otherwise robocopy will grab the lock on those bad boys and Perforce will hang… Not that I found that out. No.. not me. Not the hard way. (It does release the locks when it’s done copying)

Published by heckj

Developer, author, and life-long student. Writes online at

%d bloggers like this: