Budget Windows Mirroring

Last week I put a plea for help up about my quest to find a way to mirror some directories between servers. That isn’t so difficult, but the desire to have it real-time – or almost real-time – made finding a cost-effective solution difficult.

I put a post up on serverfault.com and got some good responses. The answer I selected taught me some features of my old friend robocopy that I had never discovered: the /mon and /mot flags.

/mon: Monitors the source, and runs again when more than N changes are detected.

/mot: Monitors source, and runs again in M minutes if changes are detected.

Those flags are game changers! With them, robocopy runs the sync job as specified. When done, it stays alive and starts watching for changes. As the changes are detected the timer starts a countdown until the next run. Brilliant!

I created a ltitle batch file with the robocopy command and arguments I wanted. I set it as a scheduled task that starts every morning at 6 AM. I specified properties on the task to kill the job after 16 hours. Then the next day it starts up. Seems to be working very well. The only time it gets weird is when folks inadvertently lock files on the mirror’s destination side. That hoses things up a big until they release the lock. That’s mostly been an education issue though.

Here’s the command I’m using. Lots of flags!

robocopy "E:\source" \\server2\dest /mir /mon:1 /mot:1 /R:2 /W:15 /COPY:DT /log:c:\util\mirlog.txt /NJH /NJS /NDL /NP /Z

The logging is a bit funky and might be related to the logging options I’ve specified (/NJH /NFS /NDL /NP). Seems like I get lots of blank gaps in the log when there are locked files and the latest log entry isn’t necessarily at the bottom of the file.. But hey, we know that any changes made will be on the other server within a minute and that’s just what needed to happen.

Pseudo real-time mirroring for free!

[robocopy reference]

Possibly Related posts:

  1. Windows 2003 Real-Time Mirroring?
  2. Finding Uptime for Windows
  3. Windows Scheduled Tasks Tricks
  4. Free Windows ISO Toys

About Chris

I consider myself a jack-of-all-trades. Which means I know a little about a lot... or think I do, at any rate. Check my "About Me" page for more info.
Tagged , , , , . Bookmark the permalink.