2

It's been many hours reading and reading everywhwere.. testing rsync, Grsync, and Unison.. with no hope! The normal way of rsync copying/synchronizing files between two local folders is to "copy the whole folder itself! - not the contents as thought! - nothing else!

To experiment with, I made two folders with different names on same root. When got this result, I separated them and gave the source the same name of destination in case this was the cause.

normal way of rsync copying/synchronizing files between two local folders

rsync -zrahvWnt --delete-after ~/Documents/test3/source-DRV ~/Documents/test3/dest-T

I also used ALL possible options in Unison.. no hope! Same result!

"Resolve conflicts in favor of first root" "Propagate Right to left" "Right to left"

None worked differently! All gave same result: Copy the "whole" folder "inside" the other folder!

What I want basically is very simple:

  1. Check for missing files in the Target that are in the source.

  2. Move - preferable, but copy is ok

  3. only missing files from the source to the Target folder.

  4. Do nothing to files that are identical in size, date and found in both folders.

This will result in a "Complete Folder" - which is the destination, and a "Useless Folder" which is the source, to be deleted manually no problem.

desired way of making rsync 'preferably' move - not copy - the only missing files and folders from the source to the target

[Edit:] While implementing the solution, I found that I've used the -n option, which makes "dry run".. that's probably another reason why nothing worked. I removed it and everything went as expected!

4

If I understand your intention correctly, all you need to do is to append a trailing slash to your first argument of rsync. That is, instead of writing

rsync -zrahvWt --remove-source-files ~/Documents/test3/source-DRV ~/Documents/test3/dest-T

write

rsync -zrahvWt --remove-source-files ~/Documents/test3/source-DRV/ ~/Documents/test3/dest-T

Edit I have modified the above commands according to the OP's comments in regard of answering his/her own question.

With regards to the parameters of rsync:

  • -z: compress file data during the transfer
  • -r: recursive: To copy the folders under the current folder and its files, not just the files under the current folder
  • -a: preserve almost everything (dates, permissions, etc.)
  • -h: output numbers in a human-readable format
  • -v: verbose: to print more details of the process on the screen
  • -W: copy the whole file, not update the difference of data only.

More details can be found by running man 1 rsync.

  • But I have no idea why Gui's didn't do this too. probably the "trailing" slash" has to be put manually in the path field. – OpenSourceMan Dec 29 '17 at 5:16
  • Just installed grsync and found that there is a question mark after the text "Source and Destination". Clicking on the question mark reveals a hint about the trailing slash issue. – Weijun Zhou Dec 29 '17 at 5:31
  • Yes. but the example they gave is not easy to relate to the novice user. – OpenSourceMan Dec 29 '17 at 6:51
  • I found that this command is working perfect, leaving the source folder not deleted though: rsync -zrahvWt --remove-source-files /home/office1/Documents/test9/source-DRV/ /home/office1/Documents/test9/dest-T While using the --delete-after option instead of --remove-source-files will actually remove all the target folder's files, and will be just copying the source files into the target folder: rsync -zrahvWt --delete-after /home/office1/Documents/test10/source-DRV/ /home/office1/Documents/test10/dest-T – OpenSourceMan Dec 29 '17 at 7:06
  • Regarding the options I used: -zrahvWt -z: compress file data during the transfer -r: recursive: To copy the folders under the current folder and its files, not just the files under the current folder -a: preserve almost everything (dates, permissions, etc.) -h: output numbers in a human-readable format -v: verbose: to print more details of the process on the screen -W: copy the whole file, not update the difference of data only. -t: transfer modification times too (not needed if -a used) I should remove it More details on the manual here: linux.die.net/man/1/rsync – OpenSourceMan Dec 29 '17 at 7:06

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.