That will not work how you think it will - rsync assumes the source is the
authoritative list.  So, if you have something like this:

/home/MyProfile/Music/filea.mp3 (modified today)
/home/MyProfile/Music/fileb.mp3 (modified last week)

/USBDevice/Music/filea.mp3 (modified last week)
/USBDevice/Music/fileb.mp3 (modified today)

Your script will blow away filea & fileb in /home/MyProfile/Music (filea
will be the older version).  The second part of your script will not perform
any file copies.

Secondly, rsync doesn't recurse by default (much like cp). Here's what you
actually want:

rsync -au /USBDevice/Music/ /home/MyProfile/Music/
rsync -au /home/MyProfile/Music/ /USBDevice/Music/

The -a option (--archive) enables recursion & retains permissions and
timestamps.  The -u option (--update) honors file timestamps (copy only if
source is newer than target).  The trailing slashes on the directory paths
are important, because without it, rsync will copy the Music directory from
the source into the Music directory of the second (Music/Music), which is
likely not what you want.

There's a lot of material, but I suggest reading
http://www.samba.org/ftp/rsync/rsync.html - there is a ton of information
about all the options to rsync. It's a very powerful tool, with some complex
idiosyncrasies that are very useful to learn.

-- 
You received this message because you are subscribed to the Linux Users Group.
To post a message, send email to [email protected]
To unsubscribe, send email to [email protected]
For more options, visit our group at 
http://groups.google.com/group/linuxusersgroup

Reply via email to