Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Using rsync to sync iTunes on two computers UNIX
At home I have a laptop, and at work a desktop. I usually surf and do email and load music on my laptop (either iTunes store, or from CDs), but occasionally I'll shop the iTunes store at work. This means that, if I want to sync my songs to each machine, I can't simply copy my laptop's iTunes directory from the laptop to the desktop, since I'd lose some purchases. The process I use involves four steps, so it's not the simplest, but it works well...

Before starting, you must be able to ssh from either machine to the other, so the keys are set up and rsync can use ssh. Then I rsync from the laptop to the desktop, then the desktop to the laptop. If files are copied to the desktop, I run iTunes on that machine and choose "Add to Library" on the iTunes directory, which scans the entire iTunes directory and adds the new songs to iTune's library. Similarly on the laptop.

The rsync command, which is a single line is:
 rsync --ignore-existing --progress --recursive --perms  --times \
--size-only --whole-file --rsh=ssh --exclude='.*' \
--dry-run Music/iTunes/  DesktopMachine.local:Music/iTunes
The dry-run argument is to test and make sure everything is setup properly before attempting it. If it seems to be doing what you want, eliminate the dry-run argument and let it go. From the desktop machine, I'd rsync to LaptopMachine instead -- use the appropriate system names, of course.

Note that there are some sync solutions that work bi-directionally. But they all seem to make the reasonable assumption that if you have the same file (name) on two machines, but the last-modified date is different, sync over the most recent one. With iTunes, this doesn't make sense, since file contents don't change (unless you re-encode your library). This results in many more files being copied than necessary -- at least the first time. That and a couple of other minor issues are why I use rsync.

Be careful in playing with rsync options. If you're not careful, you can have it deleting files on the other machine which don't exist on the source machine while attempting to make the two directories look the same.
    •    
  • Currently 2.86 / 5
  You rated: 1 / 5 (7 votes cast)
 
[112,968 views]  

Using rsync to sync iTunes on two computers | 11 comments | Create New Account
Click here to return to the 'Using rsync to sync iTunes on two computers' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Using rsync to sync iTunes on two computers
Authored by: rattler14 on Oct 04, '04 11:27:44AM

This is an excellent hint. I too have the same problem, and I basically just mirrored my library on both computers. Problem is, my iPod kept trying to sync to each library (a pain in the butt). So, I ended up resetting all settings on my home computer.

I use rsync for backing up tons of directories back and forth from home/work. My biggest suggestion for a future tweak is to get a more complete 2-way rsync_iTunes script, to keep an updated playcount list, etc. Though, it's not really that big of a deal, it would just be nice.



