Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

xcopy and retain permissions

Posted on 2014-07-16
7
Medium Priority
?
382 Views
Last Modified: 2014-07-30
Hi all,

got to copy shared user data from one server to another. I'm looking for a xcopy script that copies all folders and contained files and retains the permissions from the source and looks at the file being copied and only copies the file if it has newer changes applied.

Any help appreciated.
0
Comment
Question by:Jason Thomas
  • 3
  • 2
  • 2
7 Comments
 
LVL 86

Accepted Solution

by:
oBdA earned 1400 total points
ID: 40199059
Use robocopy, not xcopy.
Robocopy will by default only copy files that don't exist in the same version in the target yet, so you can just run it several times and it will only copy the differences after the initial run.
Some hints to the arguments:
- /mir already includes /e or /s; this makes sure source and target are identical after the run (which includes deleting files in the target that don't exist in the source anymore!)
- /nfl and /ndl will suppress the file and folder listing of successfully copied files/folders; errors will still be logged. Having log entries for files that were successfully copied usually are of no interest and only clutter up the log
- /r and /w in a LAN are usually unnecessary; if a copy doesn't work, it's mostly "access denied", either because the file is in use or because someone thought he's so very smart that he doesn't need his files backed up, denying admin access. Retries won't change that and will only slow down the copy.
- /np disables the progress indicator. A progress bar is a very nice thing if you have the time to stare at the screen, willing the percentage to move, and if you copy files that are so large that a progress indicator actually makes sense. If writing to a log, it's totally counterproductive, because it fills the log with control characters.
- /z, /b, or /zb will slow down the copy because of the additional overhead, with not much benefit in a LAN. /z is useful if copying over WAN connections, and /b only if the account you're using doesn't have full control over the folder tree.
robocopy.exe \\OldServer\D$\Users D:\Users *.* /copyall /mir /r:0 /tee /nfl /ndl /np /log:"C:\Temp\UserCopy.log"

Open in new window

0
 
LVL 1

Author Comment

by:Jason Thomas
ID: 40199079
Thank you very much. Would you happen to know where I can download a copy of robocopy please?
0
 
LVL 86

Expert Comment

by:oBdA
ID: 40199085
robocopy is part of the OS since Vista/Server 2008 (which was part of your topics).
For XP/Server 2003, it's part of the Resource Kit Tools: http://www.microsoft.com/en-us/download/details.aspx?id=17657
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 600 total points
ID: 40199091
The following options would be a start with xcopy:

xcopy /d /k /o /e  "c:\source\*.*" "D:\dest"

That will copy from source to dest if the file is newer or doesn't exist, but won't delete anything for dest.

but would suggest using robocopy instead:

robocopy "c:\source" "d:\dest" *.* /mir /copyall

That will DELETE any entries in dest that don't exist in source so be careful!  Nothing will be changed in source.

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 40199093
Bit of delay between typing and pressing Submit there for me!
0
 
LVL 1

Author Comment

by:Jason Thomas
ID: 40199484
Thanks chaps, will give it a go now and report back.
0
 
LVL 1

Author Closing Comment

by:Jason Thomas
ID: 40228623
Sorry for the delay.
0

Featured Post

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Question has a verified solution.

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

Understanding the various editions available is vital when you decide to purchase Windows Server 2012. You need to have a basic understanding of the features and limitations in each edition in order to make a well-informed decision that best suits …
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

571 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