Quote:
Originally Posted by Garrett85
... I'm using the command 'rsync -a --delete SRC DEST' ...
|
Could you tell us the exact commands that you used?
I am guessing you used commands of this form:
Code:
rsync -a --delete ~/music/ /media/sdcard
rsync -a --delete ~/audiobooks/ /media/sdcard
Note the trailing slash (the slash character at the end of the source directory). This is a problem. It tells rsync to
transfer the files in ~/music or ~/audiobooks, and
not the directories themselves, to /media/sdcard, and delete anything else in /media/sdcard.
One solution is to omit the trailing slash:
Code:
rsync -a --delete ~/music /media/sdcard
rsync -a --delete ~/audiobooks /media/sdcard
This tells rsync to
transfer the directories ~/music and ~/audiobooks complete with their contents. It will create destination directories /media/sdcard/music and /media/sdcard/audiobooks, and the scope of the --delete option will be limited to the respective destination directory. I think that will keep all the files you intended to keep.
For the sake of completeness, I point out that the above transfer can also be accomplished with the trailing slash on the source (meaning "files in" that directory) and specifying the full destination directory, for example:
Code:
rsync -a --delete ~/music/ /media/sdcard/music
rsync -a --delete ~/audiobooks/ /media/sdcard/audiobooks
This would create directories /media/sdcard/music and /media/sdcard/audiobooks and put the corresponding files in them.
Edit: In rsync, a trailing slash on the destination doesn't do anything. It doesn't make a bit of difference. Therefore, if you are not sure (don't remember) which one the trailing slash is supposed to go on, and you don't want to read the manual, go ahead and put it on both:
Code:
rsync -a --delete ~/music/ /media/sdcard/music/
rsync -a --delete ~/audiobooks/ /media/sdcard/audiobooks/