How to install a recent/up-to-date version of a package on a server running the stable Debian tree

Imho Debian is one of the best distributions out there. Its development cycle is a bit slower compared to the other distros, but most of the time I consider this to be an advantage. However you might face a situation where you are forced to get a recent version of an application eg. because of a critical bug fix. You've two choices:
  • download the latest version and compile from source
  • or use some sort of a "backport" of that package
Backports are recompiled packages from the testing (mostly) and unstable (in a few cases only, e.g. security updates) trees, so they will run without new libraries (wherever it is possible) on a stable Debian distribution.

You can find detailed instructions on how to use the official Debian backports repository here. I chose to go with pinning and it seems to be a good practise to me. Eg. to install the recent version of MySQL 5.x, you've to add the following to your /etc/apt/preferences file (or create the file if you didn't have it yet):
Package: mysql-server-5.0
Pin: release a=etch-backports
Pin-Priority: 999

Package: mysql-client-5.0
Pin: release a=etch-backports
Pin-Priority: 999

Package: mysql-common
Pin: release a=etch-backports
Pin-Priority: 999

Package: libmysqlclient15off
Pin: release a=etch-backports
Pin-Priority: 999

And of course add the backports repository to your sources.list list file, as written on the page that I referred to earlier. After that you just have to issue an apt-get update && apt-get upgrade and the new version is installed without any problems. Of course you better make a backup of your database before jumping twenty-something in the minor version number of the MySQL server. Smile

If you want to learn more about APT pinning, read the apt_preferences manpage. It has a detailed (and easily understandable) description of all the pinning parameters/options available in the /etc/apt/preferences file.