Migrating Redmine can seem complex, but with careful planning, you can minimize downtime and ensure all essential components are securely transferred. This guide covers the migration process, from preparing your source and destination servers to transferring data and verifying the new Redmine instance.
1. Prepare Your Destination Server
First, set up a compatible environment on the new server to ensure Redmine functions smoothly after migration.
1. Install Redmine: Set up Redmine on your destination server following the same version as your source installation. Make sure that all dependencies, such as Ruby, Rails, and the required database (MySQL, PostgreSQL, etc.), are installed and configured correctly.
2. Install Plugins: If your Redmine instance uses plugins, install the same plugins on the new server to avoid compatibility issues. It’s best to install plugins of the same versions as on the source server.
3. Match Ruby and Rails Versions: Ensure the Ruby and Rails versions match the original server’s versions. This will reduce the risk of configuration issues during migration.
4. Set Up Database: Create a new database on the destination server with the same name and character set as your existing Redmine database. The database user permissions should also match.
2. Back Up Data on the Source Server
To safely transfer data, you need to back up the Redmine database, configuration files, and any uploaded files.
1. Back Up the Database:
• For MySQL/MariaDB:
mysqldump -u root -p redmine_database > redmine_db_backup.sql
• For PostgreSQL:
pg_dump redmine_database > redmine_db_backup.sql
This creates a .sql file that you’ll import into the destination server’s database.
2. Back Up Files and Attachments:
• Copy the files directory, which stores uploaded files and attachments.
tar -czvf redmine_files_backup.tar.gz /path/to/redmine/files
3. Back Up Configuration Files:
• Backup essential configuration files, especially configuration.yml and database.yml, located in /config.
• If you have customized themes or plugins, back up the plugins and public/themes directories as well.
3. Transfer Data to the New Server
Now, copy your backed-up data from the source server to the destination server.
1. Copy the Database Backup:
scp redmine_db_backup.sql user@destination_server:/path/to/backup/
2. Copy the Files Directory:
scp redmine_files_backup.tar.gz user@destination_server:/path/to/backup/
3. Copy Configuration Files:
Repeat this process for configuration files and any customized themes or plugins if necessary.
4. Restore Data on the Destination Server
1. Restore the Database:
• For MySQL/MariaDB:
mysql -u root -p redmine_database < redmine_db_backup.sql
• For PostgreSQL:
psql redmine_database < redmine_db_backup.sql
2. Restore Files and Attachments:
• Extract the files directory:
tar -xzvf redmine_files_backup.tar.gz -C /path/to/redmine/
3. Replace Configuration Files:
Copy configuration.yml, database.yml, and any other customized configuration files to /config in the new Redmine directory, ensuring they’re placed in the same structure as on the original server.
5. Finalize and Test the Migration
1. Run Database Migrations:
If you’ve installed or updated plugins, run database migrations on the destination server:
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
2. Clear the Cache and Sessions:
Clear the cache to prevent any inconsistencies:
bundle exec rake tmp:cache:clear tmp:sessions:clear RAILS_ENV=production
3. Restart Redmine:
Restart your Redmine instance on the new server to apply all changes:
sudo systemctl restart redmine
4. Test Your New Redmine Instance:
• Login and navigate through Redmine to check that all settings, custom fields, and projects are in place.
• Verify attachments and uploaded files.
• Test plugins to ensure they are functioning as expected.
• Check email notifications if Redmine is configured to send updates.
6. Update DNS and Redirects (If Applicable)
If the migration changes your Redmine instance’s IP address or domain, update your DNS records to point to the new server. You may also want to set up redirects if users are accustomed to a specific URL.