This error may occur if the reported folder is not accessible by the Service account on which the Backup is configured.
I use the below Robocopy command to backup my files to a network drive:
Robocopy “Source Folder” “Target Folder” /e /r:3 /w:1 /sec /mir /z /b /np /log:c:\Backup.log
As in the above syntaxes used below are the description of them:
/e: Copies subdirectories.
/r: Retry Option.
/w: Wait time.
/sec: Copies the security permission as same as the source folder.
/mir: Mirrors the directory tree. (Same as /e or /purge)
/z: Copies files in Restart mode.
/b: Copies files in Backup Mode.
/np: The progress of the copying operation will not be displayed. (% progress of each file)
/log: Creates a log file in the root directory so that you can have the details of copy.
For the error 5, it may be due to multiple reasons, include the below syntaxes to troubleshoot the error:
- You need to use the /FFT flag to assume FAT file times (2 second granularity). Although the target folder is Ntfs/Fat, these file systems also implement file times with 2 second granularity.
- You need to turn off the attribute copying. Robocopy uses the /COPY:DAT by default, which means to copy data, attributes and timestamp. You should turn off attribute copying by explicit setting /COPY:DT
This syntax should resolve the issue with Error 5 of Robocopy.
The Final Robocopy command would look like this:
Robocopy “Source Folder” “target Folder” /e /r:3 /w:1 /sec /mir /z /b /np /COPY:DT /FFT /log:c:\Backup.log
You may also get an issue where some of the automatic files generated by windows will not backup; these files may include Thumbs.db or Desktop.ini
You can exclude these file by adding the /XF syntax in the command.
You may also exclude some of the unwanted folder to be backed up from the command, for that you need to use /XD
Example command to exclude the unwanted files or folders:
Robocopy “Source Folder” “target Folder” /e /r:3 /w:1 /sec /mir /z /b /np /COPY:DT /FFT /XF *.ini thumbs.db /XD .trash /log:c:\Backup.log
Hope you have an error-free Backup :)
Other Posts related to backup: