Robocopy backup script query

Associate
Joined
16 Nov 2007
Posts
811
Hello

I am in the process of writing some scripts to automatically backup my home server data to other remote drives. I am planning to use Robocopy commands in a script set to run via task scheduler.

It's the first time I've played with such a thing and have noticed a warning in the guide linked below

http://www.sevenforums.com/tutorials/187346-robocopy-create-backup-script.html

The warning suggests that the "MIR" option (and presumably using /E and /PURGE) could delete files from the source folder. This is naturally of concern to me.

In testing my scripts though, I cannot seem to replicate an instance of deleting files from the source folder.

Is the guide factually incorrect or could Robocopy introduce such a problem?

A sample of one of my commands is pasted below for reference.

robocopy "\\SERVER\Temp" "\\STORAGE\Temp" /E /PURGE /V /NP /R:10 /W:30

I posted in here as I'm assuming this sub-forum attracts more users who use such commands. I originally posted a query in the Windows forum but didn't receive much response.

Thank you for your time,

Mike
 
This is a script I was previously using to backup F: to Y:, its just something I grabbed from the net and modified slightly but worked fine for over a year. I only stopped using it because I switched to a Linux server.

Code:
robocopy F:\ Y:\ /XD F:\$RECYCLE.BIN /XD "F:\System Volume Information" /e /mir /np /log+:backup_log.txt

Unfortunately I never did try removing files from the backup destination although the website I got the script from originally did say that the source files would also be removed.
 
Last edited:
/MIR and /PURGE will delete files on the source directory. I'm guessing if you're making backups, you don't want this.
My opinion is that Robocopy is a copying program, if you want to delete stuff, use specific commands.

For doing backups, you probably want something more like this:
robocopy "\\SERVER\Temp" "\\STORAGE\Temp" /ZB /E /COPYALL /R:3 /W:5 /MT:64 /LOG:"C:\Path\To\Log\File.txt"

A quick breakdown:
/ZB will allow you to backup locked files, if you happen to have a movie or photo open, this is good.
/E is discretionary, you might not want to copy empty directories.
/COPYALL this retains all of the NTFS file attributes. This is good because it's nice to see 'file created' or 'file modified' even after moving the file 10 times.
/R and /W are obvious.
/MT multithreads the amount of transfers happening at one time. 64 threads is tuned more for large file shares (100,000 items+). If you have a few very large files, you'll want to turn this figure down.
/LOG gives you a log with the CMD output you'd normally see. Very handy to see skipped files etc. You could combine this with /NP if you want a tidier log, but sometimes the % a copy reaches is an important factor in diagnosing a failing copy.

I haven't used /V so I can't comment.
 
Last edited:
Thank you both very much for your replies.

I can't seem to get the script to work with the extra switches you mention, not sure why but I'll explain my installation / intended usage for context. For example, I started with my base script and added the /COPYALL switch but it failed to work, likewise adding in the /ZT and /MT switches.

I have a Windows home Server 2011 installation with the hostname of "server", the shared folders of which I wish to back up on a 2 weekly basis to a Thecus NAS drive with hostname "backup".

I therefore regard "server" as the source and "backup" as the target.

** To confirm. I wish for the "backup" files to be a direct mirror of what is on the "server" at time of copying, even if that means files on "backup" are deleted because they have been deleted on "server" some time in the past 2 weeks.

I've modified my script as below

robocopy "\\SERVER\Temp" "\\BACKUP\Temp" /E /PURGE /V /NP /R:3 /W:5 /LOG:"\\BACKUP\Temp\~Backup Log.txt"

This has been tested and (appears to) meet my needs.

What I'm worrying about though and what I still don't understand, is that you (Yamahahahahaha) have indicated that the /PURGE switch has the ability to delete files from the source as opposed to the target. Are you 100% certain of this? If so, please can you let me know how to replicate this for testing purposes?

Just to confirm, I'm 100% happy with files being deleted from the target folders, that is my proposed usage, to have a direct mirror of what is contained on the source.

Thank you for your time and sorry to question your feedback, I just want to be 100% certain before I role it out and rely on it!

Thank you

Mike
 
xcopy c:\*.* \\backupserver\backupdrive /s/e/v/d/c

personally I'd say scratch the /d so you know if there are read errors on the source or destinateion

(/d copies only altered files which is faster but does not let you know if the files are ok)
 
Thanks for all your input. After some testing this weekend, I've decided to go with FreeFileSync instead.

What are you copying to? As Uhtred says, if your destination does not use the same time granularity as your source, then every file will be marked as 'old' on the next robocopy run and everything will re-copy.
If it's a Thecus NAS, then check their site as numerous firmware updates have "broken robot copy". Which basically means they screwed robocopy and don't respond to support requests about it.
Ah, just read your reply... Thecus. Caused me so much grief I ended up selling mine and buying a micro Proliant for £120 less than I got for the NAS! Yes, Thecus have broken robocopy for all us end users. I say vote with your keyboard and open a support job with them and harass them until they admit they broke it and they aren't going to fix it, then sell it and tell them you're telling all your friends never to buy Thecus.

FYI, I had an N4100+, but gather the same problem is present on many models.
 
Last edited:
...
Ah, just read your reply... Thecus. Caused me so much grief I ended up selling mine and buying a micro Proliant for £120 less than I got for the NAS! Yes, Thecus have broken robocopy for all us end users. I say vote with your keyboard and open a support job with them and harass them until they admit they broke it and they aren't going to fix it, then sell it and tell them you're telling all your friends never to buy Thecus.

Thank you for this insight. This explains why I couldn't get Robocopy to work properly between my server and NAS. As you say, one of the problems was the fact that it tried to copy every single file instead of incremental.

Freefilesync appears to do everything I need. I've created a script and rolled it out last night.

Thank you all.

Mike
 
Thank you for this insight. This explains why I couldn't get Robocopy to work properly between my server and NAS. As you say, one of the problems was the fact that it tried to copy every single file instead of incremental.

Freefilesync appears to do everything I need. I've created a script and rolled it out last night.

Thank you all.

Mike

its a bad idea to only do an incremental, all your photos could have CRC errors in the on your PC because hte HDD is failing... then your backup drive could start to go nad you dont know the back drive had an issue until your PC drive dies or you realise your stuff is corrupt
 
Back
Top Bottom