NetApp – Copy LUN between filers using NDMP
ndmpcopy is a wonderful command. It allows a fine-grained copy of files or directories between NetApp devices, across network, even if they do not use (or unlicensed) SnapMirror, SnapVault and the rest of the Snap* products NetApp offer.
In this example I will show how to copy a LUN from one filer to the other.
First, set the LUN to offline on the source filer. Make sure that it is not mounted, disconnected, etc – whatever prevents any major data loss. As you can deduce – setting a LUN to offline state will prevent write access to it. Also – take its parameters. For example:
lun show -v /vol/server1/data/mydb.lun
Second, create the required qtree structure. Make sure that the LUN is created at the root of either a volume or a qtree, or else.
Third, use ndmpcopy:
ndmpcopy -da root:password /vol/server1/data/mydb.lun remotefiler:/vol/server1/data/
This operation will take time.
When it completes, on the target NetApp, set priv to diag, and do the following:
- Rename the LUN:
mv /vol/server1/data/mydb.lun /vol/server1/data/mydb.not.lun - Create a hard-link LUN from a file (requires priv diag!)
lun create -f /vol/server1/data/mydb.not.lun -t linux -o noreserve /vol/server1/data/mydb.lun
(Command syntax: lun create -f <file_path> -t <ostype> [ -o noreserve ] [ -e space_alloc ] <lun_path>) - Remove the original file (it is hard-linked, so the data will not be affected)
rm /vol/server1/data/mydb.not.lun - Resize, if required, the LUN to the original full size (relevant if the LUN was thin-privisioned)
lun resize /vol/server1/data/mydb.lun 400g
You can now map the LUN to any relevant host, and obtain full access to its data.