Solved

Backup with Robocopy

Posted on 2015-02-06
47
170 Views
Last Modified: 2015-02-23
Hello,

I am wanting to configure a backup job to copy a shared directory from one external HD to another on the same machine.  Initially, I want to create an exact copy of the existing 300 GB shared folder on the backup HD, then run a daily scheduled task with robocopy to only backup files that have changed since the full backup.  I am somewhat familiar with robocopy but have had some issues with it, especially copying 300 GB of data at once.

Thanks,
Mike
0
Comment
Question by:cheesebugah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 22
  • 12
  • 9
  • +1
47 Comments
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 167 total points
ID: 40594040
schtasks /create /ru system /sc daily /st 08:00 /tn Backup /tr "robocopy H:\Folder T:\Folder /e /s /mir"

Should be all you need...(run from an elevated cmd prompt)
0
 
LVL 2

Accepted Solution

by:
Marc L earned 333 total points
ID: 40594059
I would use the following in a scheduled task (task requires elevation):

robocopy <source> <destination> /MIR /COPYALL /ZB /R:5 /V /FP /Log:<path to log file>

/MIR - mirrors the directory tree, deletes destination files and folders that don't exist in the source
/COPYALL - copies all file information (data, attributes, time stamps, security, owner, auditing)
/ZB - uses restart mode, and if files are in use, copies using backup mode
/R:5 - sets retries to 5 (default 1,000,000), so if it runs into any issues you still get as much of the backup as possible

For logging:
/V - verbose
/fp - full path names
/log - sets a path for the log file to be written
0
 

Author Comment

by:cheesebugah
ID: 40594092
So I am creating a command prompt task to run robocopy, right?
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

Author Comment

by:cheesebugah
ID: 40594118
What would I actually put in the Run: and Start in: textboxes?  This is what is currently in those textboxes:

Run:  C:\WINDOWS\system32\cmd.exe

Start in:  C:\WINDOWS\system32
0
 
LVL 2

Assisted Solution

by:Marc L
Marc L earned 333 total points
ID: 40594148
You could run robocopy directly:

Run: c:\windows\system32\robocopy.exe
Start in: c:\windows\system32
Arguments: <source> <destination> /MIR /COPYALL /ZB /R:5 /V /FP /Log:<path to log file>

Or you could save the command in a script
save 'robocopy <source> <destination> /MIR /COPYALL /ZB /R:5 /V /FP /Log:<path to log file>' as the first line in a text file, and rename it to c:\script.bat
Run: c:\script.bat
Start in: c:\
0
 
LVL 25

Expert Comment

by:NVIT
ID: 40594169
If you want to keep the folder timestamps, also use the /DCOPY:T switch
0
 

Author Comment

by:cheesebugah
ID: 40594181
I am backing up this location, E:\User Files.  The User Files root directory is not present on the destination.  Do I have to create the F:\User Files root folder, or will robocopy create it if I use:

robocopy "E:\User Files" "F:\User Files" /switches

Thanks,
0
 
LVL 25

Expert Comment

by:NVIT
ID: 40594185
Add trailing backslash:
robocopy "E:\User Files" "F:\User Files\" /switches
0
 
LVL 2

Expert Comment

by:Marc L
ID: 40594192
It will automatically create the destination directory
0
 

Author Comment

by:cheesebugah
ID: 40594705
Will the log files be created each time this runs or overwrite each time?
0
 
LVL 25

Expert Comment

by:NVIT
ID: 40594751
/log: overwrites
/log+: appends
0
 
LVL 2

Expert Comment

by:Marc L
ID: 40594756
It overwrites it each time, if you use the parameter /Log+:<log file> instead it will append it to the existing log file
0
 

Author Comment

by:cheesebugah
ID: 40594757
Would there be a selection that creates a new log file for each run?
0
 
LVL 25

Expert Comment

by:NVIT
ID: 40594771
If you want a unique log name each time you run the backup, you could use something like:
/log:Backup-%date:/=_%-%time::=_%.txt

Open in new window

0
 

Author Comment

by:cheesebugah
ID: 40594818
I'll just append to the existing.  The /MIR switch is not going to delete anything from the source will it?
0
 
LVL 25

Expert Comment

by:NVIT
ID: 40594841
/MIR deletes, if any, at the target. So that the target is a mirror of the source.

I find that trying it out on a small, test folder helps build confidence that it will work.
0
 

Author Comment

by:cheesebugah
ID: 40595006
First run on an almost 300 GB folder is scheduled for tonight.  We shall see what happens.  I will update this post when the verdict comes in.  Thank you guys for all of your help.  It is greatly appreciated.  Keep up the great work.

Thanks,
Mike
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 40595109
Depending on the system specs, you might also consider multi-threading to speed up the transfer.
Add a /MT:16 (8 is the default if no value supplied).
0
 

Author Comment

by:cheesebugah
ID: 40598516
For some reason the task did not even run over the weekend?
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 40598627
There is a file that should give you details on the reasoning located in
%systemroot%\tasks\SCHEDLGU.TXT

Perform a search of the string
[ ***** Most recent entry is above this line ***** ]

and you should be able to pinpoint the record of the event...
0
 

Author Comment

by:cheesebugah
ID: 40598666
Sorry, but that file is not present.  I must have screwed up the scheduling somehow?  Although at this point it is not clear to me in looking at it?
0
 

Author Comment

by:cheesebugah
ID: 40598684
In that location you mentioned, it says the task ran at its scheduled time on Friday, yet there is no log file or the mirroring of the shared folder as expected?
0
 

Author Comment

by:cheesebugah
ID: 40598696
The only thing I can think of is that this task is being run under a command prompt and when CMD opens, it cannot find the script file to run because it is set to run on the root of C: in the task?
0
 

