Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Quickly Copy Large Directory Tree Via SSH (See related posts)

To copy the entire directory tree at /some/path to other.host via SSH...

find /some/path -print | sort | cpio -o -Hnewc | ssh -C other.host "cpio -idvum"


Make sure you use an absolute path to the directory tree. Existing files on the destination host will be overwritten unconditionally.

Comments on this post

procreate posts on Oct 21, 2005 at 03:19
If you just want to copy a tree you can use: scp -r /top/of/tree my_login@other.host:/location (or location)
AGWA posts on Dec 04, 2005 at 22:58
True, but only if you have regular files in the directory. scp doesn't play nice with special files like symlinks, hard links, FIFOs, and devices. cpio is guaranteed to preserve those.

You need to create an account or log in to post comments to this site.


Click here to browse all 5140 code snippets

Related Posts