RedmineUpgrade

Version 50 (Etienne Massip, 2011-12-12 14:29)

1 44 James Turnbull
h1. Upgrading
2 44 James Turnbull
3 44 James Turnbull
{{>toc}}
4 44 James Turnbull
5 44 James Turnbull
h2. Step 1 - Check requirements
6 44 James Turnbull
7 44 James Turnbull
The first step to upgrading Redmine is to check that you meet the [[RedmineInstall#Requirements|requirements]] for the version you're about to install.
8 44 James Turnbull
9 44 James Turnbull
h2. Step 2 - Backup
10 44 James Turnbull
11 44 James Turnbull
It is recommended that you backup your database and file uploads.  Most upgrades are safe but it never hurts to have a backup just in case.
12 44 James Turnbull
13 44 James Turnbull
h3. Backing up the files
14 44 James Turnbull
15 44 James Turnbull
All file uploads are stored to the @files/@ directory.  You can copy the contents of this directory to another location to easily back it up.
16 44 James Turnbull
17 44 James Turnbull
h3. MySQL database
18 44 James Turnbull
19 44 James Turnbull
The @mysqldump@ command can be used to backup the contents of your MySQL database to a text file. For example:
20 44 James Turnbull
<pre>
21 44 James Turnbull
/usr/bin/mysqldump -u <username> -p<password> <redmine_database> | gzip > /path/to/backup/db/redmine_`date +%y_%m_%d`.gz
22 44 James Turnbull
</pre>
23 44 James Turnbull
24 44 James Turnbull
25 44 James Turnbull
h3. SQLite database
26 44 James Turnbull
27 44 James Turnbull
SQLite databases are all contained in a single file, so you can back them up by copying the file to another location.
28 44 James Turnbull
29 44 James Turnbull
h3. PostgreSQL
30 44 James Turnbull
31 44 James Turnbull
The @pg_dump@ command can be used to backup the contents of a PostgreSQL database to a text file. Here is an example:
32 44 James Turnbull
<pre>
33 44 James Turnbull
/usr/bin/pg_dump -U <username> -Fc --file=redmine.sqlc <redmine_database>
34 44 James Turnbull
</pre>
35 44 James Turnbull
A decent blog (self plug) can be found here: http://www.commandprompt.com/blogs/joshua_drake/2010/07/a_better_backup_with_postgresql_using_pg_dump/
36 44 James Turnbull
37 44 James Turnbull
h2. Step 3 - Perform the upgrade
38 44 James Turnbull
39 44 James Turnbull
Now it's time to perform the actual upgrade.  This process is different depending on how you downloaded Redmine.  You only need to perform *one* of the following options.
40 44 James Turnbull
41 44 James Turnbull
h3. Option 1 - [[Download|Downloaded release]] (tar.gz or zip file)
42 44 James Turnbull
43 44 James Turnbull
1. Uncompress the new program archive in a new directory.
44 44 James Turnbull
45 44 James Turnbull
2. Copy your database settings-file @config/database.yml@ into the new @config@ directory.
46 44 James Turnbull
47 48 Etienne Massip
3a. Copy your base configuration settings-file @config/configuration.yml@ into the new @config@ directory.
48 48 Etienne Massip
49 48 Etienne Massip
3b. Or, *if upgrading from version older than 1.2.0*, copy your email settings from your @config/email.yml@ into the new @config/configuration.yml@ file that can be created by copying the available @configuration.yml.example@ file.
50 44 James Turnbull
51 46 Etienne Massip
4. Copy the @files@ directory content into your new installation.
52 44 James Turnbull
53 47 Etienne Massip
5. Copy the folders of your *custom* installed plugins from your @vendor/plugins@ directory into new installation directory. Make sure that you copy only plugins that are were not initially bundled with your previous Redmine setup.
54 44 James Turnbull
55 46 Etienne Massip
6. Run the following command from your new Redmine root directory:
56 44 James Turnbull
57 44 James Turnbull
  rake config/initializers/session_store.rb
58 44 James Turnbull
59 44 James Turnbull
If you're using a newer version of Redmine, the above file will no longer exist. On these versions, run
60 44 James Turnbull
61 44 James Turnbull
  rake generate_session_store
62 44 James Turnbull
63 44 James Turnbull
This will generate a file (@config/initializers/session_store.rb@) with a random secret used to secure session data.
64 44 James Turnbull
65 46 Etienne Massip
7. Check for any themes that you may have installed in the @public/themes@ directory. You can copy them over but checking for updated version is ideal.
66 44 James Turnbull
67 44 James Turnbull
VERY IMPORTANT: do NOT overwrite @config/settings.yml@ with the old one.
68 44 James Turnbull
69 44 James Turnbull
h3. Option 2 - Upgrading from a SVN [[CheckingoutRedmine|checkout]]
70 44 James Turnbull
71 44 James Turnbull
1. Go to the Redmine root directory and run the following command:
72 44 James Turnbull
<pre>
73 44 James Turnbull
svn update
74 44 James Turnbull
</pre>
75 44 James Turnbull
76 44 James Turnbull
2. If you are upgrading from an older version to 0.8.7+ or from the trunk version of Redmine to r2493 or above, you must generate a secret for cookie store.  See the note at the bottom about generating a @session_store@.
77 44 James Turnbull
78 44 James Turnbull
h2. Step 4 - Update the database
79 44 James Turnbull
80 44 James Turnbull
This step is the one that could change the contents of your database. Go to your new redmine directory, then migrate your database:
81 44 James Turnbull
82 44 James Turnbull
<pre>
83 44 James Turnbull
rake db:migrate RAILS_ENV=production 
84 44 James Turnbull
</pre>
85 44 James Turnbull
86 44 James Turnbull
If you have installed any plugins, you should also run their database migrations. If you are upgrading from Redmine 0.8.x as part of this migration, you need to upgrade the plugin migrations first:
87 44 James Turnbull
88 44 James Turnbull
<pre>
89 44 James Turnbull
rake db:migrate:upgrade_plugin_migrations RAILS_ENV=production 
90 44 James Turnbull
</pre>
91 44 James Turnbull
92 44 James Turnbull
<pre>
93 44 James Turnbull
rake db:migrate_plugins RAILS_ENV=production 
94 44 James Turnbull
</pre>
95 44 James Turnbull
96 44 James Turnbull
h2. Step 5 - Clean up
97 44 James Turnbull
98 44 James Turnbull
1. You should clear the cache and the existing sessions:
99 44 James Turnbull
<pre>
100 44 James Turnbull
rake tmp:cache:clear
101 44 James Turnbull
rake tmp:sessions:clear
102 44 James Turnbull
</pre>
103 44 James Turnbull
104 44 James Turnbull
2. Restart the application server (e.g. mongrel, thin, passenger)
105 44 James Turnbull
106 44 James Turnbull
3. Finally go to _"Admin -> Roles & permissions"_ to check/set permissions for the new features, if any.
107 44 James Turnbull
108 44 James Turnbull
h2. Common issues
109 44 James Turnbull
110 44 James Turnbull
h3. Errors with repository management
111 44 James Turnbull
112 44 James Turnbull
There were several new features added to the reposman.rb file, make sure you have a group specified if you're having issues ( --group=groupnamehere).  Also, make sure you follow the instructions [[Repositories_access_control_with_apache_mod_dav_svn_and_mod_perl|here]] again if you only copied your Redmine.pm, and update your Apache configuration as the recommended configuration has changed.
113 44 James Turnbull
114 44 James Turnbull
h3. Generating a session_store.rb
115 44 James Turnbull
116 44 James Turnbull
An unique @session_store.rb@ file needs to be generated for Redmine for the new cookie based sessions to work.  This is required on the trunk version of Redmine at r2493 or above.  Just run the following command and Redmine will create one for you:
117 44 James Turnbull
<pre>
118 44 James Turnbull
rake config/initializers/session_store.rb
119 44 James Turnbull
</pre>
120 44 James Turnbull
121 44 James Turnbull
_Note: The code repository for Redmine does not contain the config/initializers/session_store.rb file, it is created by the above rake command.  If the above command does not work, make sure you are running Ruby 1.8.7 and have Rails 2.3.5 (see Error about the Rails version below)._ 
122 44 James Turnbull
123 44 James Turnbull
h3. Errors about a missing session_store.rb
124 44 James Turnbull
125 44 James Turnbull
If you see any errors about a missing @session_store.rb@ file, run the command above to create a new one.
126 44 James Turnbull
127 44 James Turnbull
h3. Error about the Rails version
128 44 James Turnbull
129 50 Etienne Massip
Remember to install the Ruby on Rails gem version required by the new Redmine version (1.2.x uses Rails 2.3.11, 1.3.x uses 2.3.14 etc.).
130 50 Etienne Massip
131 50 Etienne Massip
You might need to upgrade your Ruby on Rails gem, e.g.:
132 44 James Turnbull
<pre>
133 49 Etienne Massip
gem install rails -v=2.3.14
134 44 James Turnbull
</pre>
135 44 James Turnbull
136 44 James Turnbull
h3. Error about member_roles
137 44 James Turnbull
138 44 James Turnbull
If you have had a failed upgrade/migration in the past then you may have a member_roles and/or group_users table already created.  The db migration noted above will fail.  Simply rename the tables by logging into MySQL command line and executing the rename table command:
139 44 James Turnbull
140 44 James Turnbull
@mysql> rename table member_roles to member_roles_saved
141 44 James Turnbull
mysql> rename table groups_users to groups_users_saved
142 44 James Turnbull
@
143 44 James Turnbull
144 44 James Turnbull
145 44 James Turnbull
h3. Error about "undefined method `add_frozen_gem_path'"
146 44 James Turnbull
147 44 James Turnbull
If you see this error, check if the directory @vendor/rails@ exists and remove or rename it if it does, it might have an old RoR version.
148 44 James Turnbull
149 44 James Turnbull
h3. Related Resources 
150 44 James Turnbull
151 44 James Turnbull
These resources may help you with your Redmine upgrade:
152 44 James Turnbull
153 45 Jean-Philippe Lang
* "mod_fcgid for Apache2":http://httpd.apache.org/mod_fcgid/ helped us get Rails running on Apache 2
154 44 James Turnbull
* "Running Redmine on Apache":http://www.redmine.org/wiki/redmine/HowTo_configure_Apache_to_run_Redmine
155 44 James Turnbull
* "Notes about our 0.8.6 to 0.9.3 upgrade issues and how to resolve them":http://www.cybersprocket.com/2010/project-management/upgrading-redmine-from-8-6-to-9-3/ --cybersprocket (2010-04-25)
156 44 James Turnbull
* "Notes about our 0.9.6 to 1.0(RC) upgrade process":http://www.cybersprocket.com/2010/tips-tricks/upgrading-redmine-from-0-9-6-to-1-0-0/ --cybersprocket (2010-08-14)