• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 496
  • Last Modified:

robocopy stuff

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
JeffBeall
Asked:
JeffBeall
  • 9
  • 6
  • 2
  • +2
4 Solutions
 
Bill PrewCommented:
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
 
Emmanuel AdebayoGlobal Windows Infrastructure Engineer - ConsultantCommented:
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
 
Paul MacDonaldDirector, Information SystemsCommented:
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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
JeffBeallAuthor Commented:
"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
 
JeffBeallAuthor Commented:
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
 
Paul MacDonaldDirector, Information SystemsCommented:
Try...

ROBOCOPY /MIR /FFT /XO /LOG+:C:\offlinefiles\mydocslog.txt "H:\MyDocs" "C:\offlinefiles\mydocs"
0
 
Bill PrewCommented:
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
 
JeffBeallAuthor Commented:
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
 
David Johnson, CD, MVPOwnerCommented:
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
 
JeffBeallAuthor Commented:
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
 
Bill PrewCommented:
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
 
JeffBeallAuthor Commented:
"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
 
Bill PrewCommented:
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
 
JeffBeallAuthor Commented:
ok, but should this handle copying the files then?

robocopy  /fft /XO
0
 
Bill PrewCommented:
I would think you want the /MIR, and adding the /XO should prevent accidental overwrite of a newer file in the destination.

~bp
0
 
JeffBeallAuthor Commented:
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
 
Bill PrewCommented:
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
 
JeffBeallAuthor Commented:
yes, that you for the explanation.
0
 
JeffBeallAuthor Commented:
thank you for all the help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

  • 9
  • 6
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now