Author Comment

by:cheesebugah
ID: 40598700
The script file is located in the root of C:, but when CMD opens, I don't think it opens to that location and would have to be instructed to go to that location?  I don't know, just my thought on it.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 40598735
My preference is to schedule it from a cmd line, which helps (me) avoid some of these hiccups.
Yet, if your script is in the root, and it's simply calling robocopy - that file is in your path, so it shouldn't cause any problems.
Try heading your script off with some logging:

echo.  Beginning backup script >> c:\backups\Logfile.txt

Does that file get created and populated?

Another thing that comes to mind - make sure the task is set to run as highest elevation - there's a checkmark on the settings for that...
0
 

Author Comment

by:cheesebugah
ID: 40598823
I did a test run with a simple text file located in a folder on the source.  I could see the command prompt briefly run, but no log file and no mirroring of the folder and file?  Here is my simple script:

robocopy "E:\Test 1" "F:\Test 1\" /MIR /COPYALL /ZB /R:5 /V /FP /Log+:C:\Robocopy\Logs\UserFilesBU.log

Am I missing something here?

Thanks,
0
 
LVL 25

Expert Comment

by:NVIT
ID: 40598948
What do your scheduled task options look like?
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 40598965
Is it set up to run with highest privileges?
0
 
LVL 25

Expert Comment

by:NVIT
ID: 40598989
Program: robocopy
Add arguments: "E:\Test 1" "F:\Test 1\" /MIR /COPYALL /ZB /R:5 /V /FP /Log+:C:\Robocopy\Logs\UserFilesBU.log

As sirbounty mentioned, set "Run with highest privileges"
0
 

Author Comment

by:cheesebugah
ID: 40599047
Well, as it turns out, you have to put quotes around the path in the Run: textbox.  When creating the task, that is not automatically done.  I guess it is assumed you will not have any spaces in the path?  Anyway, my test run ran perfectly with the quotes around it and we should be good to go.  I don't think this is something that can complete in 12 hours though, so I'll have to schedule it again for this weekend.  I will let you guys know.  Thank you for all of your help.  It is greatly appreciated.

Thanks,
Mike
0
 
LVL 25

Expert Comment

by:NVIT
ID: 40599059
Just a friendly reminder, Mike.
Do you need to keep the folder timestamps? If so, add the /DCOPY:T switch. Else, the folders will have the current date.
0
 

Author Comment

by:cheesebugah
ID: 40599094
Does this apply to the files contained within those folders also?
0
 

Author Comment

by:cheesebugah
ID: 40599096
Any particular sequence to apply that switch in the command?
0
 
LVL 25

Expert Comment

by:NVIT
ID: 40599099
It applies to the folders only. It shouldn't matter where you put the switch.
0
 

Author Comment

by:cheesebugah
ID: 40599100
What about the /W:   switch?  Might be advantageous?
0
 
LVL 25

Expert Comment

by:NVIT
ID: 40599105
I'm pondering the utility of that switch... Has there ever been a time I wanted to keep the file dates but not the folders'? No. Maybe they were rushed to get it out. IDK... Have a nice day, all.
0
 
LVL 25

Expert Comment

by:NVIT
ID: 40599111
I think /W is used when files might be open, e.g. worked on by users. In your case, the /W: switch has no use.
0
 

Author Comment

by:cheesebugah
ID: 40599113
I believe the /w switch is the wait time between retries if I am not mistaken?  The default is 30 seconds.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 40599143
Correct, default wait is 30 seconds.
/ZB is backup/restartable mode meaning it should be able to deal with file locks, in most, but possibly not all, cases.
0
 
LVL 25

Expert Comment

by:NVIT
ID: 40599149
/Wait between /Retries. Yes. Some files, when opened by users and processes may be locked. If robocopy can't copy these, it will try after the /W:timeout

In your case, cheese, I believe you are copying files you know are free.

For cases like this, I set it to /W:2 /R:2. This makes the job finish faster. Also, use the /LOG switch. Then, you can review any /W and /R entries later, if any, and copy those manually.
0
 

Author Comment

by:cheesebugah
ID: 40616914
Hello,

I am finally getting back to this topic after being sick for several days.  The /DCOPY:T switch was causing the script to hang.  I had to take it out.  Might have something to do with an older version of robocopy?  I don't know.  Anyway, the script is still running as of this morning.  What is weird is in the log file, it shows the /PURGE switch, which is not in the actual command?  Anyone know why this switch would mysteriously show up in the log file?  

Thanks,
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 40617050
If you're using /MIR switch, it's basically the same thing as using /E /PURGE
and is translated that way in the log file.
0
 

Author Comment

by:cheesebugah
ID: 40617093
Okay, cool.  I can't believe the thing is still running and only about a quarter of the way finished after 4 and a half days!  I guess that's what you're going to get on an 11 year old system.

Thanks
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 40617168
were you able to use multi-threading (/MT:xx)
0
 

Author Comment

by:cheesebugah
ID: 40617213
I did not include that in my script.  I bought a USB 3.0 adapter card for the server, but have had all kinds of issues with this server, so I am reluctant to install it, seeing as how things are running okay now.  What kind of performance improvements have you seen with this switch?

Thanks
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 40617423
I've not done a side-by-side comparison, but can only say that it has helped in scenarios where the system had enough mojo to enable it....
0
 

Author Closing Comment

by:cheesebugah
ID: 40627098
Thanks for all of your help.  This seems to have done the trick.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

VM backups can be lost due to a number of reasons: accidental backup deletion, backup file corruption, disk failure, lost or stolen hardware, malicious attack, or due to some other undesired and unpredicted event. Thus, having more than one copy of …
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…

622 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