0
  1. I have 2 directories- etc and oldroot/etc
  2. I want all the files in etc to match exactly as oldroot/etc
  3. If there are any files in etc that are not in oldroot/etc, I want to preserve them as is

I have tried every variety of flags I can think of with rsync, but I cannot get the desired result.

# # A few of the simpler commands I have tried
# rsync -Ia oldroot/etc etc
# rsync -Iac oldroot/etc etc
# rsync -ac oldroot/etc etc

They complete without errors. When I do a diff on the directories (diff -r oldroot/etc etc), there remains several of the same files that exist in both directories and with different content. I've been working on this 2 days, and needless to say I am frustrated beyond belief.

1 Answer 1

2

rsync --… oldroot/etc etc copies the source directory etc to a subdirectory of the destination directory, so a file oldroot/etc/foo ends up copied to etc/etc/foo. If you want to copy a directory to a directory of the same name, specify the parent of the target directory:

rsync -a oldroot/etc .

If you want to copy a directory onto another directory, tell rsync to copy the contents of the source directory into the target directory by appending a trailing slash to the source. (A trailing slash on the target makes no difference.)

rsync -a oldroot/etc/ etc
1
  • 100% correct. I discovered the directory etc/etc just as you stated
    – Sepero
    Commented Mar 4, 2015 at 0:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .