Making a DIY Command Prompt Back up Program

a small sheep logo

Lesson 8 - ROBOCOPY Options Part 4: Retry Options

There aren't very many retry options and as a result, there isn't much to this lesson. We will cover the retries, wait time, registry default, and low free space mode options. So basically we won't cover the sharenames to be defined option. Let's get started.

Retries and Wait Times: /R, /W, and /REG

It's possible that when you attempt to copy a file, the computer fails to actually copy it. If you've never encountered a random error on a computer I am shocked and confused, so this is hopefully a scenario you could imagine happening.

I such an event, you may like it if the program automatically tried to copy the file again. In that case, you use the /R option to specify the number of times it will retry.

There are a variety of reasons that files might not being copying over, from permissions issues, to maybe the computer is just too busy doing other stuff. So they gave us the option /W to specify the amount of time in seconds to wait between attempts.

You probably noticed the inputs section already gave values for these two options. The default values are /R:1000000 and /W:30. Your eyes do not deceive you, that is 1 million attempts and 30 seconds between each attempt. That's 30 million seconds, or 8,333 hours, or 347 days. Just to to copy a single file.

For our personal back up project, we definitely don't need that. So why not lower them? I suggest retrying 5 times with /R:5 spaced 10 seconds apart with /W:10. That will give us a perfectly good amount of time to fix the problem if we notice it and can fix it. Otherwise, it moves on after about a minute instead of 347 days.

The /REG option can be used to save whatever values you use for the /R and /W options as default values. This means you wouldn't have to specify them again if typing them in bothers you. To use it, just include it in the list of options along with either or both of the other two:

ROBOCOPY "C:\Users\Rob\Desktop\Original" "C:\Users\Rob\Desktop\Backup" /E /R:5 /W:10 /REG

will save the retries to 5 and wait time to 10 seconds as defaults. Next time you run ROBOCOPY, if you don't include the /R or /W options, you will see your new defaults in the inputs section.

Low Free Space Mode: /LFSM

This option can be used if you have concerns about filling up your back up location with too much backed up data. For example, say you have a 1 TB drive you are using as your backup, but you only want to keep 300 GB of free space on that drive. You can use /LFSM:300G to prevent the free space from going below 300 GB.

For the data units, K=kilo, M=mega, and G=giga

If you just use /LFSM without a number, the default is to keep the free space at 10% of the total size.

Suggested Options

I'm going to suggest we cut down on the number of retries and wait times.

/R:5 /W:10

Use /LFSM with number specified or not if you have concerns about free space of your backup location