From: Brian Candler Date: 2003-05-25T01:46:01+09:00 Subject: Re: file copy blues On Sat, May 24, 2003 at 11:55:29PM +0900, kingsley@icecode.org wrote: > How do I copy an entire directory from one place to another? > > At the moment I am copying the names of all the sub directories then > creating them in the new location, then recursively going through each > of the sub directories and copying the files to the new directories > created. > > This seems like a long way around. > > Plus I also want to be able to copy the entire directory to another > machine - I was thinking of opening a socket connection to a listener on > the target machine and trying to copy the files that way. > > Any thoughts? For copying to the remote machine, I'd say 'rsync' is the best tool. It's not a Ruby program or library, but you can run it using system() of course. It runs over ssh. rsync -a will recursively copy subdirectories and also preserve mtime, mode bits and ownership (if it is being run with sufficient privileges) It cleverly optimises bandwidth by working out which files or bits of files already exist, so only copies what is new. Regards, Brian.