[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
following:
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.
IF YOU ARE NEW, PLEASE PLAY WITH IT IN POWERSHELL CONSOLE FIRST, UNTIL YOU ARE HAPPY.
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.
NOTE: SEE LAST POST FOR FINAL VERSION