Robocopy command to transfer files from linux to Windows server

I have a about 2TB of files on a Linux serve that is accessible via Windows as a SMB share. From the windows 2012 r2, I like to copy the files and get a log files with only the files that it was not able to copy  . I have looked at the command options and a bit confused with to many switches.  I used Richcopy which is a Utility based on Robocopy , but it freezes and hangs halfway though. It has done great on most of the directories. I have a feeling it may be related to very deep folder paths or bad characters in the file names. Whould Robocopy be able to handle bad characters in the file-names.   ?
Who is Participating?
I haven't had robocopy choke on anything name related yet, but I never used a Linux share as a source.
robocopy definitely has no issues with long paths; it supports the full NTFS limit of about 32000 characters.
/mir (already includes /e) will mirror the source folder into the target folder, so after the copy, source and target will be identical; note that this means as well that robocopy will delete any files in the target that do not exist in the source.
What you definitely want to set is /r:n (retry, default 1000000) and /w:n (wait in seconds, default 30). In a reliable LAN, you can usually use /r:0.
Then to only log files that had errors, you need to use /ndl (no directory listing) and /nfl (no file listing); this will only exclude successfully copied files from the log, errors will still be logged.
"Skipped" in robocopy doesn't mean that the file was ignored; it means that the file was not copied, because it already existed in the target location (same date, same size); unlike copy/xcopy, robocopy will by default skip over those.
You best start the copy on the target server and use the local path as target.
So a starting point would be (do not use trailing backslashes in the path needs to be enclosed in quotes because of spaces in the path):
"\\LinuxServer1\SomeSMBShare" "D:\Some\Target\Folder" *.* /mir /r:0 /nfl /ndl /tee /np /log:"D:\Temp\robocopy.log"

Open in new window

*.* the file mask to copy (same as if omitted; just for reference)
/mir: as described above; to do a "normal" copy, replace with /e
/r:0: no retries on fails
/nfl /ndl: no file list, no directory list (log only header, errors, and the summary)
/tee: output to console and log file
/np: disables the progress bar for large files; the progress bar uses control characters that will end up in the log file and make it hard to read.
Note that with /nfl and /ndl, you won't (well, "shouldn't") see much of an output until the copy is done, because only errors will be written/logged. The only way to monitor the progress is to check the properties of the of the target folder.
If you are hitting a path limit or bad characters then I don't think Robocopy will help with that.
Cliff GaliherCommented:
If by "handle" you mean it will succeed, then no.  But it should accurately report errors that many GUIs choke on because of font selection, etc.  You'll at least have a list of failed files that you can work on moving another way (shortening the path, moving to an alternate location, renaming to remove bad characters, etc.)  Robocopy is far superior to RichCopy, I recall...all development was abandoned on years ago.
netcompAuthor Commented:
I have looked at the command options and a bit confused with to many switches. Can you all help me with a sample command . The destination is blank and does not need compression for now . I would like a log file with all the errors or skipped files.  I cam up with the following , but not sure what /MIR does and also not sure how to get the logs or add any additional switches that are needed.  I came up with this  ROBOCOPY \\Server1\Examplefolder \\Server2\examplefolder /MIR
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.