Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to copy a /home/user folder from one hard disk to another one. It has 100,000 files and around 10G size.

I use

cp -r /origin /destination

sometimes I get some errors due to broken links, permissions and so on. So I fix the error, and need to start again the copy.

I wonder how could I tell the command "cp", once it tries to copy again, not to copy files again if they exist in the destination folder.

share|improve this question

migrated from stackoverflow.com Mar 11 '10 at 16:51

This question came from our site for professional and enthusiast programmers.

add comment

6 Answers

up vote 6 down vote accepted
cp -R -u -p /source /destination
share|improve this answer
    
To literally only copy files that don't exist and not update existing ones, yes n | cp -i /source/* /destination 2>/dev/null –  sventechie Nov 21 '13 at 20:14
add comment

Don't us cp. Use rsync instead.

share|improve this answer
add comment

rsync -aq /src /dest

Apart from only copying newer files, it will even only copy the newer parts of files if the file has changed. It's intended for copying over network links where you want to minimise the amount of data - but it also works great locally.

share|improve this answer
add comment

Look up the "-u" option for the cp command.

share|improve this answer
add comment

Disagree that using -u is a good idea.

-u copies only when source is newer or destination is missing. Original poster's issue was caused by file copy breaking for whatever reason.

OP would therefore have half-written file that wasn't updated when re-running the copy. That file might be important to someone!

rsync solves this problem.

share|improve this answer
add comment

You should be copying as root to maintain permissions/ownership

# cp -au

Also look at rsync

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.