Solved

robocopy stuff

Posted on 2014-03-21
20
466 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
20 Comments
 
LVL 51

Expert Comment

by:Bill Prew
Comment Utility
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 16

Assisted Solution

by:Emmanuel Adebayo
Emmanuel Adebayo earned 125 total points
Comment Utility
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 33

Assisted Solution

by:paulmacd
paulmacd earned 125 total points
Comment Utility
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
 
LVL 1

Author Comment

by:JeffBeall
Comment Utility
"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
Comment Utility
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 33

Expert Comment

by:paulmacd
Comment Utility
Try...

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

Expert Comment

by:Bill Prew
Comment Utility
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
Comment Utility
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 78

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 125 total points
Comment Utility
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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 1

Author Comment

by:JeffBeall
Comment Utility
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 51

Expert Comment

by:Bill Prew
Comment Utility
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
Comment Utility
"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 51

Expert Comment

by:Bill Prew
Comment Utility
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
Comment Utility
ok, but should this handle copying the files then?

robocopy  /fft /XO
0
 
LVL 51

Expert Comment

by:Bill Prew
Comment Utility
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
Comment Utility
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 51

Accepted Solution

by:
Bill Prew earned 125 total points
Comment Utility
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
Comment Utility
yes, that you for the explanation.
0
 
LVL 1

Author Closing Comment

by:JeffBeall
Comment Utility
thank you for all the help.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
OfficeMate Freezes on login or does not load after login credentials are input.
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

771 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now