Difference between revisions of "Nc"
(Created page with "<yambe:breadcrumb>Network related tools | Network tools</yambe:breadcrumb> =nc= '<tt>nc</tt>' is often called Swiss-knife of networking tools. It can be used to perform very ...") |
m |
||
Line 21: | Line 21: | ||
One should check the status of copying by using something similar to 'watch du -sh' on destination folder. Also try to check copying is working after disconnecting from both source and destination shell to verify that background processes are continuing properly. Note that this can be used only for one time copying and cannot be used a replacement of rsync when both source and destination already have a copy of data and only differences have to be migrated. | One should check the status of copying by using something similar to 'watch du -sh' on destination folder. Also try to check copying is working after disconnecting from both source and destination shell to verify that background processes are continuing properly. Note that this can be used only for one time copying and cannot be used a replacement of rsync when both source and destination already have a copy of data and only differences have to be migrated. | ||
'''Note that this method caused the overall process to stop after copying about 8 GB. The process works well if it is not sent to background using ()& sequence. The reason for crash when commands are sent to background needs to be determined.''' |
Revision as of 00:54, 25 December 2012
<yambe:breadcrumb>Network related tools | Network tools</yambe:breadcrumb>
nc
'nc' is often called Swiss-knife of networking tools. It can be used to perform very different operations via properly crafted shell commands. An example usage of nc to clone disk partitions is explained at Cloning disks or partitions using dd. Here few other such tricks related to nc are described.
Remote copy of folders/files very efficiently using nc
Normally one can use scp or rsync to copy files. But if amount of data is large then the first copy would take long time slightly due to encryption overhead of scp or rsync. Now if encryption is not necessary (Data is not very confidential or network is very secure) then nc can be used in place of scp or rsync for copying data for first time.
To copy folder in background using nc use on destination machine in destination folder:
(nc -l 9000 < /dev/zero | gunzip | tar x >/tmp/tar.out 2>&1) &
Then on source machine in source folder execute:
(tar c . | gzip | nc <destination-ip> 9000 >/tmp/nc.out 2>&1) &
One should check the status of copying by using something similar to 'watch du -sh' on destination folder. Also try to check copying is working after disconnecting from both source and destination shell to verify that background processes are continuing properly. Note that this can be used only for one time copying and cannot be used a replacement of rsync when both source and destination already have a copy of data and only differences have to be migrated.
Note that this method caused the overall process to stop after copying about 8 GB. The process works well if it is not sent to background using ()& sequence. The reason for crash when commands are sent to background needs to be determined.