Upgrading Redmine 1.0.1 to 2.5.1 on Debian Squeeze (from repo to standalone mode)

Debain Squeeze has Redmine 1.0.1 in it's repositories. If you want to install latest 2.x branch, you need to switch from package to standalone setup. Here is a step-by-step howto guide.

We will remove the package, place new binaries at the same folder and upgrade database. There also some squeeze-specific workarounds.

Preparation

1. Dump redmine_default database:

mysqldump -u redmine -p redmine_default > /root/redmine/db.sql

2. Backup attachments folder:

cp -R /var/lib/redmine/default/files /root/redmine/files

3. Delete redmine:

apt-get remove redmine

During uninstall choose to keep old database.

Setup

1. Required packages:

apt-get install imagemagick libmagickcore-dev libmagickwand-dev libmysqlclient-dev

Fix for: missing requirements for bundler

2. Delete old Redmine, download new Redmine instead:

rm -R /usr/share/redmine
cd /usr/share
wget http://www.redmine.org/releases/redmine-2.5.1.tar.gz
tar -xvf redmine-2.5.1.tar.gz
ln -s /usr/share/redmine-2.5.1 /usr/share/redmine
cd /usr/share/redmine

3. Install bundler:

gem install bundler

4. Prepare environment:

export PATH=$PATH:/var/lib/gems/1.8/bin

Fix for: "command not found" for bundle command

5.Configure:

cp /usr/share/redmine/config/configuration.yml.example /usr/share/redmine/config/configuration.yml
cp /etc/redmine/default/database.yml /usr/share/redmine/config/database.yml

Edit /usr/share/redmine/config/database.yml and change adapter from mysql to mysql2.

Edit /usr/share/redmine/config/configuration.yml and setup the secret_token. Email config is also here now, so you can copy old settings from /etc/redmine/default/email.yml here by hand.

You'll need to add enable_starttls_auto: false to smtp_settings group for this delivery method to work on Squeeze

6. Install:

bundle install --without development test

7. Edit /usr/share/redmine/Gemfile, change rake version in it to:

gem "rake", "0.8.7" 

Fix for: rake crash on start-up. 0.8.7 is the latest compatible version.

8. Reconfigure rake:

bundle update rake

9. Upgrade database and drop caches:

rake generate_secret_token
rake db:migrate RAILS_ENV=production
rake tmp:cache:clear
rake tmp:sessions:clear

10. Bring back the attachments:

cp -R /root/redmine/files/* /usr/share/redmine/files/

There are other ways to do this. For example, you can create a symlink from /usr/share/redmine/files to /var/lib/redmine/default/files and keep using previous location

11. Change directory owner:

chown -R www-data /usr/share/redmine

Fix for: 500 error on administrative pages. Some people say it's enough to chmod -R 777 /usr/share/redmine/tmp, but it didn't work for me

12. Restart web-server and enjoy.