Scheduled task : Error 0X3 but Log doesn't give any error - scheduled-tasks

I have several tasks using Robocopy.exe, On One of those tasks, I get a error result 0X3 but the log file doesn't display any error.
Here is the command :
ROBOCOPY \\X\L$\FORMATION \\Y\O$\FORMATION /MIR /sec /W:2 /R:5 /log:c:\O_journal.log
I tried to launch it without the task scheduler, it worked fine without ant errors.
I know that the error 0X3 is : ERROR_PATH_NOT_FOUND.But the log file doesn't display any error.
If someone have any clue or any methods...

This is a standard behavior and relates to exit codes from Robocopy:
0×00 0 No errors occurred, and no copying was done.
The source and destination directory trees are completely synchronized.
0×01 1 One or more files were copied successfully (that is, new files have arrived).
0×02 2 Some Extra files or directories were detected. No files were copied
Examine the output log for details.
0×04 4 Some Mismatched files or directories were detected.
Examine the output log. Housekeeping might be required.
0×08 8 Some files or directories could not be copied
(copy errors occurred and the retry limit was exceeded).
Check these errors further.
0×10 16 Serious error. Robocopy did not copy any files.
Either a usage error or an error due to insufficient access privileges
on the source or destination directories.
And a combination of them, ie: 0x03 = 0x02 + 0x01
See https://blogs.technet.microsoft.com/deploymentguys/2008/06/16/robocopy-exit-codes/ for a complete explanation.

This is an issue to the path configured on the robocopy script. I have fixed this issue by adding the root directory or the main drive to both source and destination.
Note: Please make sure that you are an administrator to both Servers (source and destination)
Example:
Source: "\\192.168.1.2\e$\my files"
Destination: "\\192.168.1.5\d$\backup"
The root directory or the main drive that I have referred is the "e$" and "d$" as shown above. If this will not included in your script, you will be encountering the "0X3" error in the Scheduler and the scheduler will not works.
Note: This script is to synchronize/replicate the file from the source to destination.
Parameters used. /MIR /E /Z /R:5 /W:5
This is how the script looks as a whole:
robocopy "\\\192.168.1.2\e$\my files" "\\\192.168.1.5\d$\backup" /MIR /E /Z /R:5 /W:5
Hope this might help.
Thanks.
Xian

Related

Robocopy with logs

I want to use robocopy for one copying work where whole directory and it's subdirectories with files needs to be copied, but also the log files must contains the logs of copied as well skipped files details. I was using below command robocopy src dest /e /logs:dest
But it's not working for me, can anyone please suggest the required command that can be used for this purpose. Thanks.

RMDIR does not delete nested directories path greater than 255 length

I am using below command inside the batch file and running via task scheduler in my server , it deletes most of the nested files/folders but when path length exceed 255 it does not delete those files/folders. Is this issue with RMDIR , What are other alternatives , Robocopy Delete ? Has somebody faced this issue and robocopy was able to solve this issue for them , something like below ?
RMDIR "Path-location" /S /Q -- Does not delete files/folder > 255 length
Robocopy : You need to create empty folder before executing below commands :
robocopy "C:\empty" "C:\Test Folder" /purge
rmdir "C:\Test Folder" // Once all files/folders are deleted now remove your parent/root directory
This is normal behaviour. To be exact, the limit is defined as 260 characters (source). You have multiple options to circumvent this limit:
You can raise this limit to 65535 characters by adding/setting the registry value HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled of type REG_DWORD to 1. This works since Windows 10, version 1607 (read more). Reboot your machine after this change.
You can use robocopy in combination with the /PURGE parameter to synchronize an empty folder to the folder that contains the long file paths as you already found out. This might get complicated if you do not want to delete everything, but only certain files.
You can use UNC paths to describe long paths. Change
C:\very\long\...\path
to
\\?\C:\very\long\...\path

How to perform two ROBOCOPY statements from one source folder to two destination folders in one batch file?

I have an interesting situation where I'd like to move some files from directory X to directory Y, but in order to MOVE the files without deleting the source folder, I created a log statement in said folder. A very simple version of what I'm doing is this:
robocopy
"C:\Desktop\Origin" "C:\Desktop\Destination"
/e /move /XF "C:\Desktop\Origin\test.log"
/log:"C:\Desktop\Origin\test.log"
This results in the moving of all files in "Origin" directory to "Destination" directory, and doesn't get rid of the "Origin" directory, as the "/e /move" flags normally would. Now, if I didn't want that log file, I could simply add this line to the code:
del "C:\Desktop\Origin\test.log"
But, I actually do want to keep this log file. I just want it somewhere else. So what I've been trying to do is to move it to directory Z with "/e /mov" or even just "/s" and then the delete. For example:
robocopy
"C:\Desktop\Origin" "C:\Desktop\Destination"
/e /move /XF "C:\Desktop\Origin\test.log"
/log:"C:\Desktop\Origin\test.log"
robocopy
"C:\Desktop\Origin" "C:\Desktop\Destination 2"
/s
del "C:\Desktop\Origin\test.log"
But after trying multiple times, with multiple little variations, nothing seems to happen. The first robocopy happens, but the second doesn't seem to happen at all. It seems like multiple robocopy statements can run in one batch file (which is what I want) but perhaps not from the same source directory. Does anyone know why this is the case and also how I can achieve my stated goal? Thanks!
Thanks to the suggestion of Ken White, I found a solution to this. If you use MOVE.EXE, it works just as expected.
robocopy
"C:\Desktop\Origin" "C:\Desktop\Destination"
/e /move /XF "C:\Desktop\Origin\test.log"
/log:"C:\Desktop\Origin\test.log"
move
"C:\Desktop\Origin\test.log" "C:\Desktop\Destination 2"
One thing to note is that you can't use /LOG+: with this method, since you'd be writing the log file to a location where no log file exists, since it had been moved previously to "Destination 2". However, even the normal log files include the *EXTRA files already in the directory.

How do I remove skipped files from output of robocopy?

I have a drive with several TB of data, most of which doesn't change often. When I run robocopy the spew contains reams and reams of skipped files. I'd like to run /L to see what will be copied and what will be deleted before mirroring to my backup drive, but there is so much noise in the log due to the skipped files that sorting through it is time-consuming.
How do I tell robocopy to log only those files that are copied or deleted?
i have found this switch useful to reduce the amount of unnecessary output
/ndl Specifies that directory names are not to be logged.
All robocopy Parameters

Robocopy Error 3 "System cannot find the file specified" for 1 file in the folder

I am trying to copy a folder from the network path to my machine .But while copying the folder the robocopy suddenly got stuck in copying 1 file from the folder and did not proceed forward . I am seeing the error ERROR 3 (0x00000003) , "The System cannot find the path specified." , even though the file did exist in the source directory.
The command that I use is
ROBOCOPY source destination /MIR /Z /Log+:logs.txt
I am seeing this issue when my executable is triggered by the task scheduler. This issue does not happen when i run the exe directly. Any idea why this could be happening and also how to fix this problem
When robocopy claims it cannot find a file, it often means it is running into permission issues. If your script works from the command line, but not from the task scheduler, make sure the task uses your user credentials. You can set them in the task properties on the general tab under security options.