IT professionals (and amateurs), it’s time we had a chat. It’s time to stop dragging and dropping (or copying and pasting) files between servers and/or workstations.

It’s clumsy. It’s childish. It uses memory on the server.

Oh, and there’s a really easy tool to copy files built into Windows – Robocopy.

Here’s the basic premise: you open a PowerShell window (or command prompt, but let’s join the 21st century), and enter

robocopy    /

The file(s) are copied, with progress shown. A few things I love about this:

  • I can specify a network location or a local directory for either the source or the destination.
  • I can copy one backup file, or every transaction log backup in the directory.
  • I can use the /z option to tell Robocopy that if the transfer gets interrupted, pick back up when it gets reconnected.
  • I can see the progress, in terms of actual bytes, not just Windows’s “45%” that runs for three hours.

Here are a couple examples.

I want to move the files from my Extended Events folder on AG1 to AG 2. Command:

robocopy "C:\Users\a-jes\Documents\SQL Server Management Studio\Extended Events" "\\SQL2014AG2\C$\Users\a-jes\Documents\SQL Server Management Studio" /z
All sorts of goodness!

All sorts of goodness!

 

Let’s say I wanted to move all the .xml.gz files from one directory to another. Command:

robocopy "C:\Users\a-jes\Documents" "\\SQL2014AG2\C$\Users\a-jes\Documents" *.xml.gz /z 

robocopy 2

That’s a very quick look at Robocopy. I suggest you know it, use it, and love it!

(Inspired by Tim Ford’s call to blog about #entrylevel topics that I #wanttoshare.)