0

I have these folders:

.
├── result
├── test
│   ├── file1
│   ├── file2
│   ├── file3
│   └── file4
└── test2
    ├── file1
    ├── file2
    ├── file3
    └── file5
  • test is the original folder.
  • In test2 some files are different, others are identical and others only exist in there.

I want to user rsync to copy in result only those files in test2 that are newer that those on test or that doesn't exist on test.

I run any os the following, varying whether or not there's a = between --compare-dest and the name of the folder, whether or not the folder name has a trailing slash, or even inverting the parameters, just in case I'm missunderstanding what folder is compare-dest :

rsync -av --dry-run --itemize-changes --compare-dest=test2 test/ result/
rsync -av --dry-run --itemize-changes --compare-dest=test2/ test/ result/
rsync -arv --dry-run --itemize-changes --compare-dest test test2/ result/
rsync -arv --dry-run --itemize-changes --compare-dest test/ test2/ result/

All of them tell me:

--compare-dest arg does not exist: NAME_OF_EXISTING_FOLDER
  • What am I doing wrong?
  • What's the correct command I have ro issue to satisfy the requirement I explain at the beginning of this question?
2

man rsync:

If DIR is a relative path, it is relative to the destination directory.

You need:

rsync -av --dry-run --itemize-changes --compare-dest="$PWD"/test test2/ result/
  • I could give it three absolute paths then? – Tulains Córdova Feb 2 '16 at 17:30
  • The parameters were inverted, I corrected it. The "older" folder must be indicated by --compare-dest= and the newer is the following parameter. – Tulains Córdova Feb 2 '16 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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