Here’s a little powershell script I used to solve a problem where I needed to synchronize MILLIONS of files quickly and be notified about it promptly once the operation has complete.

Normally, I’d take machine snapshots or something but this backup is native and sadly, it happens at the file level; it also requires a Microsoft OS to run natively on bare-metal. rsync isn’t fast enough as-tested. However, 128 threads of robocopy flies right through it!

Robocopy starting with Windows Vista *SHOULD* support multiple concurrent threads with the /MT switch.

# PowerShell Robocopy script with e-mail notification
# Created by Michel Stevelmans -
# needed moar variables and threads [ edit]

# Change these values, name your job, configure the paths
$job = "BLAH"
$DateAndTime = get-date -UFormat "%Y%m%d_%H%M%S"
$SourceFolder = "F:\REPORTS"
$DestinationFolder = "\\UNC_PATH\TO\SHARE\REPORTS"
$Logfile = "C:\LogFiles\$job-$DateAndTime.log"
$EmailFrom = ""
$EmailTo = ""
$EmailBody = "Robocopy Job: $job completed successfully. See attached log: $Logfile for details"
$EmailSubject = "Robocopy Summary: $job for $DateAndTime"
$SMTPServer = "some.smtp.server"
$SMTPPort = "25"

# Copy Folder with Robocopy
Robocopy $SourceFolder $DestinationFolder /R:1 /W:1 /MT:128 /MIR /XX /LOG:$Logfile /NP /nfl /ndl

# Send E-mail message with log file attachment
$Message = New-Object Net.Mail.MailMessage($EmailFrom, $EmailTo, $EmailSubject, $EmailBody)
$Attachment = New-Object Net.Mail.Attachment($Logfile, 'text/plain')
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, $SMTPPort)

Say something!

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

[ hamcomputers ]

Technical Support enthusiasts.

Happenin's in the 'Ham

We are here to keep you updated with all the free, cheap, and amazing events around Birmingham!

CaliBama Belle

A Southern Belle with a Golden State of Mind

We Share the Same Sky

Desiring but another day to ebb the pull, damn the flow and spend an evening wading creeks that meander.

Shedrick Flowers Photography

'dem sexy internets

The Immortal Jukebox

A Blog about Music and Popular Culture

The Bitcoin Wife

All things fresh and fabulous in the Bitcoin world.

Unlearning Economics

Musings on the Current State of Economics

Thought Catalog

Thought Catalog is a digital youth culture magazine dedicated to your stories and ideas.


'dem sexy internets

Bourbon & Kale

A Left Coast Guide to Longevity and Southern Guide to Sanity


'dem sexy internets

Jesse's Café Américain

'dem sexy internets


Bitcoin Stuff

Bitcoin Foundation

'dem sexy internets

The Monetary Future

'dem sexy internets

%d bloggers like this: