Is it possible to use rsync to copy files in one direction only? For example suppose we have :

left/ a.txt

right/ a.txt

where the files are initially identical. If one then modifies right/a.txt, then :

rsync -avv left/ right/ 

will copy right/a.txt onto left/a.txt. Is it possible to restrict rsync to only copying from left/ to right/ (i.e. prevent if from being able to copy from right/ to left/)?

link|improve this question

0% accept rate
feedback

2 Answers

It should be rsync [OPTION...] SRC... [DEST] so it does work in that direction (unless you switch dest and src).

left/a.txt should be copied to right/a.txt:

$ echo 'left' > left/a.txt
$ echo 'right' > right/a.txt
$ cat left/a.txt && cat right/a.txt
left
right
$ rsync -avv left/ right/
sending incremental file list
delta-transmission disabled for local transfer or --whole-file
a.txt
total: matches=0  hash_hits=0  false_alarms=0 data=5

sent 95 bytes  received 34 bytes  258.00 bytes/sec
total size is 5  speedup is 0.04
$ cat left/a.txt && cat right/a.txt
left
left

If there are specific files you don't want included by rsync take a look at --exclude=PATTERN and --exclude-from=FILE.

link|improve this answer
And remember, when in doubt the --dry-run option will show you a list of the files that would have been transferred but not actually perform the transfer. I add this to the start of every rsync just as a precaution, even if I am sure the command is correct. – slillibri Oct 18 '11 at 22:03
feedback

You misunderstand rsync. This command:

rsync -avv left/ right/ 

will not sync anything in right to left. It will, as @atbg says, only sync left to right. Rsync is not a bi-directional syncer. It syncs the dest with the source.

Man page for reference: http://linux.die.net/man/1/rsync

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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