In these cases, RoboCopy continues to attempt to retry the copying or moving the open files by pausing, and then retrying again repetitively with the following error message:
The process cannot access the file because it is being used by another process.
Waiting 30 seconds… Retrying…
RoboCopy will retry until the file is closed, i.e. the file no longer being used by any processes.
However, sometimes the open file may not be released by the process that use it for hours, days, weeks or even infinitely, such as database files. As such, it’s important to skip the open files encountered by RoboCopy to ensure that most files are copied or moved to destination.
To skip open files while replicating, use the /w:1 /r:1 switches (of course you can change the number to any integer you like). For example,
robocopy C:\ D:\ /w:1 /r:1
/R:n indicates number of retries on failed copies, such as those encountering on open files. By default RoboCopy retries for 1 million times.
/W:n indicates the wait time between retries. By default it is 30 seconds. If you want RoboCopy to skip any failed copy quickly, reduce it to lesser amount.