Tuesday, July 9, 2013

Scheduling Robocopy, something I need to do WAY more of

Create a c:/scripts folder to house your robocopy bat script and create a backupfiles.bat inside of it.

This is an example of a robocopy line I use most often:

robocopy "C:\Source" "E:\Destination" /MIR /LOG:"C:\scripts\backupfileslog.txt"

Save this in your bat file.  The /MIR switch will mirror the source to the destination, copying the subfolders and purging stuff that no longer exists in the source.  The /LOG switch will output the job status to a file.

Launch taskschd.msc and under 'Task Scheduler Library' right click and Create Basic Task:

Give it a name and I usually schedule it daily early in the morning:

You are going to want to start a program and select your bat script:

Click finish and we need to make it so it runs when I am logged off the computer/server so right click on the job and click properties.  Under the General Tab select Run whether user is logged on or not:

Click OK and we are all set.  You can run the job now by right clicking on it and selecting Run.  Check your log file and you can see the status of the robocopy job:

This is a really easy way to make sure your important stuff gets backed up.  Robocopy doesn't do VSS so you can't copy locked files, for that look into Hobocopy: https://github.com/candera/hobocopy

Learn more about robocopy: http://ss64.com/nt/robocopy.html