Robocopy appears to do nothing when /MT flag is used - robocopy

This command works:
robocopy \\build7\d$ d: *.* /mir /XD "System Volume Information" /XD "$Recycle.Bin"
But when I try adding the /MT flag:
robocopy \\build7\d$ d: *.* /mir /XD "System Volume Information" /XD "$Recycle.Bin" /MT
The only output I get is
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows
-------------------------------------------------------------------------------
Started : Thu Apr 09 09:11:27 2015
Source : \\build7\d$\
Dest : D:\
Files : *.*
Exc Dirs : System Volume Information
$Recycle.Bin
Options : *.* /S /E /COPY:DAT /PURGE /MIR /MT:8 /R:1000000 /W:30
------------------------------------------------------------------------------
It gives me that output, and then just sits there.
I tried using the /LOG flag to redirect the output to a file, but it still just sat there with the same output, only in a file.
Is it doing something in the background that I can't see, or am I doing something wrong?

In my experience, what you are seeing is normal. When Robocopy runs using multiple threads (/MT), the output is limited to exceptions (new file, extra dir, error, etc...). It will not show you the directory names with the file count that you are probably used to seeing. That means that if the target is largely in-sync with the source, you will not see much output.
I don't know exactly why this is the case. I assume that Robocopy handles the directory walking differently when there are multiple threads involved. This difference probably makes the normal output impossible (or meaningless) to produce.
When I am running Robocopy with multiple threads, I often use the Disk tab in the Windows Resource Monitor to see what Robocopy is doing. How to Use Resource Monitor

Related

How do I protect against file corruption when using robocopy restartable mode?

I have a powershell script that that copies published files for a web app to a server for deployment. It utilizes robocopy to copy the files. Due to lack of administrator privileges, I can only use restartable mode (/z) and not restartable mode with backup mode (/zb). My question is two parts:
How reliable is robocopy using restartable mode- how likely are files to become corrupted?
What would be the best way to incorporate into the script a check to see whether a file has corrupted during the copying process?
Here is a sample of my code:
robocopy /s /z /ndl /r:0 /w:0 /mt:32 .\Publish "DESTINATION_HERE" /MIR

Robocopy - ERROR 124 (0x0000007C) Creating Destination Directory

Hoping someone familiar with Windows 10 and Robocopy can help.
I am using the following robocopy command in backup script that is being run as Administrator (yes the real Administrator user ID)
runas /user:Administrator backup.bat
robocopy N:\FNL E:\FNL /MIR /E /Z /R:1 /W:1 /V /NP /LOG+:backup.log
As long as there have been no new files for directories created in the source folder, in this case N:\FNL it seems to run fine. As soon as I create a directory, for example "Fred", I get the following error:
ERROR 124 (0x0000007C) Creating Destination Directory N:\FNL\Fred
The system call level is not correct.
I have changed file permission for "Authenticated Users" to Full Control and as well have taken ownership of all folders and sub-folders/child objects on the target drive but still get the same error.
Anyone have an idea what I might be doing wrong?

Power Shell Script Open and Close a webpage after Network is opened

