Category Archives: Microsoft Server 2012R2

Robocopy – The Quickstart Guide

Robocopy is a great tool, but there are so many options/attributes to choose from, a simple copy script for a server migration can take more time than you’d care to spend. I typically create and run these commands from the new/destination server. Below are the quick steps you can use on a new server to:

  • Copy all files/folders, retaining their timestamps, from source server to destination server
  • Log the outcome of the copy job so that you can kick it off, let it run, and check back later for any files that may have had issues
  • Modify your copy job to only capture only incremental file/folder changes after your initial large file copy

 

FULL COPY (with log):
robocopy “SOURCE” “DESTINATION” /NP /TEE /MT:32 /E /R:3 /W:5 /ZB /COPY:DT /LOG:”LOG_FILE_NAME_&_LOCATION”

Example:
robocopy “\\Source_Server\Data_Share” “D:\Data_Share” /NP /TEE /MT:32 /E /R:3 /W:5 /ZB /COPY:DT /LOG:”C:\Users\administrator\Desktop\data_share_log.txt”

 

MIRROR/INCREMENTAL COPY (/MIR):
robocopy “SOURCE” “DESTINATION” /NP /TEE /MT:32 /E /R:3 /W:5 /ZB /MIR /COPY:DT /LOG:”LOG_FILE_NAME_&_LOCATION”

Example:
robocopy “\\Source_Server\Data_Share” “D:\Data_Share” /NP /TEE /MT:32 /E /R:3 /W:5 /ZB /MIR /COPY:DT /LOG:”C:\Users\administrator\Desktop\data_share_log.txt”

 

The two commands/examples above are identical minus one attribute, /MIR. Typically, I use the first example to do the initial large copy. Let it run all night, and then check the log file on the desktop the following morning searching for the word ‘error’. If you have to postpone your ‘new server cutover date’, the second example comes in handy. It will only copy files from the source destination that are new or newer than what already is in the destination. It’s much more efficient than redoing the entire copy job, and very helpful for keeping the new directory up and in-sync with the source.

The full list of available robocopy attributes is available here. The quick reference for the ones in my example are here:

/NP – Specifies that the progress of the copying operation (the number of files or directories copied so far) will not be displayed.
/TEE – Writes the status output to the console window, as well as to the log file.
/MT:<N> – Creates multi-threaded copies with N threads. N must be an integer between 1 and 128. The default value for N is 8.
/E – Copies subdirectories. Note that this option includes empty directories.
/R:<N> – Specifies the number of retries on failed copies. The default value of N is 1,000,000 (one million retries).
/W:<N> – Specifies the wait time between retries, in seconds. The default value of N is 30 (wait time 30 seconds).
/ZB – Uses Restart mode. If access is denied, this option uses Backup mode.
/MIR – Mirrors a directory tree (equivalent to /e plus /purge).
/COPY:DT – Specifies the file properties to be copied. (D=Data, T=Timestamp)
/LOG:<LogFile> – Writes the status output to the log file (overwrites the existing log file).

Empty Recycling Bins For All Users

Many times on a Windows Server or PC you will have had multiple users log in at some point in time, and each user account has it’s own Recycling Bin. When getting cramped for free space, it can be handy to empty all Recycling Bin’s at one time, so you do have to, or can’t log into the other accounts:

Windows7, Server2008/R2, Server2012/R2

rd /s c:\$Recycle.Bin


WindowsXP, Vista, Server2003/R2

rd /s c:\recycler

Resize or Extend a Windows Disk

For Windows XP, Server 2003, and Vista, this will only work for data (Non C:\) partitions. It will work for all disks on Windows 7, 8, 2008/R2, 2012/R2 disks (including C:\).

NOTE: Be cautious, you can grow disks as many times as you want (up to 2TB) but not shrink them (in Vista, 7/8, 2008/R2, 2012/R2 you can shrink the partition but cannot shrink the underlying disk).

1. Allocate additional free disk space on the Disk

  • For VMs, you first must increase the VMs disk size using VMware vSphere client or Hyper-V Host server. Find the VM that you want to expand, edit the properties of its virtual disk to increase it. (see Adding/Editing VMware Virtual Disk)
  • For physical servers, move/remove partitions as needed

2. Confirm New Space

  • Back to the computer, right-click My Computer > Manage. Go to Disk Management, right-click and Re-Scan Disks if it hasn’t already shown the new extent. Confirm the new space is available on the same disk as the partition you want to extend.

3. Use DiskPart to Extend

Open command prompt as Administrator and perform the following:

  • >diskpart
  • >list volume
  • >select volume VOLUME_#_TO_BE_EXTENDED

To extend using all available space:

        • >extend

To use a portion of the available space

        • >extend size=SIZE_IN_MB_THE_PARTITION_SHOULD_BE_EXTENDED

If the partition still shows the same amount of free space it had prior to being extended, go back to >diskpart, select the volume and try:

    • >extend file system

4. Grab a beer.