?
Solved

robocopy stuff

Posted on 2014-03-21
20
Medium Priority
?
485 Views
Last Modified: 2014-03-22
I created the a simple robocopy bat file to take the place of windows offline files because where i work the domain admins don't allow offline files. the following is what i have in the batch file
cd \

robocopy /MIR /fft /XO "H:\Computer stuff" "C:\offlinefiles\compstuff"

robocopy /MIR /fft /XO "H:\MyDocs" "C:\offlinefiles\mydocs"

robocopy /MIR /fft /XO "H:\MyDocuments" "C:\offlinefiles\mydocuments"

robocopy /MIR /fft /XO "H:\Printer Stuff" "C:\offlinefiles\printerstuff"

robocopy /MIR /fft /XO "C:\offlinefiles\compstuff" "H:\Computer stuff"

robocopy /MIR /fft /XO "C:\offlinefiles\mydocs" "H:\MyDocs"

robocopy /MIR /fft /XO "C:\offlinefiles\mydocuments" "H:\MyDocuments"

robocopy /MIR /fft /XO "C:\offlinefiles\printerstuff" "H:\Printer Stuff"

Open in new window

I thought it was working fine until today when i made a copy of an excel document. so for example there is an excel document, let's call it doc1, and i copied all the sheets from excel doc1 to excel doc2. then i ran my batch file to create my "offline" files, but the robocopy batch is removing doc2. So just to be sure i didn't misplace excel doc2, I copy the excel documents again, and ran the batch file, and sure enough, after running the batch, excel doc2 is gone.
any ideas on how this would happen? do i have the correct switches for my robocopy statement?
0
Comment
Question by:JeffBeall
  • 9
  • 6
  • 2
  • +2
19 Comments
 
LVL 59

Expert Comment

by:Bill Prew
ID: 39946117
Where are you creating the doc2 file that is being removed, on which drive?

And why are you doing ROBOCOPY in 2 directions?

What is the goal after the script runs, do you want C: and H: to be exact mirrors of each other?  If so, how do you want to handle files that are deleted from either side, do you want them removed from the other drive?  Etc.

Need a little more info on exactly what you want to happen to be able to coach.  But using /MIR in both directions would likely remove doc2 if you added that on the C: drive.  If you added it on the H: drive then it wouldn't be removed.

~bp
0
 
LVL 18

Assisted Solution

by:Emmanuel Adebayo
Emmanuel Adebayo earned 500 total points
ID: 39946121
Looking through the script, it looks okay but it might be one of the robocopy is running over it again.

As a test, run only the robocopy job that have the doc2 and see what result you get.

Regards
0
 
LVL 34

Assisted Solution

by:Paul MacDonald
Paul MacDonald earned 500 total points
ID: 39946122
Is is possible the duplicate is being saved in a folder that isn't mirrored?  Are you sure the script has access to that folder?

Have you tried adding /LOG+:LogFileName to see what robocopy has to say about it?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Author Comment

by:JeffBeall
ID: 39946138
"Where are you creating the doc2 file that is being removed, on which drive?"

"H"

"And why are you doing ROBOCOPY in 2 directions?"
when I first created this, i noticed that when i was at work and saving to "H" it works fine, but when i am out of the office, i save to "C" and the stuff I do on "C" isn't copied to "H"

"What is the goal after the script runs, do you want C: and H: to be exact mirrors of each other?"
Yes i want the "C" directories to be an exact mirror of "H" and visa versa, so like i said, if i make changes to "C" they are reflected on "H"

"Have you tried adding /LOG+:LogFileName to see what robocopy has to say about it? "

would i have to put /LOG+:logfilename on each line?
0
 
LVL 1

Author Comment

by:JeffBeall
ID: 39946148
I tried this

robocopy /MIR /fft /XO /LOG+:mydocslog.txt "H:\MyDocs" "C:\offlinefiles\mydocs"

but i don't see

mydocslog.txt in

 "H:\MyDocs"

or

 "C:\offlinefiles\mydocs"

or even in the startup folder which is where my batch file is.
0
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 39946184
Try...

ROBOCOPY /MIR /FFT /XO /LOG+:C:\offlinefiles\mydocslog.txt "H:\MyDocs" "C:\offlinefiles\mydocs"
0
 
LVL 59

Expert Comment

by:Bill Prew
ID: 39946222
It seems to me what you really need is TWO scripts.

One you would run when you have been working on the H: drive and are ready to sync to the C: drive.

The other you would use when you have been working on the C: drive, and are ready to sync back to the H: drive.

Each script would have just the robocopy commands that make sense, in one case mirroring H: to C:, and in the other mirroring C: to H:.

