What is a good, general way to make a recursive/deep directory copy in Linux that works in most cases? I've used simple things like cp -R as well as fairly elaborate cpio incantations. Are there any significant strengths or weaknesses that cause you to prefer one over the other? Which one do you use most often?
| |||
|
feedback
|
So in answer to your question:
Copy everything recursively from directory /foo to directory /bar while preserving symbolic links and file/directory 'mode' 'ownership' & 'timestamps'. | |||||||||||
feedback
|
|
I use a command like "cd $srcdir ; tar -c . | tar -C $destdir -x " most often. But I also use rsync -a $src $dst. The biggest strength of the tar solution is that it is what I had to use on a system many years ago that didn't have cpio, rsync or a cp that would copy recursively. Tar is pretty much everywhere. It is stuck on my head because I used it a lot, there probably are more elegant ways. It always seems to get the job done correctly, so I have never really looked to hard to find a replacement. | |||||||||||||
feedback
|
|
Take a look a rsync ... I like it because you copy less data when keeping two directories up to date ... it can also work remotly. In its simplest form rsync -a /src /dest | |||||
feedback
|
|
| |||
|
feedback
|