Transfer file between 2 host via ssh with tar

Push copy to remote :

cd $SOME_DIR ; tar -cf – . | ssh host.com tar -xf – -C /destination

Pull copy/baskup to local: With progress display (when we installed pv )

ssh user@from-remote-server “tar czpf – /some/important/data” | pv | tar xzpf – -C /new/root/directory


Other ways: http://serverfault.com/questions/43014/copying-a-large-directory-tree-locally-cp-or-rsync

rsync

Here is the rsync I use, I prefer cp for simple commands, not this.

$ rsync -ahSD --ignore-errors --force --delete --stats $SRC/ $DIR/

cpio

Here is a way that is even safer, cpio. It’s about as fast as tar, maybe a little quicker.

$ cd $SRC && find . -mount -depth -print0 2>/dev/null | cpio -0admp $DEST &>/dev/null

tar

This is also good, and continues on read-failures.

$ tar --ignore-failed-read -C $SRC -cf - . | tar --ignore-failed-read -C $DEST -xf -

Note those are all just for local copies.