Presentation Project
CMIT 215-02 Microsoft Client Operating Systems 
Christine Dunnells  

 
                                                                                                                          
  • What is Robocopy?        

 It is basically a command line tool that is very efficient at copying and mirroring folders and directories. Robocopy offers a lot of useful and reliable features, like for example, the ability to copy file permissions and attributes over, resume where it left off after a disconnect, copy only new or changed files, and much more.

NOTE:  For the purposes of this “How to” tutorial, I will stick with the basics needed to create a batch file that will run Win 10 Robocopy to perform a one-way sync of files between two devices on a scheduled basis.                                                                              


                                                                                                                            

  • What will you need?  
    Free bullets for web pages  Robocopy (already included in Windows Vista or later)
                      -Accessed through the command line
    Free bullets for web pages  Batch File
                    -Simple notepad (included with Windows) to write your command into
    Free bullets for web pages  Scheduler
                    -Windows Task Scheduler (included in Windows OS)

                                                                                                                                                                                                                   

  Robocopy-baseline 
     command:                                                                                                                              
 
 
[Command] [Source Location][Directory/Folder path] [Destination Location][Directory/Folder path]

  Robocopy                C:             \Desktop\robocopysource                 F:                       \robocopybackup
 
Translation:        The “robocopysource” folder and all of its contents that is located on my desktop is going to be backed up to my external flash drive currently located at F: drive and renamed as “robocopybackup”. This is the foundation. No commands have been applied yet.

NOTE: Robocopy copies folders and files within those folders, not single files. Your files must be in a folder, your destination must be a folder also.
Example:

Robocopy C:\Desktop\robocopysource F:\robocopybackup                                                                                    
                 
                    

 

  • What about syncing?

 

Here is where you will add the command that will perform a one-way mirror of the source to the destination.

/mir 
Adding the /mir command copies all of the sources directory tree and everything in it, to the destination. This is essentially the /purge command used with /E.
BE Careful: Because this is an exact mirror of the source copied to the destination,
any folders in the destination that are no longer in the source folder, will be
removed from the destination!


Example:

Robocopy C:\Desktop\robocopysource F:\robocopybackup /mir

 

To leave folders in the destination that are no longer in the source:

/XX Excludes files and directories tagged as “extra”

 

You could instead just use /E to effectively copy all directories and subdirectories form source to the destination without deleting anything from the destination. 

 


 

  • Here’s How it Works
You can see it copied 2 Directories: my “1st folder” and “2nd folder”.
  • I am going to make a change in my source folder by adding another folder called “3rd folder

 

 

Here you can see that it copied the one new folder named “3rd folder” and skipped
over the original 3,
 as no changes have been made to those, and a copy already
resides in the destination folder.

 


Free bullets for web pages  How to create a batch file:
 
  • Simple…open up Notepad by typing notepad into the search bar. This will open up notepad.
 

 

 


Type your code into the notepad, and save the file as a .bat file. This makes it an executable set of commands called a batch file. 

NOTE: The command prompt windows appears by default. If you would like turn off viewing the command prompt window, type the ‘echo off’ at the beginning of the text file. To prevent viewing of a specific command line, type @echo off at the beginning of the command line

 


 

Free bullets for web pages  Schedule the Robocopy 

     to run:
 
  • You can schedule your Robocopy batch file to run using Windows Task Scheduler. Type task scheduler into the search bar. Hit enter. 

 

  1. Click on Action on the top toolbar, and choose Simple Basic Task.
  2. Name your task in the box, then click next.
  3. Choose when you would like for your task to run, then click next.
  4. Now choose when you would like for your first task to start, and the time you would like it to run.
  5. Next you decide what it is you want the task to perform. Here we will choose start a program.
  6. Next is where you choose the program you would like the scheduler to start. This is going to be the batch file that you created. Browse to where you saved the batch file, select it, then hit next.
  7. Here you click Finish.
  8. Now lets make sure the program runs in elevated mode. Back at the main screen of the scheduler, browse through the Task scheduler library until you see the task you just created. Double click to open it. In this window, you want to check the box at the bottom that says, Run with highest privileges. 