I don't think there is any dependable way to let a single script sort it all out, all the time.  For example if you worked on C:, and deleted a file that you no longer needed, your curent script would always copy it back from H: the next time you ran it.  Those are the types of problems you will run in to.

~bp
0
 
LVL 1

Author Comment

by:JeffBeall
ID: 39946226
thank you, that worked.
So I have a copy of my excel document that keeps getting removed somewhere else on my "C" drive.
I copy it to C:\offlinefiles, then run the batch. After the batch runs, the copy of the excel document is gone, and I don't see anything in the log file. the excel document is called
Win7Upgrade3.xlsx
I attached the log file
mydocslog.txt
0
 
LVL 84

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 500 total points
ID: 39946274
1 Extra File  with /mir it will DELETE the file.   Don't use /MIR unless you are very careful of your source and destinations
the top 4 lines will delete the extra files from the C: Drive
you should only be using the bottom 4 going to H:
cd \
@ Here you are copying from your storage space to your computer
robocopy /MIR /fft /XO "H:\Computer stuff" "C:\offlinefiles\compstuff"
robocopy /MIR /fft /XO "H:\MyDocs" "C:\offlinefiles\mydocs"
robocopy /MIR /fft /XO "H:\MyDocuments" "C:\offlinefiles\mydocuments"
robocopy /MIR /fft /XO "H:\Printer Stuff" "C:\offlinefiles\printerstuff"
@ Here you are copying from your computer to the storage space
robocopy /MIR /fft /XO "C:\offlinefiles\compstuff" "H:\Computer stuff"
robocopy /MIR /fft /XO "C:\offlinefiles\mydocs" "H:\MyDocs"
robocopy /MIR /fft /XO "C:\offlinefiles\mydocuments" "H:\MyDocuments"
robocopy /MIR /fft /XO "C:\offlinefiles\printerstuff" "H:\Printer Stuff"

Open in new window

0
 
LVL 1

Author Comment

by:JeffBeall
ID: 39946303
ok, so would

cd \
robocopy  /fft /XO "H:\Computer stuff" "C:\offlinefiles\compstuff"
robocopy  /FFT /XO  "C:\offlinefiles\mydocs"
robocopy  /fft /XO "H:\MyDocuments" "C:\offlinefiles\mydocuments"
robocopy  /fft /XO "H:\Printer Stuff" "C:\offlinefiles\printerstuff"
robocopy  /fft /XO "C:\offlinefiles\compstuff" "H:\Computer stuff"
robocopy  /fft /XO "C:\offlinefiles\mydocs" "H:\MyDocs"
robocopy  /fft /XO "C:\offlinefiles\mydocuments" "H:\MyDocuments"
robocopy  /fft /XO "C:\offlinefiles\printerstuff" "H:\Printer Stuff"

be a safer way to go?
0
 
LVL 59

Expert Comment

by:Bill Prew
ID: 39946361
What do you want to happen when you delete a file from either C: or H:?  Do you want the script to delete it from the other location?

~bp
0
 
LVL 1

Author Comment

by:JeffBeall
ID: 39946365
"What do you want to happen when you delete a file from either C: or H:?  Do you want the script to delete it from the other location?"

yes, i think that would be nice, does the current batch not do that?
0
 
LVL 59

Expert Comment

by:Bill Prew
ID: 39946383
It does not.  How would you expect the batch to know the different between adding a new file, or deleting an old file, there is really no way to know which is the case.,

This is why I believe you will need two different scripts, as mentioned above...

~bp
0
 
LVL 1

Author Comment

by:JeffBeall
ID: 39946412
ok, but should this handle copying the files then?

robocopy  /fft /XO
0
 
LVL 59

Expert Comment

by:Bill Prew
ID: 39946724
I would think you want the /MIR, and adding the /XO should prevent accidental overwrite of a newer file in the destination.

~bp
0
 
LVL 1

Author Comment

by:JeffBeall
ID: 39946812
well, I'm a little confused now,
David Johnson said

"1 Extra File  with /mir it will DELETE the file.   Don't use /MIR unless you are very careful of your source and destinations "

but you are saying I would want the /MIR switch? So it would be safe to use it?
0
 
LVL 59

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 39947453
The /MIR option will create a duplicate of the source at the destination. So it will only delete files from the destination location, never from the source, it assumes that is the master version ans seeks to replicate it.  So it you deleted a file from the source side, you would want it deleted from the destination so that they stay in sync.  However if you add a new file to the source location, it will know that is a new file and copy it to the destination, not delete it.  Does that help at all?

~bp
0
 
LVL 1

Author Comment

by:JeffBeall
ID: 39948075
yes, that you for the explanation.
0
 
LVL 1

Author Closing Comment

by:JeffBeall
ID: 39948079
thank you for all the help.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
Suggested Courses
Course of the Month14 days, 2 hours left to enroll

807 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