Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Mirror only directories that exist in destination

Posted on 2010-08-17
12
Medium Priority
?
462 Views
Last Modified: 2012-05-10
I am trying to copy data from an old file server to a new one.  Some of the users on the old one aren't coming to the new system.  I did a robocopy job where i just mirrored the directories and not any data and then had the admins go through and delete any users that aren't coming to the new system.

Now I just need to determine how I can tell robocopy to only mirror data for directories that exist on the destination.  Is that possible?
0
Comment
Question by:Waident
[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
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 8

Expert Comment

by:SylvainDrapeau
ID: 33459474
Hello !

XCOPY /U does just that, but I can't find an option in ROBOCOPY that looks like this.

Syldra
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 33459482
The only way I can think of to achieve that is to maintain a exclusion list of folders with the /XD option. You can obtain that list by:

@echo off
setlocal EnableDelayedExpansion
dir /a:+d /s /b \\srcserver\share\  > srcdirs.txt
dir /a:+d /s /b \\dstserver\share\  > dstdirs.txt
set xdirs=
for /F %%D in ('findstr /v /L /g:dstdirs.txt srcdirs.txt') do set xdirs=!xdirs! "%%D"
robocopy ... /XD %xdirs% ...

(You need to fill out the remainder of the robocopy to your liking).
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 33459492
xcopy /u does not refer to folders, only to files ...
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
LVL 57

Expert Comment

by:Bill Prew
ID: 33460517
Just to toss another option out there, I don't think ROBOCOPY can do it all in one step.  But you could wrap the ROBOCOPY usage in a small BAT script that looks at the directories in the source location, and only does a ROBOCOPY of that folder if it exists in the destination location.  So it would look like this (I didn't try to put options on the ROBOCOPY, you likely have a set of those from the first copy):

@echo off
setlocal EnableDelayedExpansion
set FromDir=\\srcserver\share
set DestDir=\\dstserver\share
for /D %%A in ("%FromDir%\*") do (
  if exist "%DestDir%\%%nA" (
    robocopy "%FromDir%\%%nA\" "%DestDir%\%%nA\"
  )
)

~bp
0
 
LVL 8

Expert Comment

by:SylvainDrapeau
ID: 33461178
@Qlemo : I have not tested it but after reading the description again, I believe you are correct. My apologies.

Syldra
0
 

Accepted Solution

by:
Waident earned 0 total points
ID: 34347966
thanks for the help guys...unfortunately I ended up having to just move the users drives manually into a separate folder on the source side so i could do a full copy job.  
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 34348309
I'm convinced that both my and Bill solutions are working and feasible. Any reason why you could use neither?
0
 

Author Comment

by:Waident
ID: 34348532
compiling the list and writing a script was more complex than simply moving the directories I needed into a subfolder and mirroring the whole directory.

I have no problem awarding you guys the points...you did provide options, i just thought that I only reward points when I use the solutions provided and they work which in this case I did not and since I didn't I have no way of knowing whether they would work or not.  

0
 
LVL 71

Expert Comment

by:Qlemo
ID: 34348575
What you did was alright. You should just have added the last comment to your closing request. I've asked because it might not have worked for any reason, and that would be important to know for us.
0
 

Author Comment

by:Waident
ID: 34348600
Gotcha...noted for next time.  

I do appreciate the answers, as always...in this case I was looking for a simple answer to avoid the manual process but when I saw that there was no simple answer I went with a way I know will work as I couldn't afford any mistakes.  

 
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 34348648
No bad choice.
0
 

Author Closing Comment

by:Waident
ID: 34387588
no solution provided...did my own workaround
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Many businesses neglect disaster recovery and treat it as an after-thought. I can tell you first hand that data will be lost, hard drives die, servers will be hacked, and careless (or malicious) employees can ruin your data.
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…
This Micro Tutorial will teach you how to reformat your flash drive. Sometimes your flash drive may have issues carrying files so this will completely restore it to manufacturing settings. Make sure to backup all files before reformatting. This w…

670 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