Using Mendeley and Dropbox to sync your pdf library across computers

Mendeley is a pdf and reference manager software that has a number of cool features: online/offline support, tools for creating public groups (=collections of references), and last but not least, it’s fast and easy to use. Since your references are synchronised via the online service, you can run Mendeley on more than one computer/device. However unless you pay for a fee you will be able to synchronise only up to 1 gig of data through it, which is probably not enough for some people. So here’s a simple method for using a cloud service like Dropbox to sync your entire pdf library without having to pay a cent.

The basic idea: keep all of your pdf files in the cloud using a Dropbox folder; also, keep the Mendeley database and preferences in the cloud, so that they are shared across computers. Finally, point Mendeley to that Dropbox folder and let it do the rest for us (e.g. keeping it organised etc.).

Warning: since with this method the preferences and database are shared across computers, you must make sure you don’t use Mendeley at the same time on both computers as that could lead to some conflict!

This recipe assumes that you have two macs and both Dropbox and Mendeley installed on both of them. We’ll call one of the two machines mac-1, and the other one mac-2.
Also, the method requires that you are using the same username on both macs. I know, this is a big limitation, but since Mendeley indexes pdf files using their full path that’s the only way for things to be wired up correctly (otherwise on one of the two macs the path of the pdf files will be broken).

1. Set up Mendeley and DropBox on mac-1

On Mac-1, create a Mendeley folder in your Dropbox. Within that, create two new folders, pdf and db.
Now launch Mendeley Desktop and in the preferences panel set the pdf-files location to the pdf folder you just created. After clicking on ‘apply’ Mendeley will move your existing library (if you have one) into the new folder. Wait till that’s finished before moving on to step 2.

Mendeley Prefs

2. Add Mendeley database to DropBox on mac-1

Close Mendeley Desktop on mac-1. Now open up the terminal and symlink the ~/Library/Application Support/Mendeley Desktop folder to the db folder just created in Dropbox. This way the DB and preferences can be shared across computers.


[mac]@mac1:~/Library/Application Support>cp -r Mendeley\ Desktop/ ~/Dropbox/Mendeley/db/
[mac]@mac1:~/Library/Application Support>mv Mendeley\ Desktop/ _backup_Mendeley_Desktop/
[mac]@mac1:~/Library/Application Support>ln -s ~/Dropbox/Mendeley/db/Mendeley\ Desktop .

Dropbox will start cloud-syncing the new folder we added. In the meantime, you can try launching Mendeley and checking that everything works at it should.

3. Set things up on mac-2

Put to sleep mac-1 and wake up mac-2. If you’re online, Dropbox on mac-2 will immediately start downloading all the new stuff you previously added to it (via mac-1). In the meantime, quickly open up Mendely and update the preferences as we did in step 1 above. Then closed it down.

Once the Dropbox download is finished, we can set up the symlink to the Mendeley database as we did in step 2 (no need to copy the db folder this time, because we’re using the folder already present in Dropbox/Mendeley/db):


[mac]@mac2:~/Library/Application Support>mv Mendeley\ Desktop/ _backup_Mendeley_Desktop/
[mac]@mac2:~/Library/Application Support>ln -s ~/Dropbox/Mendeley/db/Mendeley\ Desktop .

That’s it. You now should be able to open up Mendeley and have your entire library synchronised across the two computers (effectively, you’re working on a single library since your database is shared too).

Obviously you can still use the web-sync service, which is handy for example if you use also some mobile device. There you’ll still have the 1gig limitation for the pdf files, but at least for me that’s hardly a problem cause I don’t need to have my entire library on the go all the time (I just have a folder called ‘syncedStuff’ in Mendeley Desktop and synchronise only the files attached to that).

If things go wrong..

Well, I’d expect any wise pdf-collectors to make regular backups of their precious databases. In some cases though it’s not just a matter of putting things back as they were; for example once I moved the pdf source files to a different location, launched Mendeley and discovered that although my library was still there all the pdf links were broken.
Since I wanted to keep the new paths for all the pdf files, as a last resort I tried to hack into Mendeley’s own SQLite database and clean things up myself.

Here’s another post that explains how to modify Mendeley’s database manually: Using Mendeley effectively on multiple systems using an external storage drive

This is pretty easy actually. Mendeley stores the full file paths to your files in its database. In particular, the database file can be found in /Application Support/Mendeley Desktop, and it is named like this: youremail@www.mendeley.com.sqlite.

All you have to do is this: close down Mendeley (if it’s running), make a backup copy of the database file for safety purposes, then open it up using a SQLite GUI (e.g. on mac you can use SQLite Browser which is free). You’ll see that the Files table contains all the (wrong) paths to your pdf files; now you can update these paths by launching a simple ‘execute’ command, e.g.:


update Files set 
  localurl = replace(localurl, '/Users/me/Dropbox/Mendeley/old/path/', '/Users/me/Dropbox/Mendeley/new/path/');

Make sure the command did its job by checking the Files table contents; if that’s the case, the next time you launch Mendeley it won’t have no broken links anymore!

 

