Spotify and Linux: Backing it up with dpkg-repack

Spotify is great and it is nearly the only choice if you want a music streaming service with a native Linux client. But the client is still in a "preview" stage. So if Spotify releases a new version of the Linux client, it sometimes botches your spotify installation. So if you do your "apt-get update && apt-get upgrade" dance, it might leave you without music (eeeeeeek!). But fear not! There is an easy way to backup your working Spotify installation on an Ubuntu/Debian system.

First, install the required tools: sudo apt-get install fakeroot dpkg-repack

Then run the following line: for I in $(dpkg-query -W -f='${Package} ' spotify*); do fakeroot -u dpkg-repack $I; done

This will recreate the .deb Spotify packages from the files installed on your system and place them in the current directory (just make sure you are in a directory with write access). Its easy to roll back to an old installation by installing the .deb files with "dpkg -i".

Now you just have to remember to do this, when you got a running Spotify or you could create a cron job to backup periodically.