Hello Stack community I have been trying to search this for a while now but can't seem to find anything. All I want to do is launch a webpage using iexplorer.exe "www.myserverIP.com\dev\emailme.php" It is suppose to be an air gap kind of server that turns on its connection takes a backup of multiple other servers then shuts off its connection. In between turning it on and off I want it to visit my wamp server to run a php script to send me an email of when this happens :D I already made the PHP script. Any other ideas are completely welcome as well I always love trying something new!
Code is provided below:
# Monday Backup Script
#7zip path:
$path = "C:\Program Files\7-Zip\7z"
$date=get-date -format "%M.%d.yy"
#:: /COPYALL :: COPY ALL file info
#:: /B :: copy files in Backup mode.
#:: /SEC :: copy files with SECurity
#:: /MIR :: MIRror a directory tree
#:: /R:n :: number of Retries
#:: /W:n :: Wait time between retries
#:: /LOG :: Output log file
#:: /NFL :: No file logging
#:: /NDL :: No dir logging
# Open Network
netsh interface set interface ethernet enabled
# Alert for Backup
iexplore.exe "http://172.20.255.3/NeikoDev/Backup%20emails/Backup%20Emails.php"
taskkill /IM iexplore.exe /F
# ^^^ THIS IS THE CODE THAT DOESNT WORK FOR THIS ^^^^**
# Wait for network to come online
sleep 120
# Backup NAS to local
ROBOCOPY "\\10.0.5.100\PrivateData\." "D:\PrivateData\." /COPYALL /B /SEC /MIR /R:0 /W:0 /LOG:C:\backups\LOGS\Monday\Monday.txt
ROBOCOPY "\\10.0.5.100\PrivateData1\." "D:\PrivateData1\." /COPYALL /B /SEC /MIR /R:0 /W:0 /LOG:C:\backups\LOGS\Monday\MondayPrivate1.txt
ROBOCOPY "\\10.0.5.100\PrivateData2\." "D:\PrivateData2\." /COPYALL /B /SEC /MIR /R:0 /W:0 /LOG:C:\backups\LOGS\Monday\MondayPrivate2.txt
ROBOCOPY "\\10.0.5.100\PrivateData3\." "D:\PrivateData3\." /COPYALL /B /SEC /MIR /R:0 /W:0 /LOG:C:\backups\LOGS\Monday\MondayPrivate3.txt
ROBOCOPY "\\10.0.5.100\HomeworkArchive\." "D:\HomeworkArchive\." /COPYALL /B /SEC /MIR /R:0 /W:0 /LOG:C:\backups\LOGS\Monday\MondayHomeworkArchive.txt
ROBOCOPY "\\172.20.255.125\PortableDeviceFilesArchive\." "D:\PortableDeviceFilesArchive\." /COPYALL /B /SEC /MIR /R:0 /W:0 /LOG:C:\backups\LOGS\Monday\MondayPorDevArch.txt
ROBOCOPY "\\172.20.255.3\wamp\." "D:\3wampBackups\." /COPYALL /B /SEC /MIR /R:0 /W:0 /LOG:C:\backups\LOGS\Monday\MondayWAMPSERVER.txt
ROBOCOPY "\\172.20.255.123\wamp\." "D:\123wampBackups\." /COPYALL /B /SEC /MIR /R:0 /W:0 /LOG:C:\backups\LOGS\Monday\MondayWAMPSERVER123.txt
# Wait for files to finish
sleep 60
# Zip logs
& $path a Monday.zip Monday*.txt
# Copy to network
cp Monday.zip "$date.zip"
cp "$date.zip" "\\10.0.5.100\PrivateData\Resource\Network\backuplogs\Monday\$date.zip"
# Wait for network traffic to stop
sleep 120
# Close network
netsh interface set interface ethernet disabled
As you mentioned in your own comment (by the way, please edit your question instead of commenting on it in the future), this can be done by using an Internet Explorer ComObject:
$IE=new-object -com internetexplorer.application
$IE.navigate2("www.microsoft.com")
$IE.visible=$true
# do more stuff until done with IE
$IE.Close()
This way you have better control over IE, and can do things like check if a page is still loading, which I imagine yours would be while running scripts, or if not perhaps your script can forward to a new page when completed, or make some change that your comobject can detect, so you know when to move on or close the site.
You haven't described what the problem is when the script hits line 21. I'm going to assume, without running your script, that the previous line is successfully retrieving the web page within IE but the desired effect is that this window is immediately closed, whereas the taskkill command is failing to shut IE.
If what you want is for the web address to be hit without leaving an open browser window, I would suggest a simpler way to go about this is to request the web address directly from PowerShell and skip the browser altogether.
One way to achieve this in PowerShell v3 is to use Invoke-WebRequest like so:
Invoke-WebRequest -Uri "http://172.20.255.3/NeikoDev/Backup%20emails/Backup%20Emails.php"
But there are similar alternatives outlined here: http requests with powershell

Robocopy Invalid Parameter #7 Log

I've been cracking my head trying to fix this. But it seems this command line isn't working for my robocopy batch file. It has something to do with the parameters, quotation marks, backslashes or maybe I'm just blind. I'm not too sure. Here's the code.
REM #Echo Off
SETLOCAL EnableDelayedExpansion
Set hostname=%COMPUTERNAME%
set torun=wmic bios get serialnumber /format:value
for /f "tokens=2 delims==" %%a in ('%torun%') do set serial=%%a
Set src="D:\BackUPTEST\%serial%"
set dest="D:\RestoreTEST\%serial%"
set logdest="D:\RestoreTEST\%serial%\Logs"
set logfile=Restore-%serial%.log
set log="%logdest%\%logfile%"
robocopy %src% %dest% /E /R:3 /W:3 /TEE /log:%log% /NP
echo Restore Completed. . .
ENDLOCAL
Echo On
I'm returned with...
ERROR : Invalid Parameter #7 :
"/log:D:\RestoreTEST\CNU1293K2J\Logs\Restore-CNU1293K2J.log"
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 !
Just been hit by the dreaded "Invalid log parameter"!
Been using it for a year or more without problem, running on a network drive, then Robocopy V10 hit my machine a few days ago and it stopped working with the following message:
'\\SEAGATE-435DC3\usb1-1share1\BACKUP'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
C:\Windows>robocopy X:\Documents Y:\BACKUP\Documents /s /XO /FFT /DST /TEE /NP /R:2 /W:5 /LOG:robocopy_docs.log
2016/11/10 19:07:47 ERROR 5 (0x00000005) Opening Log File C:\Windows\robocopy_docs.log
Access is denied.
So you now need to specify the path to the log file, then it works!
(Y: is mapped to \SEAGATE-435DC3\usb1-1share1)
Okay, figured out. As for Logging, there should be an existing Folder. So I simply added mkdir %logdest% before the robocopy command initializes... That seems to fix it.

please give the command in Robocopy i should use to copy the files from primary server to the secondary server

I got the command in robocopy as mentioned below
ROBOCOPY Source Destination [file…[file]…..] [Options]
Source: Source Directory
Destination: Destination Directory
Files: files to copy .
Please let us know what does the "\server\share\path" means? Kindly provide me an example on this command syntax and explain
An example of a ROBOCOPY call would be
ROBOCOPY C:\Users \\SERVER\backup\Users /MIR /R:0 /W:0
This copys everything under C:\Users to a network share at the UNC path \\SERVER\backup. If you don't know, what that means, google for 'UNC path' or find a nice tutorial that explains how to setup network shares under Windows.
Instead of \\SERVER\backup, that copies to a remote machine, you are totally free to use something like H:\ to copy to a local drive like a USB mass storage device.
The part /MIR /R:0 /W:0 are options of ROBOCOPY. Call ROBOCOPY /? to get an explanation for these.
Cheers,