Share/Bookmark






  • Stefan

    Thanks a lot. It works perfect! :-)
    I use it for syncing Mendeley on Linux and Mac.

    Only if you later like to change the document path in Mendeley it is wise to pause Dropbox sync and to close the Mendeley instance on the other machine. Otherwise I experienced that the old configuration might be synced backwards.

    • mike

      I see – thanks for pointing that out!

  • Andy

    nice work…do you think this would also work when one computer is a mac and the other is a pc?

  • Tobi

    Hi,

    This works very well – thanks! One issue that I keep having is that the syncing of the subfolders does not appear to work properly. That is, when I put a file into a subfolder at my office mac and close Mendeley afterwards, it’s not referenced in the corresponding subfolder at my laptop at home (after having opened up Mendeley). Any idea what the reason for this could be?

    Also, in my Mendeley/db folder in Dropbox, I get conflicted files for the monitor.sqlite – does that have anything to do with the issue I’ve described above?

    Cheers,

    Tobi

    • mike

      I’ve never used subfolders so I can’t really help you with that (promise I’ll give it a go soon though!). Regarding the second issue, it *might* indeed be related to the first one as I never had any problem like that..

  • Brian

    Will this duplicate files? I’ve tried to sync PDFs using Dropbox and Mendeley in the past (not using this method, of course), and got duplicates when I renamed files. I think having Mendeley and Dropbox syncing simultaneously was problematic. Will the method outlined above avoid this issue? Thank you!

    • mike

      no this method won’t cause any duplicate, because as far as Mendeley goes there is only *one* database and pdf folder.

  • bergh

    This is good stuff!

    Since I use two macs and several PCs I wonder what would happen if I don’t yse step 2. If I tell each mendely installation to use the dropbox/pdf/ as a watchfolder and add any pdf there to its local database, would that not work? Would I loose some functionality?

  • Manuel

    Thanks a lot! This document has been very useful for me!

  • Mohan

    I do not think this will work on PC/Mac. I tried the method and created a symlink using the mklink in windows. but the file location for both windows and mac are different in windows it is C:\Users\loggeduser\Dropbox\mendeley and in mac /Users/loggeduser/Dropbox/mendeley this will create an issue. It has to be either 2 windows with same username or two mac with same username.

    Correct me if I am wrong on this? or anybody who is successful in getting this work on a Mac and PC

    -Mohan

    • http://michelepasin.org/ Mikele

      you’re right it won’t work across different operating systems, due to the different ways folders are managed.

    • ali

      but who got the solution for this then?

  • Raul

    No way to get it done:

    /Library/Application: No such file or directory error once and again

    it seems it is not able to read the space between “Application support”

    Mountain Lion on the run

    Any ideas?

    Thanks

    • http://michelepasin.org/ Mikele

      Try using tab for autocompletion. Otherwise look here http://apple.stackexchange.com/questions/14683/how-to-cd-to-a-directory-with-a-name-containing-spaces-in-bash

  • Matt

    Thanks for the instructions. Though I’m having a little trouble. Following everything, I can get the database to sync just fine, but if I add a file on one computer, it does not get linked in the database on the second computer. The DB shows the entry, the PDF is in the PDF folder, but there’s no link in Medeley to open the associated PDF. Any suggestions?

    • http://michelepasin.org/ Mikele

      are you using the same usernames on both macs? that’s a precondition for this method to work..

  • Georg Krainer

    I am wondering if you could give us a detailed desciption of how to sync Mendeley between two Windows based PCs/Laptops based on your method described here. I am a newbie to Mendely and I would like to have my database and PDFs (with Mendeley’s auto re-name function beeing active) being synchronized via DropBox on my Windows based computers. In particular, how is the symlink step accomplished. Thank you in advance!

    • http://michelepasin.org/ Mikele

      Creating symlinks in Windows is easy: http://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/

      However I can’t help you setting this up in more details cause I’m not a windows user….

  • Bernardo

    Hi. Amazing tutorial ! Thank you
    I don´t now much about programmation.
    I would like to edit many paths together.
    I want to edit first part of the paths of many lines (the paths of many files) that are equal on many paths.

    Like this:

    old/path/Mendeleylibrary/Paper01.pdf
    old/path/Mendeleylibrary/Paper02.pdf
    old/path/Mendeleylibrary/Paper03.pdf
    old/path/Mendeleylibrary/Paper04.pdf

    and change to

    new/path/Meneleylibrary/Paper01.pdf
    new/path/Meneleylibrary/Paper02.pdf
    new/path/Meneleylibrary/Paper03.pdf
    new/path/Meneleylibrary/Paper04.pdf

    What command Do I use to edit all this paths together ?

    • http://michelepasin.org/ Mikele

      Hi Bernardo – you can edit those paths by using a SQLite application (see the final section of the article). 
      A command like this would update the path of all files in the /old/path/Mendeley folder (make sure you backup your data before trying this out though!):
      =========
      update Files set
      localurl = replace(localurl, ‘/old/path/Mendeley/’, ‘/new/path/Mendeley/’);
      =========

  • Pingback: Sincronización de artículos con Mendeley y Dropbox | ¡Woof!