You are done!

 


 

  • Other Switch Commands:

 

NOTE: 

Issue the robocopy /? command in the command line prompt to see a list of Robocopy commands.


There are many commands you can use depending on what it is you are trying to accomplish. I will name a few basic and most used commands here:

Scheduling:

/mon:[# of changes before copying] This ‘monitors’ changes made, and starts the sync when the number of changes has been reached.
Copy a folder to a backup folder specifying the number of changes that will take place before this copy is executed.
    Robocopy C:\Desktop\robocopysource F:\robocopybackup /mon:10
        NOTE: Here I have set it to copy after 10 changes have been made.

/mot:
[# of minutes before running again] This monitors for changes and runs again when the elapsed time specified has been reached.
    Robocopy C:\Desktop\robocopysource F:\robocopybackup /mon:10 /mot:30
 

 

Copying:

/E Copy ALL subdirectories (includes empty ones)

/S Copy subdirectories (excludes empty ones)

/Copy:DATS or /SEC Copies security information over

/PURGE Deletes all files and directories in destination that no longer exist in the source

/MIR Mirrors a whole directory tree in source…deletes files in destination that aren’t in source. Equal to /purge + /E

 /IS Includes files tagged as “same”
/IT Includes files tagged as “tweaked”
/R:[#] Specifies number of retries on failed copies.

/W:[seconds] Specifies the amount of time between retries

 

Changed, Newer, and Older files are copied by Default. Tweaked files are not copied or identified, so use the /IT command so Robocopy will make the distinction between Same and Tweaked files, and copy these files over.
 

 


 

Bibliography:

(n.d.). Retrieved April 04, 2016, from http://burpee.smccme.edu/studenthowtos/robocopy.htm

Beginners Guides: Understanding and Creating Batch Files. (n.d.). Retrieved April 04, 2016, from http://www.pcstats.com/articleview.cfm?articleid=1767

Get to Know Robocopy for More Powerful File Management. (n.d.). Retrieved April 04, 2016, from https://technet.microsoft.com/en-us/magazine/ee851678.aspx

How To Write A Simple Batch (.bat) File. (n.d.). Retrieved April 04, 2016, from http://www.makeuseof.com/tag/write-simple-batch-bat-file/

How to schedule a Batch File to run automatically on Windows. (2011). Retrieved April 04, 2016, from http://www.thewindowsclub.com/how-to-schedule-batch-file-run-automatically-windows-7

Robocopy /MIR switch – mirroring file permissions. (n.d.). Retrieved April 04, 2016, from https://blogs.technet.microsoft.com/filecab/2008/07/31/robocopy-mir-switch-mirroring-file-permissions/

Robocopy.doc. (n.d.). Retrieved April 04, 2016, from http://theether.net/download/Microsoft/Utilities/robocopy.pdf

Robocopy: Can MIR or PURGE delete files from Source ? (n.d.). Retrieved April 04, 2016, from https://social.technet.microsoft.com/Forums/windows/ko-KR/93da73cf-5261-484f-9e81-f532747bf6b1/robocopy-can-mir-or-purge-delete-files-from-source-?forum=w7itproinstall

Schedule RoboCopy. (n.d.). Retrieved April 04, 2016, from https://social.technet.microsoft.com/Forums/windowsserver/en-US/a2647339-41e1-48ea-9bb2-71b9e51a5b29/schedule-robocopy?forum=winserverfiles

Two-way folder sync with robocopy. (n.d.). Retrieved April 04, 2016, from http://stackoverflow.com/questions/33022584/two-way-folder-sync-with-robocopy

Using robocopy with source and destination as variables. (n.d.). Retrieved April 04, 2016, from http://stackoverflow.com/questions/19956249/using-robocopy-with-source-and-destination-as-variables

Windows 7 help and support forum. (n.d.). Retrieved April 04, 2016, from http://www.sevenforums.com/tutorials/187346-robocopy-create-backup-script.html

Windows command line robocopy command help and information. (n.d.). Retrieved April 04, 2016, from http://www.computerhope.com/robocopy.htm

 


 

 

 


 

 

© Christine Dunnells 2016
chrissyspcrepair@gmail.com