XBMC Community Forum
HOW-TO synchronize your XBMC Media Center between every room in the house: Lifehacker - Printable Version

+- XBMC Community Forum (http://forum.xbmc.org)
+-- Forum: Announcements, Info, and General Discussion (/forumdisplay.php?fid=85)
+--- Forum: Tips, tricks, and step by step guides (/forumdisplay.php?fid=110)
+--- Thread: HOW-TO synchronize your XBMC Media Center between every room in the house: Lifehacker (/showthread.php?tid=80829)



- aptalca - 2011-08-17 17:05

gabbott Wrote:Thanks so much for the tip and helpful how-to on your site.

After some initial pains getting syncing completely working last night with thumbnails, looks like everything is working as it should now.

Now it got me thinking about trying Unison as a cross-platform, open source alternative.

I was planning to do the same with rsync and cwrsync.

But there are a couple of potential problems I can think of. Especially because I am adding stuff to the library several times a day. I would appreciate you guys' ideas.

1) XBMC boxes are off/sleep unless they are being used, so syncing between them at scheduled times is not an option

[INDENT]I could sync all the thumbnail folders on different machines with a backup thumbnail folder that resides on the server that also hosts the mysql because it is always on[/INDENT]

2) One xbmc box updates library, another one is missing the newly added thumbnails until next scheduled sync. When should the syncs be scheduled to minimize the occurrance of this scenario?

[INDENT]Script can be run on xbmc start-up. (Does not work if boxes are put in sleep mode with xbmc on)

Maybe the script can also be run following each update. So for instance, machine 1 updates library, script automatically runs and syncs machine 1's folder with the server folder. When machine 2 is turned on and xbmc started, machine 2's folder syncs with the server folder. But the question is can xbmc be set up to run scripts following library updates?[/INDENT]