[ Reply to This | # ]
Using rsync to sync iTunes on two computers
Authored by: johan on Oct 06, '04 08:20:40AM

Does anyone have an idea how to sync a subset of the library - i.e. copying a playlist to the other machine?

I habe a library on my home PC that is just to large to even fit on my iBook without any programs istalled, so i'd like to keep only a selection with me when not at home. Right now I have no idea how to accomplish that - other than "delete library on ibook; manually select files from library folder on pc; transfer to iBook; add all files to library on iBook" which is not really a usability treat... I guess an iPod could do the same but at the moment that is not an option.

Any suggestions appreciated.



[ Reply to This | # ]
Using rsync to sync iTunes on two computers
Authored by: hypert on Oct 04, '04 11:57:21AM

Consider using <a href="http://www.van-rijn.org/unisonOSX/">Unison</a> to do true bi-directional syncing. It uses a cache to remember when a file was last modified. If it was modified on BOTH sides of the sync, it prompts the user which one to keep.

http://www.van-rijn.org/unisonOSX/



[ Reply to This | # ]
Using rsync to sync iTunes on two computers
Authored by: rattler14 on Oct 04, '04 12:52:01PM

Thanks for the note. I tried install unison from the "stable" fink packages before, without luck because of an upgrade to the ocaml distribution which changed some of the commonly used global variables (or something to that effect). I was able (through the CVS) to get a copy of unison compiled, however, I'm going to wait till I can use the stable version from fink before I try it.

BTW, the link you sent basically says to just get the fink version.

I've read a lot of the unison documentation. It looks pretty sweet. Hopefully I'll be able to use that instead of rsync (which is awesome for archiving, but horrible for an iDisk substitute).



[ Reply to This | # ]
Using rsync to sync iTunes on two computers
Authored by: bluehz on Oct 05, '04 12:23:40AM

I just built the latest Unison beta 2.10.2 from scratch with no problems.

http://www.cis.upenn.edu/~bcpierce/unison/download/beta-test/unison-2.10.2/unison-2.10.2.osx-textui.gz

There are other version if you prefer.



[ Reply to This | # ]
Using rsync to sync iTunes on two computers
Authored by: rattler14 on Oct 05, '04 03:27:31PM

thanks, downloaded 2.10.2 and finally got a working binary. Will check out.

thanks for the info



[ Reply to This | # ]
File contents change
Authored by: extra88 on Oct 04, '04 12:48:41PM
With iTunes, this doesn't make sense, since file contents don't change (unless you re-encode your library).

File contents also change if you modify the ID3 tags on one of the computers. I change the tags to alter the genre (if I don't like what cddb says it should be), to add comments, to add album art and for other reasons. Often this is done when a file is first added to the Library but not always.



[ Reply to This | # ]
Using rsync to sync iTunes on two computers
Authored by: tinker on Oct 04, '04 09:54:36PM
Another thought -- if you were to use the work computer as the main iTunes repository and leave it on (and if you're not behind some impenetrable firewall), you could use it as a music server with for example Slim Server or something similar. Then you could access all your music from anywhere. Don't know how well or poorly it works for your situation (sounds like you download most music to your laptop), but it's an interesting possibility to keep in mind.

[ Reply to This | # ]
Simpler & faster?
Authored by: MattHaffner on Oct 05, '04 02:56:07PM

My standard rsync line works great with my iTunes directory:

rsync -ave ssh Music/iTunes/ DesktopMachine.local:Music/iTunes

Or, more verbosely:

rsync --archive --verbose --rsh=ssh Music/iTunes/ DesktopMachine.local:Music/iTunes

--archive puts together all the essential syncing features. Add --progress if you want fancier output. Add --delete if you really want the two directories to be *identical* (it removes files that aren't on the source). Add -z (--compress) if you are running over a slow link (although this may not help much with compressed audio files).

You almost never want to use -W (--whole-file). One of rsync's best features is how well and how fast it does incremental syncing. If you just change tags, artwork, etc. on a tune, you don't need to send the whole file to the destination. I would be surprised if this saved any time unless both machines are older with slow disks and are on a LAN. Any other use would probably be better with the default (i.e., not specifying whole-file).

Finally, --size-only will skip not only date-differing files, but changes you make that don't actually change the file size. If you update tags again, say change years or track numbers, that can be the case. That's why you want to leave the incremental checking in (see above paragraph). If the dates differ but content doesn't, rsync only has to update the time on the destination. You haven't wasted any time but are ensuring that the files are truly synced. When you specify --whole-file, it has to transfer the whole dang file no matter what.

rsync is one of the most fantastic command line utilities (closely followed by wget/curl) out there. It does have lots of fun options to play with, but what's great about it is that the defaults are often the best to go with. Trust it!



[ Reply to This | # ]
Try syncOtunes
Authored by: ThoGen on Oct 07, '04 06:02:06AM

http://homepage.mac.com/oligrob/syncOtunes/syncOtunes.html



[ Reply to This | # ]
Using rsync to sync iTunes on two computers
Authored by: atter_cob on Nov 01, '04 04:16:36AM

Take a look a Unison. I use it for this and it works great.



[ Reply to This | # ]