Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 356
  • Last Modified:

robocopy to copy changes

hi,

We are copying some data across the network using robocopy, which we tested and works fine, but we would like to copy the data in advance, and then just copy the changes on the day. These are the switches we use for the initial copy:

robocopy  /COPY:DATSO /Z /B /E /R:3 W:5 /V /LOG:c:\_robocopy\log.txt


What do I need to use to only copy new and changed files, overwriting the older versions on the target location? I tried looking at gui versions like richcopy and robomirror, but had some problems and crashes, so we decided to stick to what was tested and worked.

Thanks!
0
rookie_b
Asked:
rookie_b
  • 3
  • 3
  • 2
2 Solutions
 
oBdACommented:
Basically, you just run the same command again. robocopy will by default skip files that already exist in the target folder (based on same size and same time stamp).
If you want to delete files in the target that have been removed from the source in the meantime, use /MIR instead of /E.
0
 
Steve KnightIT ConsultancyCommented:
Your commandline will already do that.... one of the great things of robocopy.... it will run down and show you the files but not actually copy anything if they are the same.

If you add /purge though it will also delete from the destination (only) if the file no longer exists in the source dir to make sure they are in sync.

Only other things to be careful with is if you, say, clear the old area and someone runs the script again with /purge it will all disappear off the new area too.

Steve
0
 
Steve KnightIT ConsultancyCommented:
We crossed posts there obviously... both saying same in different ways, to clarify as oBdA says you can change /E for /MIR or use /E and /PURGE which do exactly the same.

Steve
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
oBdACommented:
Oh, and since you're writing to a log file, you should add /NP ("no progress") to prevent the control characters required for the progress bar from cluttering up your log file, and if you want to see the log output in the command prompt while robocopy is working, you can add "/TEE".
0
 
Steve KnightIT ConsultancyCommented:
Yes that has to be one of the few annoying aspects of robocopy... would be quite handy to have it show percentage progress on the screen, while still logging the success/fail to the log file!
0
 
rookie_bAuthor Commented:
Ok,

So, if I understand correctly, if I run the script below it will:
-copy new files

-delete files from target no longer on source

-overwrite existing files that have changed if the target is older than source, but ignore if target is newer than source (or will it change the source if target is newer?)



robocopy  /COPY:DATSO /Z /B /MIR /NP /TEE /R:3 W:5 /V /LOG:c:\_robocopy\log.txt
0
 
oBdACommented:
Close. robocopy will by default overwrite files that differ from the source. It will never do anything to the source, unless you use "/MOV(E)".
If you really need to prevent it from overwriting newer files, you can add /XO (eXclude Older), but that is really only required if you're changing files both in source and in target between the initial copy and the last diff copy (which I wouldn't recommend).
Note, too, that, if a user isn't happy with a newer file version that is already in the target folder, and restores it to an older version again before the diff, his change will be lost after a diff with /XO.
0
 
rookie_bAuthor Commented:
Ok, I will test and report back. Thank you very much!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now