I'm trying to use robocopy to move files to a remote machine. This is being done on a Windows machine through a file script.sh
that is executed inside Git Bash.
Background
First I use net use
to add the shared directory:
NET USE \\\\$DEPLOY_SERVER\\$DEPLOY_SHARE /user:$DEPLOY_SERVER\\$DEPLOY_USER $DEPLOY_PASS
This works fine.
Issue
Then I go to copy the files with robocopy
:
robocopy . \\\\$DEPLOY_SERVER\\$DEPLOY_SHARE\\$DEPLOY_DIR /MIR
which fails with error code 16.
From the robocopy docs, 16 is 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.
Running it without /MIR
works fine with no errors.
Error log
When run with /MIR
I get the error:
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows
-------------------------------------------------------------------------------
Started : Mon Dec 18 15:46:26 2017
Source - C:\<path to current dir>\
Dest - \\<deploy server>\<deploy share>\<deploy dir>\
Files :
Options : /COPY:DAT /R:1000000 /W:30
------------------------------------------------------------------------------
ERROR : Invalid Parameter #3 : "C:/Users/<my user>/AppData/Local/Programs/Git/MIR"
Simple Usage :: ROBOCOPY source destination /MIR
source :: Source Directory (drive:\path or \\server\share\path).
destination :: Destination Dir (drive:\path or \\server\share\path).
/MIR :: Mirror a complete directory tree.
For more usage information run ROBOCOPY /?
**** /MIR can DELETE files as well as copy them !
Further error description
This happens for any options, not just /MIR
, this is just the simplest form of the error.
I've read many questions very similar to this, the common answer is to put your paths in double quotes in case there are spaces. My paths do not have spaces but I've tried that as well and got the same error. Additionally this would result in the "Source" and "Dest" paths in the robocopy
output to be incorrect, but they are correct for me.
I have no idea why I would be going to that git
directory and looking for MIR
, or why it's not just parsing the options correctly. Additionally I checked and MIR
does not exist inside C:/Users/<my user>/AppData/Local/Programs/Git/
.
Research
Other questions that are similar but didn't help me:
- invalid parameter in robocopy syntax
- Robocopy showing invalid parameter
- robocopy invalid parameter “-”
- Robocopy Invalid Parameter #7 Log
- https://www.experts-exchange.com/questions/22616754/Robocopy-Error-Invalid-Parameter-3.html
- robocopy says its receiving invalid parameters in when used in powershell script
- Robocopy - Invalid Parameter
- Robocopy invalid parameter #3
Conclusion
Any help would be greatly appreciated! I'm also open to using something other than robocopy
, but it would need to work with a remote machine, be runnable from a shell script, support mirroring, and not use ssh
(net use
works for robocopy so ideally something else like that).