Robocopy only copies files without folders - powershell

The problem is: With this command, only files are copied, the folder structure is not copied. What can I do to fix it?
robocopy \\FSMTT2\P$ H: /J /MIR /COPYALL /ZB /W:5 /R:2 /XJ /XD "System Volume Information" "$Rec*"
"Boot" /XF "pagefile.sys" /mT:128
The problem is: With this command, only files are copied, the folder structure is not copied. What can I do to fix it?

If you are using /MIR not need to use /COPYALL.

Related

Robocopy log differentiate copy from update

I had THOUGHT that RoboCopy logs could show the action for individual files, i.e. differentiate between a file copied new because it didn't exist in the destination vs file updated because it does exist but is different. But the last time I worked with RoboCopy was Windows 7, and now in Windows 10 I am not seeing anything that looks like a way to get that information in the logs. Am I misremembering, and that was never an option? Or did that functionality get removed? Or am I just missing the argument to make that happen?
FWIW, this is my argument string at the moment
RoboCopy $sourceFolder $destinationFolder /mir /mt /fft /copy:dat /r:10 /w:5 /log:$mirrorLogPath /njh /ns /nc /np

Robocopy Error 64 (0x00000040) when copy specific file extensions to SharePoint

i am using a Windows 10 64bit laptop to copy a bunch of folder and files to a SharePoint folder.
My Script is running in PowerShell.
If i try to copy the files and folders with the explorer (strg+c and strg+v) everything except .exe files are copying.
.exe files are blocked from the server.
If Robocopy is trying to copy the same set of folders and files:
First i use: Get-Credential
then: Connect-PnPOnline
and then copying with Robocopy.
If i copy the complete bunch of the folder i use following code:
ROBOCOPY $orgPath $newPath /MIR /dcopy:DAT /copy:DAT /r:0 /w:1
Robocopy is then working with this options:
*.* /S /E /DCOPY:DAT /COPY:DAT /PURGE /MIR /R:0 /W:1
If i just copy single files i use:
ROBOCOPY $orgPath $newPath $fileName /dcopy:DAT /copy:DAT /r:0 /w:1
Robocopy is then working with this options:
/DCOPY:DAT /COPY:DAT /R:0 /W:1
$orgPath = the path of the folder i want to copy (local or network drive)
$newPath = the path of the folder where i want to copy to (SharePoint)
$fileName = the file i want to copy
I just copy if the folder/file is not existing already.
With both versions i get the same result.
This is working fine. Robocopy is copying.
The folders and the most files (.xmlx .txt) are copying
The .exe files get the error 222 because the server is blocking this file. That is normal and i understand why he is doing it.
BUT:
.pdf files do not copy with robocopy. This files gives the error 64 (0x00000040).
So the server is not blocking this file. (i also can copy this file using the explorer) but all the .pdf files getting this error using robocopy.
But of course the connection is still working. robocopy is still copying further the .xmlx and .txt files.
The error is relating to the extension.
But i do not know why and i do not know how to solve the problem.
The Name of the .pdf files do not have any special caracters.
Does anyone can help me to fix the problem?
Thanks in advance
With best regards
Matze

Robocopy is not working in PowerShell

I am trying to run a robocopy script in PowerShell so I can insert it into my other PowerShell script:
$SERVERPATH = "E:\Cisco Config Backups"
$NETWORKPATH = "\\SERVER\Cisco Config Backups"
robocopy $SERVERPATH $NETWORKPATH /E /XC /XN /XO /R:0 /W:0 /COPY:T /LOG:C:\logs\robocopy_logs\config_copy.log /TEE /NP
However when I run this code I see robocopy working where it gives me the following output:
ROBOCOPY :: Robust File Copy for Windows
Started : Thursday, June 30, 2016 1:52:56 PM
Source : E:\Cisco Config Backups
Dest : \\SERVER\Cisco Config Backups
Files : *.*
Options : *.* /TEE /S /E /DCOPY:D /COPY:T /NP /XO /XN /XC /R:0 /W:0
But nothing gets copied over, I want to use robocopy for the logging and so I can have it skip files that already exist.
Please let me know if I am doing anything wrong.
The /COPY:T criteria is specifying to only copy file timestamps, so it is not copying the actual data of the file. However, since there are no files on the destination to copy the timestamps to, nothing happens.
You need to specify at least /COPY:DT so that the file data will be copied, but you can probably just remove the /COPY switch completely as you likely want the file attributes as well, which will get copied by default along with the file data and timestamps.
From robocopy /?:
/COPY:copyflag[s] :: what to COPY for files (default is /COPY:DAT).
(copyflags : D=Data, A=Attributes, T=Timestamps).
(S=Security=NTFS ACLs, O=Owner info, U=aUditing info)
You also need to review all of the switches you are using as some are conflicting--not sure what robocopy does in those cases. As Matt points out in the comment below, you have /E and /S. Do you want to copy empty subdirectories or not? /E specifies to copy empty directories, but /S specifies to NOT copy empty directories.

Robocopy Only Output Copied Files

I have the following Robocopy command. Currently it outputs all directories it is traversing during the mirror but I only want it to output what actually got synced from source to destination. I'm not seeing a "only show differences" option in the documentation.
robocopy "C:\inetpub\example.com" "Z:\D Drive\Projects\example.com\Web\example.Web" /mir /xd "C:\inetpub\example.com\wp-content\mu-plugins\example-network" "C:\inetpub\example.com\wp-
content\plugins\example" "C:\inetpub\example.com\wp-content\themes\example" ".git"
Of course I figured it out right after I posted the question. Here is my new command. The /fp /ns /ndl options did the trick.
robocopy "C:\inetpub\example.com" "Z:\D Drive\Projects\example.com\Web\example.Web" /mir /fp /ns /ndl /xd "C:\inetpub\example.com\wp-content\mu-plugins\example-network" "C:\inetpub\example.com\wp-content\plugins\example" "C:\inetpub\example.com\wp-content\themes\example" ".git"
Meaning of switches
From SS64 entry:
/FP : Include Full Pathname of files in the output.
[...]
/NS : No Size - don’t log file sizes.
[...]
/NDL : No Directory List - don’t log directory names.

robocopy /MIR - don't delete desktop.ini in destination

I want to sync folders between two computers, one with XP and one with Vista. I want the two folders mirrored, except for security settings and folder settings. It is my understanding that /MIR switch will delete any 'extra' files in the destination folder, which would include the desktop.ini files. I can avoid copying desktop.ini files with /XA:SH How can I prevent robocopy from deleting the destination desktop.ini files?
If I have to do any extra scripting, I prefer PowerShell. But I hope robocopy can do it on its own.
Thanks.
/XF desktop.ini
Will exclude Desktop.ini (from copy or purge).
Replace the /MIR switch with /E, and don't use the /PURGE parameter.
Explanation: /MIR is the equivalent of using /E /PURGE, so by using /E without /PURGE, you achieve the results you desire.
Create a bat file so you can mirror the source at the destination and later once the mirror process is finish erase the files you desired.
For example:
robocopy SOURCE DEST /E /PURGE or /MIR or /E
command to erase recursively (test the command before running at production):
del /s DRIVe:\DESTINATION\desktop.ini
Hope this helps,
Luis