[DIY] Poor Man Backup wdcloud to PC

[EDITED] Final version.

I did this DIY backup of mycloud to my PC external drive because I don’t trust safepoint.

Problem with safepoints over network is that when I shut-down, wdmycloud loses the connection to the backup drives
and it cannot see safepoints any more. Although I can remount them again (they are not ereally lost it is just
that safepoint manager does not remember the connection. (I requested this feature to be added),
but I am fed up logging in and remounting and although I can do a script to auto remount, I don’t like changing wdmycloud.

So I wrote this script and have been using for few months. hopefully it can be useful to some.

The following script will create an exact Mirror of all the shares that you specify. So you can also exclude
what you  don’t want to back up.

I backup to an external USB 3.0 drive connected to my PC.

[TIP]: if you have 2 similar drives you can tell Windows to create a mirror drive. For example,
I connected 2 3TB drives. I created a mirror 3TB drive out of them. So anything I save on the mirror
drive will automatically (by Windows OS) create a duplicate copy. So in effect when I do a 1 backup I actually
have a redundant exact copy (all managed by Windows). If one drives goes down, Windows can automatically
recover the redundant copy. no effect on performance.

OK, this script uses native Windows “Robocopy” commandline application. It is super fast, multithreaded,
and can do incremental backup.

In the script you can specify which shares (variable $Shares) you want to back up, and where do you want to back it up to.

Then run it. First time (like any backup application),depending on the amount of data it might take
some time. Performance pretty good though, for example Robocopy output

Total Copied Skipped Mismatch FAILED Extras
Dirs : 28 28 0 0 0 0
Files : 235 235 0 0 0 0
Bytes : 235.424 g 235.424 g 0 0 0 0
Times : 0:38:53 0:38:51 0:00:00 0:00:01

Speed : 108403274 Bytes/sec.
Speed : 6202.885 MegaBytes/min.
Ended : 25 March 2015 21:00:56

As you can see 235+ Gig was copied in ~39 mins. That is 108+MB/s.
they are mixed files, one of them is Windows system image around 200G which I think gave it the boost
in speed.

The second time you run the script, it will only Mirror the changes, it will not copy files or folders
that were not changed.

NOTE: MIRROR, meaning, it will copy exactly what is in the source and delete what files no longer
exist in the destination. If you don’t want this behaviour, for some reason, you can the change one of
the flags in the script from /MIR to /E. But then you are not making exact copy. Up to you.

the script is as follows:

# Author Jamalya# Create 27/03/2015# Free to do what you like with it.# Base directory where to copy from - copy from mycloud $src='\\wdmycloud'# backup directory - change to suit yours$DST='E:\wdbackups'# we will excute Robocopy$Command='C:\Windows\System32\Robocopy.exe'# Flags to be passed to Robocopy - you can add or subtract flags - see help robocopy$FLAGS='/MIR /COPY:DAT /R:5 /W:5 /NP /MT:8 /LOG:$DST\backup.log'# Shares you want to backup - add your shares/files names in double quotes here separated by comma$Shares=@("Public")$LogFile = “E:\wdbackups\backup.log” # substite Your log file location and name ex. C:\xxxxxx.xxx$SmtpServer = “smtp.ntlworld.com” # substitute your smtp serverFunction DoBackup{        Param ( $Folder )    # construct the paths for source and destination    $FullSrcPath=$SRC+'\'+$Folder    $FullDstPath=$DST+'\'+$Folder    if ( Test-Path $FullSrcPath )    {        $Execute=$Command+' '+$FLAGS+' '+$FullSrcPath+' '+$FullDstPath        iex $Execute    }  }#Start backupFunction StartBackup {    # Go through all shares and back it up    foreach ($a in $Shares)    {        DoBackup $a    }}Function SendBackupAlert{    # Setup SMTP client    $Message = new-object Net.Mail.MailMessage    $Attachments = new-object Net.Mail.Attachment($LogFile)    $Smtp = new-object Net.Mail.SmtpClient($SmtpServer)    # Construct the message    $Message.From = “” # <-- Put an email here    $Message.To.Add(””) # <-- Put Your email here    $Message.Subject = “Nightly backup Log File” # <-- substitute your own Subject    $Message.Body = “The nightly backup log file is attached” # <-- substitute your own message body    $Message.Attachments.Add($Attachments)    # Finally send the email    $Smtp.Send($Message)}# start the backupStartBackup# send me an email when finishedSendBackupAlert# this will shut the computer down after 30 seconds of executing the command below# type "shutdown /?" (without quotes) to see other optionsinvoke-Expression -Command "C:\Windows\System32\shutdown /s /c 'End of backup'"

This is a Windows powershell script.

copy the above into a file and save with whatever name with extension ps. Example, mybackup.ps

Then run Powershell as administrator, and type the name of your file.

It will create a log file which you can refer to later to see what it did. You can change the location
of the log file. As it is, the log file is written to the destination directory.

I recommend you play with it on local directories first. Run it once, then make some changes to the
source and run it again. Watch log.  And go through the destination directory to observe what changed,
if any.

For testing all you have to do is change the variable $SRC in the script to a local directory, for
example $src=‘C:\Test’ and same for destination.
Similar thing for $Shares you can change them to directories (folders). This will mimic wdmycloud structure.

You can also experiment with Robocopy command on the CMD and make whatever changes that suit you.

This is a barebone script, which can be run as a scheduled task as well or whenever you wish manually.

Find schedule task in your Windows (usually under administrative tools) and create a new basic task
(if you are new to this) and set the options. Or choose create Task which has more advanced features. You can always go backto property of the task and change options.

When task scheduler asks for “Action” option, choose start a program, then it asks for program or script, type the

powershell -file “PATHTOYOURSCRIPT.PS”

You can further tune it in the property of the task you have just created.
That is it. it will now run however and whenever you have scheduled it.


Of course if you lost your data on the device, or did a full reset, you can restore by reversing the
source and destination.

I did not have to do it so far. But please practice the script first to do backup and restore on a test directory.
Say Goodbye to slow safepoint backups.

CAVEAT: You have to switch on your PC near the schedule time.
inconvenience VS peace of mind.

I am using Windows 8.1 pro.
Gigabit Netgear switch for PC and wdcloud, switch connected to Netgear router. Router connected to
Virginmedia HUB (cable modem).
USB 3.0 mirror 3TB drives (2 3TB) connected to PC which holds the backup.

Of course you can only use 1 USB drive or internal drive.
Maybe works on the cloud, I haven’t tested it yet. But will run a test on DropBox folder
(backup to DropBox folder which will auto synchronize).

[TIP] on a command line run

roboopy /?

To see all the switches (flags) you can use to further customise the $Flags in the script to your liking.


Reformatted the script, went completely wrong here.

if you get an error while trying to execut the script in Powershell, type

Set-ExecutionPolicy Unrestricted

and you can execute scripts.

If you like a version of Robocopy that is GUI driven you can try




Or this https://technet.microsoft.com/en-us/magazine/2009.04.utilityspotlight.aspx


I quickly tried it and works fine but I did not use it.


If you are using the backup script, add the following line right at the end

# this will shut the computer down after 30 seconds of executing the command below
invoke-Expression -Command "C:\Windows\System32\shutdown /s /c 'End of backup'"

This will shtudown the computer when the script ends.

there are other options to hibernate or log off etc.

in powershell window type

shutdown /? to see all options.

Final Script version

this will backup your shares

send you an alert with the log attached

shutsdown the computer

(Save the script somewhere as xxxxx.PS1, open as administrator a powershell console and just run the file by typing its name on the console. see first post how to schedule it to run daily, weekly, monthly etc …)

(this can also work the other way round, from PC to my cloud… by adjusting, source, destination etc… in the script)

See comments in the script.

# Author Jamalya
# Create 27/03/2015
# Free to do what you like with it.

# Base directory where to copy from - copy from mycloud 

# backup directory - change to suit yours

# we will excute Robocopy

# Flags to be passed to Robocopy - you can add or subtract flags - see help robocopy
$FLAGS='/MIR /COPY:DAT /R:5 /W:5 /NP /MT:8 /LOG:$DST\backup.log'

# Shares you want to backup - add your shares/files names in double quotes here separated by comma

$LogFile = “E:\wdbackups\backup.log” # substite Your log file location and name ex. C:\xxxxxx.xxx
$SmtpServer = “smtp.ntlworld.com” # substitute your smtp server

Function DoBackup
    Param ( $Folder )
    # construct the paths for source and destination

    if ( Test-Path $FullSrcPath )
        $Execute=$Command+' '+$FLAGS+' '+$FullSrcPath+' '+$FullDstPath
        iex $Execute

#Start backup

Function StartBackup 
    # Go through all shares and back it up
    foreach ($a in $Shares)
        DoBackup $a

Function SendBackupAlert

    # Setup SMTP client
    $Message = new-object Net.Mail.MailMessage
    $Attachments = new-object Net.Mail.Attachment($LogFile)
    $Smtp = new-object Net.Mail.SmtpClient($SmtpServer)

    # Construct the message
    $Message.From = “” # <-- Put an email here
    $Message.To.Add(””) # <-- Put Your email here
    $Message.Subject = “Nightly backup Log File” # <-- substitute your own Subject
    $Message.Body = “The nightly backup log file is attached” # <-- substitute your own message body

    # Finally send the email

# start the backup

# send me an email when finished

# this will shut the computer down after 30 seconds of executing the command below
# type "shutdown /?" (without quotes) to see other options
invoke-Expression -Command "C:\Windows\System32\shutdown /s /c 'End of backup'"

Bump for recent query

OK, I have learnt how to create scripts and have done one with the content you’ve provided. I have been to robocopy help and better understand the flags. But it is not clear to me how I should set the flags or alter the script so that it will do a partial back up. For instance, how can I set a date/time and then instruct robocopy to produce a file that contains the additions/alterations/deletions since that time? TIA … Greg


It can of what you want. Of course you have to map that drive. you can then backup from one drive to another. You just need to change source and destination in the script ($SRC and $DST). Don’t forget to change SMTP as well if you need email alerts $SmtpServer, Also change $LogFile to point to your backup same $DST but just add the logfile name you want, example:

$LogFile = “\yourlogfilename.log”

I am not sure what you mean package?

Just copy the above into your favourite text editor. do the changes, save it. Then run a commandline such as Powershell (As administrator) and run the script (just type its name in the shell).

Hi gvm77

In the script, there is a variable called $Flags. between the single quotes are the flags for robocopy, you can delete or add (in your text editor) what you need there (just keep the single quotes). Just experiment to get what you want (make a backup of a working script just in case).

Just open the scripts in an editor and do the changes and the save it and run from a powershell (as administrator).

The Log file will record all changes, what was deleted or added etc. If I understood you correctly.

Ok, but when I read the description of the flags in the robocopy help
manual it wasn’t clear how to set them in order to achieve an incremental

the script as it is does incremental backup via the option /MIR. First time it copies everything. Afterwards only copies what have been changed (deleted, added, etc).

thank you, I will give it a go

I tried running the script on my laptop and there were access restrictions that I thought would be easy to avoid if I used my home PC instead. However now I get the powershell message the script “cannot be loaded because the execution of scripts is disabled on this system. Please see “get-help about_signing” for more details.”

I learnt that I had to change the security policy and found out about the command “C:\PS>Set-ExecutionPolicy Unrestricted”. But how do I use this? I ran CMD.exe as administrator and entered it but this command is not valid. I tried including it in the Powershell script but that didn’t change anything because presumably the script failed to run before seeing the command.

I am running Powershell as Administrator (by right clicking the exe icon then selecting ‘run as administrator’. My system has only one user and it has Admin rights but I can’t change the Powershell properties so that it always runs as Administrator. The option is greyed out. Is this indicative of the cause of my problem?

Bottom line is I don’t know what to do to make Powershell run my script. Any help would be much appreciated, TIA … Greg

HI probably too late now, sorry. But I am assuming you have entered the full string in the quotes which will not work.
When you enter the shell as administrator you only to enter “Set-ExecutionPolicy Unrestricted”. Without the quotes. Hope the helps

Excellent, thank you very much jamalaya!

The script runs and produce a back up copy. But if you don’t mind I have two questions:

The backup looks like a synchronised copy, rather than a backup taken at a point in time from which I can restore an old file if need be. For example, I modified a document, ran the script again, and the modified doc seems to have overwritten the previous version. Have I done something wrong?

Secondly, less important, the email didn’t send. Can you see why from this please? …
Exception calling “Send” with “1” argument(s): “Failure sending mail.”
At C:\Users\Family\Desktop\cloud backup.ps1:67 char:15

  • $Smtp.Send <<<< ($Message)
    • CategoryInfo : NotSpecified: (:slight_smile: [], MethodInvocationException
    • FullyQualifiedErrorId : DotNetMethodException

TIA … Greg

It sounds like it is making a true backup. If a file gets deleted/changed/modified in any fashion then that is reflected in the backup. It is not keeping a version history of what has been changed.

I would like to help you on the second question but I am still learning powershell myself and that is a bit over my expertise.

Robocopy is just a file copy utility - albeit more sophisticated than normal standard copy and very fast and multithreaded, It is not a dedicated backup utility so it does not keep history versions. For that kind of backup you will need dedicated backup application. Unless of course you keep multiple copies with different dates but that is a huge waste of space.

it is called Poorman Backup for a reason :slight_smile:

Ok, fair enough. Can I ask how you think Microsoft’s Synctoy compares with
your solution? … Greg


it is almost the same thing. However, it is a lot easier and simpler to use, it has a GUI, and can be scheduled. Still has no version history.

For version history,. you could probably use something like this: http://www.acebackup.com/download.htm

which is also FREE but a bit old (2012) .