Using Robocopy

Robocopy or Robust File Copy is a command line replicated directory program. This program is recommended by a friend from US. 

This program good, easy to use and help me in saving a lot of time in writing script.  What I like the most is the log function and can give me the correct information that I required.

The best is that It can copy a single 100G sql database data over a network to a NAS as a backup without any problem.

 

Below are the script that I had written to run backup:

set folder1=%date:~0,3% <– This is to set the day Example: Mon, Tue…etc. As I don’t need to create a lot of batch to copy to different folder. 

robocopy “M:” “E:\%folder%” /R:1 /W:5 /XO /ETA /NP /LOG+:C:\Scripts\Log\data.txt

/R: Tells Robocopy to retry ‘n’ times before giving up in the event of error (default is 1 million).
      (Set it to repeat 1 time to prevent it from repeating it 1 million time)

/W: Wait time between retries (default is 30 seconds).
       (Usually I set it within 3 to 5 second)

/XO: Exclude older files
        (It will copy only the new files and not the old files. This should help you to save a lot of time during the backup process)

/NP: No Progress
       (If you don’t disable the option and the log files will record the copy percentage into the log file)

/ETA: To show the estimated  timing of arrival of copied files
          (This is very good as you can see how much you each files take to copy over to another media)

/LOG+:file:  Output status to LOG file (append to existing log).
                    (It will record the backup status so that you are able to trace which backup is not done properly)

 

 robocopy1

 Figure 1 – The details of the log file created using Robocopy

 

I discover a way to copy selective files to other media as from most of the forum saying that it can only copy a whole from the folder.

Below is the script:

robocopy “M:” “E:\%folder%” DATA01.zip DATA02.zip  /R:1 /W:5 /XO /ETA /NP /LOG+:C:\Scripts\Log\data.txt

The script is about the same as the above. The only difference is that I put the files DATA01.zip and DATA02.zip which I want to from M drive to E drive. 

Of course, you have to make sure the drive is state correctly and the files you want to copy from this drive to other external drive.

 

I would highly recommended people to use robocopy for running backup of raw data and data migration.

No comments yet

Leave a reply