How to use Robocopy to resync two file servers and file/folder permissions

Hello,

I am putting a file server in a branch office.  I originally copied all of the file/folder data from the corporate file server onto the branch file server before shipping it out.  Now that it is onsite and they are ready to go live I'd like to resync from corporate to branch given I've made several changes to permissions and document changes within the corporate file server.

I tried \\hoppy\frshare \\hkfile\frshare /mir

but I'm getting access denied.  Is this the proper syntax or am I doing something wrong?
bergquistcompanyAsked:
Who is Participating?
 
Leon FesterSenior Solutions ArchitectCommented:
I have used ROBOCOPY for this exact task many times.

Have a look at the following batch file from http://ss64.com/nt/robocopy.html

Backup a Server:
The script below copies data from FileServ1 to FileServ2, the destination holds a full mirror along with file security info. When run regularly to synchronize the source and destination, robocopy will only copy those files that have changed (change in time stamp or size.)

@ECHO OFF
SETLOCAL

SET _source=\\FileServ1\e$\users

SET _dest=\\FileServ2\e$\BackupUsers

SET _what=/COPYALL /B /SEC /MIR
:: /COPYALL :: COPY ALL file info
:: /B :: copy files in Backup mode. 
:: /SEC :: copy files with SECurity
:: /MIR :: MIRror a directory tree 

SET _options=/R:0 /W:0 /LOG:MyLogfile.txt /NFL /NDL
:: /R:n :: number of Retries
:: /W:n :: Wait time between retries
:: /LOG :: Output log file
:: /NFL :: No file logging
:: /NDL :: No dir logging

ROBOCOPY %_source% %_dest% %_what% %_options%

Open in new window


Run two robocopy jobs at the same time with START /Min

Start /Min "Job one" Robocopy \\FileServA\C$\Database1 \\FileServeBackupA\c$\Backups
Start /Min "Job two" Robocopy \\FileServB\C$\Database2 \\FileServeBackupB\c$\Backups

Or just use the command line version of the above script
Robocopy source destination /COPYALL /B /SEC /MIR /R:0 /W:0 /LOG:MyLogfile.txt /NFL /NDL

Open in new window


See the MS Storage Team blogs for more information:
http://blogs.technet.com/b/filecab/archive/2008/07/31/robocopy-mir-switch-mirroring-file-permissions.aspx
0
 
Erik BjersPrincipal Systems AdministratorCommented:
I would use total commander for this.  They have a nice sync tool that can sync up all the files on both sides, and it is free.

Here are some how to guides that will help

http://www.ghisler.com/advanced.htm

eb
0
 
bergquistcompanyAuthor Commented:
does this sync user permissions and ownership on folders?
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

 
Erik BjersPrincipal Systems AdministratorCommented:
If you use the copy function yes it will copy permissions and ownership (configurable option) but it appears it does not copy permissions and ownership when using the synchronize function.

If all the file synchronization is one way (old server to new server) then you can just tell total commander to do a copy and to overwrite older/ smaller files on the destination.  If there are files changed on both servers you need to use the sync function.

You can use setacl http://helgeklein.com/setacl/ to export and import file permissions and ownership if total commander does not copy them properly.

setacl has a free command line version and a very inexpensive GUI (setaclstudio).  I use this at lest once a week to fix permission issues so even if you don't need it for this job it is a good tool to have.
0
 
bergquistcompanyAuthor Commented:
I'd like to use one program if possible to do this and I thought robocopy did.
YOu said copy in total commander will?  If so how do you copy I don't see that in commands?
0
 
Erik BjersPrincipal Systems AdministratorCommented:
Copy in total commander will, there are a few things you need to do.

First open it
and navigate to your source on the left pane and destination on the right]

Next select the files you want to copy from left to right then simply drag them over to the destination.

An options window will pop up and one of the options is to copy NTFS permissions.

BTW I also found this info on robocopy that should tell you how to do it with robocopy if you prefer.

http://burpee.smccme.edu/studenthowtos/robocopy.htm

eb
0
 
bergquistcompanyAuthor Commented:
I didn't get the popup window

If I run the command line as follows
Robocopy \\hoppy\bqcorp1\frshare \\hkfile\bqcorp1\frshare  /COPYALL /B /SEC /MIR /R:0 /W:0 /LOG:MyLogfile.txt /NFL /NDL

This will copy everything under FRShare from Hoppyt to HKFile including permissions?
If contents are there from an original sync it will overwrite?
0
 
Erik BjersPrincipal Systems AdministratorCommented:
See dvt_localboy's comments above there is a good script for doing it with robocopy.
0
 
bergquistcompanyAuthor Commented:
So just create a batch file with this in it and all I have to change is the source and destination?
Is this using Robocopy?  Do I have to alter something in the last line or not?

If file changes and permission changes were made on the backup server they will be corrected by overwrites?
0
 
Erik BjersPrincipal Systems AdministratorCommented:
Looks like it uses robocopy and you just need to change the source and destination and then run the .bat file.

If you are on Svr 2008 I would open CMD as an admin and run the .bat from there or you may run into some security issues.

eb
0
 
bergquistcompanyAuthor Commented:
I do and get maximum setlocal recursion level reached over and over
0
 
Leon FesterSenior Solutions ArchitectCommented:
Use the last Robocopy commands that I posted. The /Mir switch mirrors the content from source to destination. /sec says to copy security permissions. If any folders are added or deleted or permissions are changed then those changes will be replica to the destination folder
0
 
Leon FesterSenior Solutions ArchitectCommented:
Use the last Robocopy commands that I posted. The /Mir switch mirrors the content from source to destination. /sec says to copy security permissions. If any folders are added or deleted or permissions are changed then those changes will be replicated to the destination folder. The batch file will explains the rest of the switches. Otherwise type robocopy /? For more help.
0
 
bergquistcompanyAuthor Commented:
ok tried that and getting
2013/01/17 17:43:38 ERROR 5 (0x00000005) Creating Destination Directory \\hkfile\bqcorp1\frshare\Materials\SFE Cycle Count Data\whse SH1 FG\2009\feb 09\
Access is denied.
0
 
Leon FesterSenior Solutions ArchitectCommented:
ERROR 5 (0x00000005) Creating Destination Directory \\hkfile\bqcorp1\frshare\Materials\SFE Cycle Count Data\whse SH1 FG\2009\feb 09\

Access denied is a permissions issue on the account that you're using to run the command.
You don't have sufficient permission to create the folders mentioned in the error message.
0
 
bergquistcompanyAuthor Commented:
is it lack of permisison on the source or destination because from the source I can browse and manually create folders as tests
0
 
Leon FesterSenior Solutions ArchitectCommented:
Destination folder

ERROR 5 (0x00000005) Creating Destination Directory \\hkfile\bqcorp1\frshare\Materials\SFE Cycle Count Data\whse SH1 FG\2009\feb 09\
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.

All Courses

From novice to tech pro — start learning today.