Solved

Reliable Copying - Robocopy?

Posted on 2004-09-12
7
1,025 Views
Last Modified: 2012-06-21
Hi

I am currently using Symantec's V2i Server Protector on a Windows 2003 Server and backing up (incrementals) hourly to a network share. This is working fine.

I wish to copy the files in the network share once a day (say 6pm) as a Scheduled Task to an external USB hard drive subject to the following requirements:

- I only wish new files to be copied to the external drive (ie nothing overwritten)
- I want the job to abort and cancel itself if the external drive is not available. Future jobs should still run however without any intervention.
- If an error occurs I would like this logged somewhere in the Windows 2003 Server Event logs and a network or SMTP-relayed email warning sent to one or more network users.

I have taken a look at Robocopy (the Windows 2003 Resource Kit is installed) and this looks to be fine but I wonder how reliable it is and whether it can cope with large files when a full backup is run once a week (~40Gb of data) without taking out the computer to which it is attached!

Can anyone advise on whether the above is possible and also the syntax needed please for whatever utility recommended.

many thanks

Rob
0
Comment
Question by:WebAdviser
  • 4
  • 3
7 Comments
 
LVL 83

Expert Comment

by:oBdA
ID: 12038772
First of all: robocopy is definitely the tool to use. It will handle the 40 Gb with a smile on its lips, singlehandedly, with the other hand tied to its back. The exact options to chose depend mainly on your situation; did you notice the robocopy.doc file in the ResKit folder?
To check if the USB drive is accessible, simply test its existence; if you have the W2k Resource Kit (unfortunately, it's not part of the free W2k3 ResKit tools), you can use logevent.exe to create an entry in the event log. For warnings in your network, you can use the good old "net send" (if the messenger service is running), and/or blat.exe to send an email from the command line.
You can schedule this with the regular task scheduler, running under a domain account with the appropriate permissions.
What's not quite clear is the "nothing overwritten" part; what is supposed to happen if an existing document in the backup folder has been changed?

Rough draft:

@echo off
set SourceDir=D:\FileRoot
set TargetDir=U:\Backup
if not exist "%TargetDir%" goto err_Target
...
robocopy "%Source%" "%Target%" -<YourOptions>

goto leave

:err_Target
logevent -m \\YourDC -s F "Backup job failed; USB drive not accessible."
net send SomeMachine "Backup job failed; USB drive not accessible."
blat.exe -t someone@your.domain.local -s "Backup job failed; USB drive not accessible." -f backup@your.domain.local
goto leave

:leave
0
 
LVL 83

Expert Comment

by:oBdA
ID: 12038774
Forgot the blat link, sorry:
What is Blat?
http://www.blat.net/
0
 

Author Comment

by:WebAdviser
ID: 12038836
Thanks oBdA. Your code seems just the job - fantastic response!

You asked: "What's not quite clear is the "nothing overwritten" part; what is supposed to happen if an existing document in the backup folder has been changed?"

This is a fair question. Perhaps some further explanation might be useful here...

The V2i backups consist of one .v2i file per week (full backup file) and one .iv2i file per hour written to the network share. All of the files are written into a single directory as read-only files so can't be changed. All I want to happen is for the files written to the network share since the last scheduled task to be copied to the external drive - not to re-write the whole directory each time to the external drive. This will give maximum efficiency.

In reality the situation is slightly more complex than this as backups are cycled over a period as obviously disk space on the network share (and the external drive) is not unlimited. At the moment the backup jobs cycle every three weeks with the oldest backup files being overwritten in order. I guess the full requirement for this task is for a full comparison of files in the network share and external drive to be undertaken each time the scheduled task runs. This is because as the backups are cycled the base file (.v2i) and ALL of its associated incrementals (.iv2i) files are deleted when a new base file is created.

I hope this makes some sense and possibly you can find a way to incorporate the above in your script.

thanks again

Rob







0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 83

Expert Comment

by:oBdA
ID: 12039004
So the "hourly" files have different names, and there's a new file added to the directory every hour? By default, robocopy won't copy files that already exist in the target directory and have the same size and date as the source file; have a look at the "Using Robocopy File Classes" section in robocopy.doc.
You might want to have a look at robocopy's /mir option; this will keep an exact copy of the source directory, where files in the target are removed automatically if they don't exist anymore in the source.
0
 

Author Comment

by:WebAdviser
ID: 12039033
thanks again oBdA.

So if I read your post and the Robocopy help correctly I could use your code with just /mir as the option then to achieve what I am looking to do?

Rob
0
 
LVL 83

Accepted Solution

by:
oBdA earned 500 total points
ID: 12039117
If you want the backup folder to be an exact replica of the original folder, that's the easiest option.
You might want to try the /r (number of retries) and /w (wait between retries) options to something useful, in case there are access problems.
As for checking if robocopy was successful, check out the "Return Code" section in robocopy.doc. In your case, it would probably be enough to check for an errorlevel larger than 4. If you create a log file (/log:"%LogFile%"), you can, for example, use the log file as the body of the email if a serious error occurred.
I'd suggest you check out the robocopy documentation and experiment a bit with it; the options are somewhat amazing.
The "Controlling Bandwidth Usage" section might be interesting for you as well, but that depends mainly on when you run the backup and whether robocopy really throttles your network.

@echo off
set SourceDir=D:\FileRoot
set TargetDir=U:\Backup
set LogFile=%Temp%\~Backup~.log

if not exist "%TargetDir%" goto err_Target
robocopy.exe "%Source%" "%Target%" /r:4 /w:5 /mir /log:"%LogFile%"
if errorlevel 4 goto err_robocopy
goto leave

:err_Target
logevent -m \\YourDC -s F "Backup job failed; USB drive not accessible."
net send SomeMachine "Backup job failed; USB drive not accessible."
blat.exe -t someone@your.domain.local -s "Backup job failed; USB drive not accessible." -f backup@your.domain.local
goto leave

:err_robocopy
logevent -m \\YourDC -s F "Backup job failed; errorlevel %Errorlevel% during robocopy."
net send SomeMachine "Backup job failed; errorlevel %Errorlevel% during robocopy."
blat.exe "%LogFile%" -t someone@your.domain.local -s "Backup job failed; errorlevel %Errorlevel% during robocopy." -f backup@your.domain.local
goto leave

:leave
0
 

Author Comment

by:WebAdviser
ID: 12039369
What can I say, fantastic answers!

Points to you oBdA and many many thanks.

Rob
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us need to configure DHCP server(s) in their environment. We can do that simply via DHCP console on server or using MMC snap-in on each computer with Administrative Tools installed in a network. But what if we have to configure many DHCP ser…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question