Robocopy
Jump to navigation
Jump to search
Copy files in powershell using RoboCopy
Remote to local
robocopy "\\192.168.1.1\main\dir" "D:\downloads\folder" /e /r:0 /w:0 /COPY:DAT /DCOPY:DAT /mt:16
Notable Options with Robocopy
/e - Copy all folders including empty ones /r - Retry times /r:0 means no retry on failed copy /w - Wait time /w:0 means no wait between retry on failed copy /COPYALL OR /COPY:DATSOU - Copy Data, Attributes, Timestamps, Security, Owner, and Auditing Info for files /DCOPY:DAT - Copy Data,Attributes and Timestamps for Directories (Other Options are E=EAs-Extended Attributes, X=Skip alt data streams, but are almost never used) /MT:n - Multithread transfer with n threads. Example /MT:4 - Use 4 threads to copy files. If no threads set, it will default to 8. /MIR - Mirror Source to Destination - WARNING: WILL DELETE ANY FILES THAT DO NOT MATCH IN DESTINATION! /MOVE - Moves from Source to Destination - WARNING: WILL DELETE ALL FILES FROM SOURCE AFTER COPY! /LFSM:100M - Operate in Low Free Space Mode with 100 Megabytes. 10M = 10 Megabytes 1G = 1 Gigabyte /B - Backup Mode - Great for system backups if you are part of Administrator or Backup Users group - NOT RECOMMENDED - Use 3rd party backup software /ZB - Restartable Backup Mode - Tries to copy files with restartable and if it fails it restarts in backup mode - NOT RECOMMENDED - Use 3rd party backup software /RH:1700-0900 - Scheduled run between 5PM and 9AM and will pause if it is during “business hours of 9AM-5PM” /LOG+:C:\robocopy.log - Outputs everything to C:\robocopy.log (Note: if NOT running as admin you need to put this in your user folder C:\Users\username\robocopy.log) the + adds to the file. /TEE - If using LOG and you also want console output, put the /TEE option in.