Transfer file between 2 host via ssh with tar

Push copy to remote :

cd $SOME_DIR ; tar -cf – . | ssh 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:


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

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


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


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.