Overview:
Over the past week or two, I've been experimenting with using Dropbox to sync my xbmc library over multiple computers and I wanted to document my experiences. This "guide" is for windows (although could easily be adapted to work on linux & osx) and is HIGHLY EXPERIMENT AND DOESN'T WORK 100% OF THE TIME! If you're not into experimenting/tinkering/trying out stuff that might not work... well then, what the heck are ya doing on the xbmc forums in the first place!? Anyway this setup has been work pretty well for me for the past week, but because of the way dropbox handles conflicting files, I still felt that warning was necessary. Now first off, so that you can understand why this works for me, let me explain how I use XBMC...
My XBMC Setups:
I've got two windows 7 machines running xbmc in my house. Machine 1 (which i will call my server) is always on and doing something (fairly powerful dual core athalon). Machine 2 (which I will call my node) is in the bedroom and is a tiny Acer Aspire Revo R1600 (single-core) ION-based pc. The node, as opposed to the server, is put to sleep whenever it's not needed. Also, the sources on both machines are identical (but not synced). All my media files are on a samba share, so the paths are the same on both machines, which is vital for this to work. The important thing to know about my setup is that 98% of the time, I only have one instance of xbmc running at one time. So file conflicts (i.e. both machines writing to the library at the same time) are a rarity for me (but does happen from time to time). The good news is that dropbox will never write to a file that is in use on the machine, so there is never a fatal error that will lock up xbmc and corrupt your library. The bad news is that dropbox will at no point try and merge the files (some might see this is a good thing too, since dropbox doesn't speak SQL and would probably screw up if it tried), so if two machines write to the library at the same time, you will wind up with 2 copies of the offending library .db file in your dropbox/database folder. One will be named correctly and one will have some extra text appended to it (https://www.dropbox.com/help/36). I'm hoping to do some more testing of both machines running at the same time, this week.
Dropbox Setup:
First off, start by picking one machine to work from for now. Update your library, make sure you thumbnails show up correctly on one machine. This whole process will go a lot smoother if you start with a complete and functioning library as opposed to trying to combine 2 or 3 of them or trying to set up syncing before building the library. You'll be able to update the library from any machine after this setup is complete, but it's definitely easier if it's as complete as possible to start with.
The trick to getting dropbox working with XBMC is symlinks. My first instinct was to just create a symlink in the dropbox folder that linked to XBMC's database folder, but this will NOT work. Dropbox will update the files there, but only when the machine (or the dropbox app) is restarted. So instead, you have to copy the Database & Thumbnail folders to your dropbox first, and then create hard symlinks (/J) in xbmc's userdata folder (if you don't maintain a library, and are only concerned with the watched/unwatched flag & resume times, then you probably don't need to sync the thumbnails folder, but if you scrape your library and have cover art, then it's a must... more on that later). I also renamed the Database & Thumbnail folders to XBMCDatabase & XBMCThumbnails once they were in my dropbox, just to make them a little more distinctive.
Helpful Tip: if your other machines all have similar setups to the one you're working from now, make a little batch file to rename or delete the old folders and create the symlinks, and put it in your dropbox. This will make setting up the nodes a lot easier later on, since all you'll have to do is install dropbox, let the files sync, and then double click the batch file. My batch file looks like this (keep in mind, I use XBMC in portable mode, so your userdata folder will probably be in a different location).
(on the first 2 lines, you could also do a "del /s /q" on those folders instead of a rename, which is what I did, but this is a bit safer)
Now if you have a large library, dropbox is gonna take a while to upload all your thumbnails. Also you should be weary of how big that thumbnail folder is (mine was just over a gig, luckily i had enough free space in my dropbox to accommodate it). But you should be able to use XBMC on this machine to verify that the symlinks are working (even while dropbox is still syncing).
IMPORTANT: You should let dropbox finish its initial sync before you attempt to set it up on another machine. It's not that dropbox would cause an error, but if you try and run XBMC before you're thumbnails have all been uploaded & synced, then you're probably gonna wind up with a whole bunch of useless .tbn files that are random frames from the videos (cause xbmc will create the ones that are missing instead of reloading them from their source.
After the initial upload, setting up your other xbmc nodes should be pretty easy. Just install dropbox, let it is sync (the downloads should be a lot quicker than the uploads), and double click the batch file (or create your own symlinks manually).
IMPORTANT: When setting up your nodes, make SURE that dropbox has finished it's initial sync BEFORE you try to run XBMC, to avoid the same problem described above (losing thumbnails).
After that, you're done. You now have 2 (or more) machines synced to the same library and with all thumbnails. You should be able to start playing something on one machine, stop it, and pick up where you left off on the other machine, within a matter of a few seconds. You should also be able to add or delete from the library on one machine and see the changes on the other (as long as both machines aren't making changes at the exact same time).
Real World Usage, Caveats and Concessions:
-Syncing the Thumbnails folder: When I first set this up, I was only syncing the Database folder. But what i noticed was when I updated the library on one machine (adding new content), the data would appear on the other machine, but none of the images would (even if the .tbn's were on the shared drive with the movies). To get the images to show up I would have to refresh the info for each movie/tv show that wasn't showing artwork (doing a normal library update would not solve the problem). This is when I started syncing the Thumbnails directory as well.
-Updating the Library: When updating the library, make sure all other instances of xbmc are not running! I have no problem with playing video on multiple boxes at the same time, since if there is a conflict the result will be nothing more than a missing resume point or watched flag, but if I'm updating my library on one machine, I'm making damn sure that the others are OFF, just to be safe.
-Putting to Sleep: So I usually put my xbmc node to sleep when I'm done watching, but here's the problem... I've configured eventghost to handle the power button on my remote, so that it always attempts to stop any playing video before going to sleep. This is great because I can just press power and xbmc will save the resume point, however I noticed that the machine was going to sleep before dropbox was finished uploading the diff created by that tiny database update. To rectify this, I altered my eventghost config on that machine to pause for 15 seconds in between stopping the video and actually going to sleep. This seems to do the trick for me, but your mileage may vary based on the speed of your net connection & the speed of your pc (remember, dropbox only uploads binary diffs when changes are made to files, not the complete file, so the upload time is pretty small when the only thing that changed was a watched flag and a resume point).
-Duplicate files: I haven't yet played too much with file conflicts as I've only encountered a small handful. But to keep my dropbox tidy I scheduled a batch script on my server to run at 4am every day and delete any duplicate files that dropbox created. ll my batch file does is "del *(*).db" (it's stored in the XBMCDatabase folder in my dropbox, and scheduled with Windows Task Scheduler). But I definitely need to do more testing with this feature. What might be a good idea is to have a script or small app determine which version is bigger and delete the smaller one (and then make sure the leftover one is named properly), so I might try and throw a little .net app together to do this.
Over the past week or two, I've been experimenting with using Dropbox to sync my xbmc library over multiple computers and I wanted to document my experiences. This "guide" is for windows (although could easily be adapted to work on linux & osx) and is HIGHLY EXPERIMENT AND DOESN'T WORK 100% OF THE TIME! If you're not into experimenting/tinkering/trying out stuff that might not work... well then, what the heck are ya doing on the xbmc forums in the first place!? Anyway this setup has been work pretty well for me for the past week, but because of the way dropbox handles conflicting files, I still felt that warning was necessary. Now first off, so that you can understand why this works for me, let me explain how I use XBMC...
My XBMC Setups:
I've got two windows 7 machines running xbmc in my house. Machine 1 (which i will call my server) is always on and doing something (fairly powerful dual core athalon). Machine 2 (which I will call my node) is in the bedroom and is a tiny Acer Aspire Revo R1600 (single-core) ION-based pc. The node, as opposed to the server, is put to sleep whenever it's not needed. Also, the sources on both machines are identical (but not synced). All my media files are on a samba share, so the paths are the same on both machines, which is vital for this to work. The important thing to know about my setup is that 98% of the time, I only have one instance of xbmc running at one time. So file conflicts (i.e. both machines writing to the library at the same time) are a rarity for me (but does happen from time to time). The good news is that dropbox will never write to a file that is in use on the machine, so there is never a fatal error that will lock up xbmc and corrupt your library. The bad news is that dropbox will at no point try and merge the files (some might see this is a good thing too, since dropbox doesn't speak SQL and would probably screw up if it tried), so if two machines write to the library at the same time, you will wind up with 2 copies of the offending library .db file in your dropbox/database folder. One will be named correctly and one will have some extra text appended to it (https://www.dropbox.com/help/36). I'm hoping to do some more testing of both machines running at the same time, this week.
Dropbox Setup:
First off, start by picking one machine to work from for now. Update your library, make sure you thumbnails show up correctly on one machine. This whole process will go a lot smoother if you start with a complete and functioning library as opposed to trying to combine 2 or 3 of them or trying to set up syncing before building the library. You'll be able to update the library from any machine after this setup is complete, but it's definitely easier if it's as complete as possible to start with.
The trick to getting dropbox working with XBMC is symlinks. My first instinct was to just create a symlink in the dropbox folder that linked to XBMC's database folder, but this will NOT work. Dropbox will update the files there, but only when the machine (or the dropbox app) is restarted. So instead, you have to copy the Database & Thumbnail folders to your dropbox first, and then create hard symlinks (/J) in xbmc's userdata folder (if you don't maintain a library, and are only concerned with the watched/unwatched flag & resume times, then you probably don't need to sync the thumbnails folder, but if you scrape your library and have cover art, then it's a must... more on that later). I also renamed the Database & Thumbnail folders to XBMCDatabase & XBMCThumbnails once they were in my dropbox, just to make them a little more distinctive.
Helpful Tip: if your other machines all have similar setups to the one you're working from now, make a little batch file to rename or delete the old folders and create the symlinks, and put it in your dropbox. This will make setting up the nodes a lot easier later on, since all you'll have to do is install dropbox, let the files sync, and then double click the batch file. My batch file looks like this (keep in mind, I use XBMC in portable mode, so your userdata folder will probably be in a different location).
Code:
rename "C:\Program Files\XBMC\userdata\Database" "C:\Program Files\XBMC\userdata\Database.bak"
rename "C:\Program Files\XBMC\userdata\Thumbnails" "C:\Program Files\XBMC\userdata\Thumbnails.bak"
mklink /j "C:\Program Files\XBMC\userdata\Thumbnails" "C:\Users\[myusername]\Documents\My Dropbox\XBMCThumbnails"
mklink /j "C:\Program Files\XBMC\userdata\Database" "C:\Users\[myusername]\Documents\My Dropbox\XBMCDatabase"
(on the first 2 lines, you could also do a "del /s /q" on those folders instead of a rename, which is what I did, but this is a bit safer)
Now if you have a large library, dropbox is gonna take a while to upload all your thumbnails. Also you should be weary of how big that thumbnail folder is (mine was just over a gig, luckily i had enough free space in my dropbox to accommodate it). But you should be able to use XBMC on this machine to verify that the symlinks are working (even while dropbox is still syncing).
IMPORTANT: You should let dropbox finish its initial sync before you attempt to set it up on another machine. It's not that dropbox would cause an error, but if you try and run XBMC before you're thumbnails have all been uploaded & synced, then you're probably gonna wind up with a whole bunch of useless .tbn files that are random frames from the videos (cause xbmc will create the ones that are missing instead of reloading them from their source.
After the initial upload, setting up your other xbmc nodes should be pretty easy. Just install dropbox, let it is sync (the downloads should be a lot quicker than the uploads), and double click the batch file (or create your own symlinks manually).
IMPORTANT: When setting up your nodes, make SURE that dropbox has finished it's initial sync BEFORE you try to run XBMC, to avoid the same problem described above (losing thumbnails).
After that, you're done. You now have 2 (or more) machines synced to the same library and with all thumbnails. You should be able to start playing something on one machine, stop it, and pick up where you left off on the other machine, within a matter of a few seconds. You should also be able to add or delete from the library on one machine and see the changes on the other (as long as both machines aren't making changes at the exact same time).
Real World Usage, Caveats and Concessions:
-Syncing the Thumbnails folder: When I first set this up, I was only syncing the Database folder. But what i noticed was when I updated the library on one machine (adding new content), the data would appear on the other machine, but none of the images would (even if the .tbn's were on the shared drive with the movies). To get the images to show up I would have to refresh the info for each movie/tv show that wasn't showing artwork (doing a normal library update would not solve the problem). This is when I started syncing the Thumbnails directory as well.
-Updating the Library: When updating the library, make sure all other instances of xbmc are not running! I have no problem with playing video on multiple boxes at the same time, since if there is a conflict the result will be nothing more than a missing resume point or watched flag, but if I'm updating my library on one machine, I'm making damn sure that the others are OFF, just to be safe.
-Putting to Sleep: So I usually put my xbmc node to sleep when I'm done watching, but here's the problem... I've configured eventghost to handle the power button on my remote, so that it always attempts to stop any playing video before going to sleep. This is great because I can just press power and xbmc will save the resume point, however I noticed that the machine was going to sleep before dropbox was finished uploading the diff created by that tiny database update. To rectify this, I altered my eventghost config on that machine to pause for 15 seconds in between stopping the video and actually going to sleep. This seems to do the trick for me, but your mileage may vary based on the speed of your net connection & the speed of your pc (remember, dropbox only uploads binary diffs when changes are made to files, not the complete file, so the upload time is pretty small when the only thing that changed was a watched flag and a resume point).
-Duplicate files: I haven't yet played too much with file conflicts as I've only encountered a small handful. But to keep my dropbox tidy I scheduled a batch script on my server to run at 4am every day and delete any duplicate files that dropbox created. ll my batch file does is "del *(*).db" (it's stored in the XBMCDatabase folder in my dropbox, and scheduled with Windows Task Scheduler). But I definitely need to do more testing with this feature. What might be a good idea is to have a script or small app determine which version is bigger and delete the smaller one (and then make sure the leftover one is named properly), so I might try and throw a little .net app together to do this.