Pages

Saturday, May 25, 2013

NAS migration using Robocopy

Robocopy - A command line utility to copy files from one location to other
Operating System -  Windows (installed in 2008), older versions can download from here
Command - 'robocopy'



Highlights:
========
- Multithreaded copying
- Tolerates network interruptions and resume copying
- Skip NTFS junction points which can cause copying failures because of infinite loops
- Copy file data and attributes correctly, preserve original timestamps, as well as NTFS ACLs, owner information, and audit information using command line switches
- A "mirror" mode, which keeps trees in sync by optionally deleting files out of the destination that are no longer present in the source
- Skip files that already appear in the destination folder with identical size and timestamp

Limitations:
=========
- Robocopy will not copy open files
- Systems prior to Windows Vista do not mirror properly, they ignore changed security attributes of previously mirrored files

Syntax:
======
robocopy <Source> <Destination> [<File>[ ...]] [<Options>]

For more switches:

robocopy /?

Throttle Bandwidth - Switch is /IPG (Inter Packet Gap)

Formula - Delay (D, in milliseconds) required to simulate a desired bandwidth (BD, in kilobits per second), over a network link with an available bandwidth of BA kbps:


For example, on a 4Mbps line, you could throttle down a copy to use a maximum of 2Mbps by using the /IPG:125 switch.

Example:
=======
To copy all files (*.*) from Source 10.10.10.10 to destination 20.20.20.20

robocopy \\10.10.10.10\source\ \\20.20.20.20\destination\ *.* /mir

Note: If you mix up you source and destination all of your data will be deleted instead of copied.

To copy Only New Files and write to a log file

If you want to copy in stages and don't want to copy all the files over again to copy any new files that were added since the first copy you can use the "/XO" flag which excludes older files. This means if the destination file exists and is the same date or newer than the source file robocopy will skip that file.

robocopy x:\ y:\ *.* /e /w:0 /r:0 /secfix /xo /log+:c:\NAS_migration.log

/e - Copies subdirectories
/w - Specifies the wait time between retries, in seconds, default value is 30
/r - Specifies the number of retries on failed copies, default value is 1,000,000
/secfix - Fixes file security on all files, even skipped ones
/xo - Excludes older files
/log+ - Writes the status output to the log file

Scenario: Migrate NAS share by scheduling to Run Incremental Copies

Scheduling as below will keep the new NAS share up-to-date until the final cut-over is scheduled.

Step:1 Create a folder on the server

Run - cmd

mkdir c:\nas_migration

Step:2 Create a bat file with below command

robocopy x:\ y:\ *.* /e /w:0 /r:0 /secfix /xo /log+:c:\NAS_migration.log

Step:3 Add this to scheduled tasks

Step:4 Plan a cut-over window

During cut-over you may make the source 'read-only' and do the final incremental update to make sure the new share is mirror of source and let the system admins work to map the new share

Done!
Read more: http://bloggerknown.blogspot.com/2013/02/changing-blog-page-by-page-number.html#ixzz2TaVMS7IW