How to force rsync to use destination directory as root

Posted by thepurplepixel on Super User See other posts from Super User or by thepurplepixel
Published on 2010-04-22T03:40:32Z Indexed on 2010/04/22 3:43 UTC
Read the original article Hit count: 231

Filed under:
|
|

I have a simple script to one-way-sync files/folders within a directory:

#!/bin/bash

HOST='<hostname>'
USER='<username>'
DIR='/downloads/'
SOURCE='/srv/torrents'

rsync -e "ssh -l $USER" --remove-source-files -h -4 -r --stats --progress -i $SOURCE $HOST:$DIR
find $SOURCE -type d -empty -prune -exec rmdir -p \{\} \;

However, when this rsync operation runs, it creates a folder, torrents in /downloads on the destination machine. How can I force rsync to put all folders & files from /srv/torrents (remote) into /downloads/ (local) instead of creating /downloads/torrents as a separate directory?

© Super User or respective owner

Related posts about rsync

Related posts about linux