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

Keep Safari/Mail RSS feeds in sync between two Macs UNIX
I have two Macs, a desktop and a portable, and on both I use Safari as an RSS reader. Until recently, I was having trouble keeping feeds synchronized. Obviously, after reading a set of feeds on one machine, I don't want to see them unread when I switch to the other one. I'm well aware that this problem can be solved by subscribing to MobileMe, Google Reader, or other "cloud data" services. I choose not to use them because of privacy concerns, which I'm not going to debate here. So I came up with a simple standalone method to sync my RSS data.

My research showed that Safari stores information about RSS feeds in an SQLite database file called Database.sqlite3 in your home directory. That database is managed by a background process called PubSubAgent, which starts automatically when you log in. This process communicates with MobileMe, if you have an account, to sync the database between devices. I assume this is done by sending SQL commands over the network. Safari and Mail are also clients of PubSubAgent.

Now, in general there's no way to duplicate the functionality of MobileMe. If you read some feeds on host A, then some other feeds on host B, you have two conflicting versions of the database. You can't resolve the conflict by simply copying the file from A to B or vice versa. MobileMe will resolve it by merging the changes so that any feed marked as read on either A or B will be marked read on both. This also works if you have more than two devices on the same account.

But in my case, I have only two devices, and I use only one at a time. When I switch from A to B, I should be able to just copy the database file from A to B over the network and take up where I left off.

I tried this, and it didn't work. PubSubAgent is constantly watching Database.sqlite3 and won't let anything else change it -- the changes either aren't recognized or are immediately reverted. There's also the problem that the file may be changing on the remote host while you're copying it, resulting in either a failed copy or a corrupted database on the local host, depending on what method you use. Also, you can't just disable PubSubAgent, because then RSS doesn't work at all in Safari or Mail.

To make the sync work, I use a shell script to temporarily stop PubSubAgent on both the remote and the local host, the restart it after the copy. I run this whenever I sit down in front of either Mac. Here's the script. Note that you must modify this script to make it work.
hostnames=' hostA hostB'
label=com.apple.PubSub.Agent
file=~/Library/PubSub/Database/Database.sqlite3
remote=${hostnames/ $(hostname)/}
launchctl stop $label
ssh $remote launchctl stop $label
scp ${remote}:$file $file
launchctl start $label
ssh $remote launchctl start $label
The script uses SSH, which you need to have set up with public-key authentication in both directions between the hosts. You also need to edit the first line, replacing hostA and hostB with the output of the hostname command on each machine. If the hostname is something like myname.local, then the script will only work when both hosts are on the same local network (or VPN). If you're syncing machines that are reachable by SSH, but are never on the same network, you'll have to modify the script.

For me, the most convenient way to run the script is to wrap it in an AppleScript using the do shell script verb, and save it as a script bundle in my ~/Library/Scripts folder. It's then available under the Scripts menu. This is a pretty crude technique, but it works well for me. I'm putting in here in the hope that someone will suggest an improvement.
    •    
  • Currently 2.44 / 5
  You rated: 5 / 5 (9 votes cast)
 
[11,977 views]  

Keep Safari/Mail RSS feeds in sync between two Macs | 3 comments | Create New Account
Click here to return to the 'Keep Safari/Mail RSS feeds in sync between two Macs' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Keep Safari/Mail RSS feeds in sync between two Macs
Authored by: nek on Aug 05, '09 04:23:06PM

I must be missing something huge here. MobileMe does not sync RSS feed status at all. It syncs bookmarks yes, but no amount of fiddling will make it sync read/unread status of subscriptions.
Rest of the hint is pretty good though...



[ Reply to This | # ]
Keep Safari/Mail RSS feeds in sync between two Macs
Authored by: lincd0 on Aug 05, '09 08:32:51PM

I've never used MobileMe, so I'm no authority on what it does. My understanding is that bookmark syncing includes RSS syncing, since RSS feeds in Safari are bookmarks. Certainly the infrastructure for it seems to be in place. But if I'm wrong, then the procedure above does something you can't do with MobileMe.



[ Reply to This | # ]
Keep Safari/Mail RSS feeds in sync between two Macs
Authored by: ottovelo on Sep 30, '09 02:56:11PM

what about replacing that file by an alias on both computers and putting the original in a dropbox? Looks like being way easier to me...



[ Reply to This | # ]