Skip to content

Instantly share code, notes, and snippets.

@godber godber/ncp
Created Jan 10, 2015

Embed
What would you like to do?
ncp - Netcat and Pigz based network file copy (faster than scp, but unencrypted)
#! /usr/bin/bash
# ncp - Netcat and Pigz based network file copy (faster than scp, but unencrypted)
# From this blog post
# http://intermediatesql.com/linux/scrap-the-scp-how-to-copy-data-fast-using-pigz-and-nc/
FILE_FULL=$1
REMOTE_HOST=$2
FILE_DIR=$(dirname $FILE_FULL)
FILE_NAME=$(basename $FILE_FULL)
LOCALHOST=$(hostname)
ZIP_TOOL=pigz
NC_PORT=13333
tar -cf - -C $FILE_DIR $FILE_NAME | pv -s `du -sb $FILE_FULL | awk '{s += $1} END {printf "%d", s}'` | $ZIP_TOOL | nc -l $NC_PORT &
ssh $REMOTE_HOST "nc $LOCALHOST $NC_PORT | $ZIP_TOOL -d | tar xf - -C $FILE_DIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.