Hi all,

I have two file servers. Server A and Server B.

I have set up a robocopy script which copies the files from one server to another. The tricky part is this:

I have users working on both server. So when my script runs (Every hour) If there are new files on the destination server (Server B) they get removed. What I am after is that hourly the script runs and copies all new files from Server A to Sever B, however if users on Server B create new files they do not get deleted.

I am basically after copying any new files from Server A to server B and any new files on Server B are kept and not removed.

Script:

et use Z: \\192.168.0.1\f$ /USER:192.168.0.1\administrator Test123

Robocopy "Z:\TEST" "e:/NEW_TEST" /e /xo LOG:C:\Scripts\RobocopyScripts\TEST.log

NET USE Z: /delete
9 Spice ups

A share on both servers might be easier. Looking at your script, it should do what you are after. Is it currently deleting the files on server B?

AssDo you have to use robocopy? And are there a lot of files involved?

You could do somethinjng like this in PowerShell

New-SmbMapping -Localpath q: -RemotePath \\cookham24/c$\foo

$SourceFiles = Get-ChildItem C:\Foo

Foreach ($SourceFile in $SourceFiles) {
  If (Test-Path $SourceFile.FullName)
    Write-Verbose " $($sourcefile.Name) - Exists - not copied"!
} elseif {
    Copy-Item -Path $Sourcefile.FullName -Destination "$(Q:$SourceFile.name)"     
}

I’ve not tested it, but this might get you going.

Yes there are around 800GB - but that would be the initial sync. Then the syncs are to just copy the deltas. But my issue is that new files on the destination server which do not exist on the old server are getting removed. Not sure if there is a better way round this but all I need is to replicate the files on Server A to Server B. and if I create new files on server B they dont get overwritten

Thanks for clarifiying your requirements - you should be able to munge the code I supplied earlier! :slight_smile:

Have you thought about using DFS Replication to handle this for you?

Hi all, so I noticed that it is not copying me everything. The folders are getting created but on certain instances it is not copying the files within. With further inspection it looks like it is skipping the files as it does not have the permissions to do so. In the logs I get the following:

The system cannot find the file specified.
(0x00000002)

If I grant permissions to the file it gets copied.

Any help?

Solved the issue by just adding /B and it copied the files!

If you are running the recent version of Windows Server as your file server, why not use the built-in Storage Migration Service instead of messing up with robocopy? It would do everything automatically https://www.starwindsoftware.com/blog/migrate-your-file-servers-with-storage-migration-service without users even noticing.