Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

It may sound strange, but I really want to copy only the existing files, so this files will be updated/overridden, and any new file will not be added.

I want to copy files of a single extension. It works well with this script line:

rsync -avm --include='*.bak' -f 'hide,! */' /Directory-to-be-backed-up/ /media/USB_stick

But I also want that the file to be copied only if it already exist in the destiny (overriding it).

For example, I have this 3 files in /tmp/a:

/tmp/a/1.h
/tmp/a/2.h
/tmp/a/internal/3.h

And this 2 files in /tmp/b:

/tmp/b/1.h
/tmp/b/internal/3.h

I would like to update/override the existing files in /tmp/b using the ones in /tmp/a, but not copy any new file (like the /tmp/a/2.h).

Is there a way?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

I'd reorder your command a bit, first I'd remove the --include and instead just put the *.bak right into the source path. Next you can add --existing to copy only existing files.

One possible way to do it (not tested):

rsync -avm --existing /Directory-to-be-backed-up/*.bak /media/USB_stick
share|improve this answer
    
I was going to suggest rsync ;) –  bodhi.zazen Jan 11 '12 at 19:42
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.