Another way would be to have the scheduling independent of xbmc, and very frequent. Such as having each machine syncing their folder with the server every five minutes whenever the are on. That way the maximum window of having missing artwork would be 10 min (following lib update on machine 1, up to 5 min delay for syncing the server folder and another up to 5 min delay for syncing machine 2's folder). Do you guys think that would be overkill? I mean running rsync with no updates would take a split second and very very little resources. Right? Would that be bad for an unraid setup where there is server access every 5 min from multiple machines?


- svenh - 2011-08-17 21:18

I was originally going to go the RSYNC route as well just like you said, and was going to use a cron job to move the data back and forth, but finding a decently working rsync server for Windows was just a pain.

If my server would have been Linux I would have gone that route for sure, just because you never have to worry about running out of space in your drop box folder.

To answer your question though, if you use a cron job that syncs at start up, and then every 2 minutes after that chances that you will miss an update are pretty slim. As you said, rsync will not hammer the discs, and the split second access is nothing to worry about either.

For me it ended up being too much of a hassle. Tryign to figure out how I had to sync between the devices (too many what-if scenarios; is the bedroom one out of date, but the living room didn't sync? etc) Dropbox does it all rather elegantly in the background with minimal configuration, and you even get the "benefit" of "offsite backup". Plus it does local lan replication so you shouldn't have to worry too much about replication between clients on the lan.

I sync my thumbs folder to dropbox, my db server (windows) and two revo's running xbmc-live, and never had a problem. I would like to clean out the thumbs folder/textures.db eventually, but I have not had a chance to really do that yet.


- aptalca - 2011-08-17 21:42

So dropbox pretty much syncs every client folder with their online server? Up to 2GB is free, but then you have to pay. The only thing is, last time I checked, my thumbs folder was larger than 2GB so I would have to pay.

You mentioned local LAN replication. Is that an offline replication process (only between the clients on the same LAN) that wouldn't use up your 2GB online quota??

**EDIT**

I guess the LAN sync only speeds up the sync process and minimizes ISP traffic.

I wish they had a LAN only sync solution that would be free. Essentially that is exactly what I'll be trying to achieve with rsync.

Btw, I use cwrsync for windows, and it actually works really well. It is a simple no gui, command line only software that you use with arguments just like in linux. In windows, you can use the task scheduler to run it at set intervals


- svenh - 2011-08-18 02:47

Yeah unfortunately it only syncs faster, not for free. As you said if you have a really large thumbnails folder it won't work for you.

I agree with you, a lan only sync solution that is multi platform, and as easily configured as dropbox would rock.

Can you share a quick howto for people who may not be as familiar with how to use cwrsync? Might help some other people out!


- ederson - 2011-08-18 19:47

gabbott Wrote:Are you sure it just cant connect or maybe it is because you are trying to connect to a library database that is for Dharma? (because they aren't compatible)

i`ve tried this with an empty database and i get the same error

20:45:15 T:9980 ERROR: Unable to open database xbmc_music_eden


- aptalca - 2011-08-19 18:00

svenh Wrote:Can you share a quick howto for people who may not be as familiar with how to use cwrsync? Might help some other people out!

Just check out this faq section on the cwrsync website.

There are guides on how to setup connections between different server and client setups (win/win, win/linux, etc.) and also with or without SSH.

Instructions are very easy to follow.

I use cwrsync on my windows laptop to take backups of my website hosted on a remote linux server. Once I installed the client software, all I had to do was to edit the batch file that came with it called "cwrsync.cmd" (which sets the paths for rsync and ssh, etc.) and add the line at the end
Code:
rsync -av 'ssh -p 1234 -i sshkeypath' sourcefolderpath targetfolderpath

Replace 1234 with your ssh port and in folder and file paths, in windows, for c:\backup\ use this format instead: /cygdrive/c/backup/

I run this command file every once in a while manually. (My website is already being backed up on two different sites online, automatically, so the local backup is an absolute worst case scenario) But in win 7 you could use start/control panel/system&security/administrative panel/task scheduler to automate it.

And also keep in mind that rsync is one way. But for thumbs folder we need it to be two way. So just replicate that line in the same batch file and switch the source and target folder paths. And do not use the --delete option.

**UPDATE**

I just realized that since we are doing a two way sync and files might have been modified at either the server or client, we need to use option -u as well. Because that will prevent a destination file to be overwritten if the destination file has been modified.

--I am assuming XBMC overwrites a cache file when the artwork is changed. Even if it doesn't this option won't hurt. --

Scenario: Client 1 changes fanart for movie A. Client 1 rsyncs with server. The cache file for movie A's fanart is updated on the server.
Client 2 rsyncs with server. Let's say it does client-to-server sync first. Both the client and the server has the same cache file for movie A's fanart. But the one on the server is modified last and is the one we want. Without the -u option, client-to-server sync will overwrite the cache file on the server and we revert the recently changed fanart to the old one. But with the option -u, during client-to-server sync, cache file is ignored, and when it's time for server-to-client sync for client 2, the local cache file gets overwritten by the one on the server because it is a later revision, which is exactly what we want.

So the batch file code will look something like this:

Code:
rsync -avu 'ssh -p 1234 -i sshkeypath' clientfolderpath serverfolderpath
rsync -avu 'ssh -p 1234 -i sshkeypath' serverfolderpath clientfolderpath



- smiffy1989 - 2011-08-20 22:21

Is the -r option needed also to sync recursively?


- elmerohueso - 2011-08-21 05:54

I got my library synced. Since the library doesn't include the fanart and covers, I used a scraper to store each movie's cover and fanart locally to so each XBMC setup wouldn't have to scrape its own data. However, my other XBMC boxes were only seeing the locally stored fanart and still going online for all the covers. I saw some other suggestions for syncing the Thumbnails folder instead or even using symbolic links. However, after some searching, I found you can just change the path of the Thumbnails folder (at least in the nightlies). So, I shared the Thumbnails folder on my media server (which is hosting the library in MySQL) and added the following code to my advancedsetting.xml on my other boxes:
Code:
<pathsubstitution>
    <substitute>
        <from>special://masterprofile/Thumbnails</from>
        <to>\\[ServerName]\[SharedThumbnailsFolder]</to>
    </substitute>
</pathsubstitution>

It seems to be working just fine. It requires less work than syncing the multiple Thumbnails directories, and I don't have to worry about symbolic links.

Hope this helps anyone else.


- ederson - 2011-08-21 16:29

i have a strange problem

when i use the mysql db i can`t access the movie info screen ..... !!!!!!!!!!!!!!
the moment i return to the local db everything is ok.

could anyone verify this or it`s just me and i should check my installation ?


it seems that it`s happening only to imported date from the dharma db ..... i guess it`s off topic


- aptalca - 2011-08-21 22:07

smiffy1989 Wrote:Is the -r option needed also to sync recursively?

the -a option includes recursive

taken from here:

Quote:rsync option -a indicates archive mode. -a option does the following,

Recursive mode
Preserves symbolic links
Preserves permissions
Preserves timestamp
Preserves owner and group