Powershell Robocopy backup script

Powershell Robocopy backup script


This PowerShell robocopy script allows you to copy files and folders from one location to another using mirroring and multi threading to speeding up the copy process. It will keep the original permissions on the new location


  • Show start and end time of the backup job
  • The duration for performance review
  • Amount of copied folders, data and skipped (if any)
  • Robocopy end-code results in case of any errors with needed catches (took a while!)
  • Source and destination address
  • Attach a log file
  • Send an e-mail to my admin account
  • Have nice feel to it

Robocopy basic command

robocopy.exe "$src" "$dst" /mir /mt:96 /r:3 /w:3 /np /ts /bytes /xd $exclude /log:"$log"

Options explained

  • /mir tells robocopy to use mirror mode
  • /mt:96 maximum of allowed threads increasing or decreasing this results in different end-times
  • /r:3 maximum set retry count
  • /w:3 maximum set wait time before a retry is executed
  • /np shows no progress
  • /ts include the timestamp of the source file
  • /bytes display progress in bytes for easy calculation
  • /xd $exclude exclude files that set in the “$exclude” variable
  • /log:”$log” specifies the logfile location by the “$log” variable
  • Detailed explanation from Microsoft

Like with all scripts improvements are ongoing.
Recent additions to the script was adding HTML with a clone feel of the Veeam mail report.

I use Veeam to backup my servers and so the look & feel goes hand-in-hand with a few modifications.

Example of the succeeded output is:

Example of the failed output is:


No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *