?
Solved

robocopy stuff

Posted on 2014-03-21
20
Medium Priority
?
480 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
[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
  • 9
  • 6
  • 2
  • +2
20 Comments
 
LVL 57

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 57

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 82

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 57

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 57

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 57

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 57

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month8 days, 12 hours left to enroll

765 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