Link to home
Start Free TrialLog in
Avatar of Indyrb
IndyrbFlag for United States of America

asked on

Robocopy batch script help

I have a batch script that uses robocopy to copy data from one file server (2003) to a new files server (2008R2 or 2012)

I have been running the tool on the destination server, thats why dst= local drive path.

The thing is its not copying all the data... I would also like to mirror exactly what is on the old server to the new server.
And security settings dont appear to be correct.  I do not want to purge, move, or delete the data off the old server.
I want to setup a task or perhaps use the mon or mopt switches to run at specific times every night, until we are ready to turn the switch over.

Fianlly the log out put is a bit hairy... I just want to know what copied and if it was sucessful or failed, for both files, and directories
Of course I want all folders, and subfolders and all files within the given path.

/MIR /SEC / COPYALL?

I dont really know how the /XO /xd operates, but maybe its excluding files somehoW That should be mirrored.
I also want to  copy all hidden files, read-only, system, achieved, and etc. except for the list of items below.

[Files:]

Thumbs.db ~*.*
*.swp
*.dmp
*.tmp
pagefile.sys
hiberfil.sys

[Folders:]

MCAF*.TMP
"$VAULT$.AVG"
"_RESTORE"
"MSOCache"
"Recycled"
"RECYCLER"
"Temporary Internet Files"
"System Volume Information"
"temp"


This is the simple robocopy that was made, but its not using the /MIR command, and when I try to add it, it just sits there and does nothing.
Also the output lists all the files and etc. I just want a summary as forementioned.

Any help to make this perfecto.




@echo off
cls

set src=\\oldserver\f$\share
set dst=E:\share
set swt=/E /ZB /COPY:DATSOU /DCOPY:T /MT:128 /XO /R:10 /W:30 /V /TS /FP /ETA /TEE
set log=C:\temp\%~n0_%date:~10,4%.%date:~4,2%.%date:~7,2%.txt
robocopy %src% %dst% %swt% /LOG:%log%
@echo off
cls

Open in new window


More over, I have been updating the file for each old server to new server, is there a way to make one inclusive file that has
multiple sources and multiple desitnations

example src1 = oldserver1\share
        dst1 = newserver1\share

      src2 = oldserver2\Users
      dst2 = newserver\users

So src1 copies the share from old to new and src2 copies user shares.


I would also like to have a bit of checking and notification in the script.

Example

echo Testing to see if src host is online.
  ping oldserver | find "TTL" > nul
  if not errorlevel 1 (
    Echo oldserver is online.
      or if the server is offline - report it is down.
    Pause
    echo Preparing to copy src1 to dst1  and if doing more src2 and dst2 it would list that as well.
And can you make the preparing to copy in Bright RED.. so they can make sure path is correct?
Avatar of NVIT
NVIT
Flag of United States of America image

> ... security settings don't appear to be correct.
Add /SECFIX and /TIMFIX
> ... I just want a summary
Add...

/NS :: No Size - don't log file sizes.
/NC :: No Class - don't log file classes.
/NFL :: No File List - don't log file names.
/NDL :: No Directory List - don't log directory names.
/NP :: No Progress
Try minimizing it...
If that works, add the switches bit by bit.

Note: You may want to adjust the source path for now as it may take awhile to finish the copy, depending on how much files you have.

set src=\\oldserver\f$\share
set dst=E:\share
set log=C:\temp\%~n0_%date:~10,4%.%date:~4,2%.%date:~7,2%.txt
robocopy %src% %dst% /mir /log:%log%
Avatar of Indyrb

ASKER

in the log that is the ~ telda and 4% 2% and etc mean?

Also can you list what the code would look like with the /MIR and the /SECFIX /TIMFIX
and all the

/NS :: No Size - don't log file sizes.
 /NC :: No Class - don't log file classes.
 /NFL :: No File List - don't log file names.
 /NDL :: No Directory List - don't log directory names.
 /NP :: No Progress

Like with my current code...
ASKER CERTIFIED SOLUTION
Avatar of NVIT
NVIT
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Indyrb

ASKER

would these switches work... used yours with the added /ZB /MT:128 /ETA /TEE

swt=/MIR /ZB /SECFIX /TIMFIX /COPYALL /DCOPY:T /MT:128 /XO /R:100 /W:30 /NS /NC /NC /NFL /NDL /NP
/ETA /TEE

Does the /XO  exclude files that are the same? from source to destination?
Avatar of Indyrb

ASKER

or this with the /V

set swt=/MIR /ZB /SECFIX /TIMFIX /COPYALL /DCOPY:T /MT:128 /XO /R:100 /W:30 /NS /NC /NC /NFL /NDL /NP /V
/ETA /TEE
Have you tested the one I posted? If it works, add your other switches. Then test.
Avatar of Indyrb

ASKER

I don't want /purge and somehow it said options /purge and I didn't add this
Avatar of Indyrb

ASKER

is the /mir adding purge... I ran it.... Did it remove anything from source?
/mir erases from destination, not the source.
See http://ss64.com/nt/robocopy.html for a good explanation
Avatar of Indyrb

ASKER

oooh so if the file from source was removed.... /mir says hey that file doesn't exist, so it needs to remove from destination??

Its a total mirror.... right?
> Its a total mirror.... right?
Correct.
Avatar of Indyrb

ASKER

thank you
You're welcome, Indyrb. I'm glad to help.