February 5, 2010

How to copy groups of files at once?


I've been working on this all morning and I cannot figure it out.

I'm running Ubuntu Server 8.04.4 and I have directories on an ext3 partition (SOURCE) that I would like to copy. I have a USB drive (DESTINATION) connected to the server and mounted NTFS.

I want to copy files from the SOURCE with "preserve" or "-p." I am interested in keeping the timestamps, owner, permissions, etc. Is this just not possible or am I missing something?

I want to give the copy command through BASH and not copy duplicates. If the server asks whether to overwrite/replace, I want the default answer to just be "no." I do not want to sit at the computer for days attending to this copy typing no. Researching all morning, I thought I was golden with the "--reply=no" argument. I then found that this argument was deprecated and did not work (oh, the joy).

On testing, my workaround command was

yes "no" | cp -r /SOURCE/ /DESTINATION/

This worked to preserve the timestamp on the directory. However, it re-copied the (already existing) files in the directory with today's timestamp. This makes the job much longer than it needs to be and messes up the timestamp.

To summarize, I want to copy only directories/files that are not already at the (NTFS) destination and preserve the timestamps, etc. with the directories/files that are copied. I already have a large number of other files on this USB drive for another project so I can't just reformat to, say, ext3 (although it seems that might be easiest at this point) Can this be done? Thanks.