Upgrading from v2.3.2 to 5.0.2 (with docker) - how to restore databases?
Added by Zs Vizi about 2 years ago
Hi everybody!
I'm currently upgrading our old Redmine server - well, actually moving it to a completely new machine. The old one ran v2.3.2 on Ubuntu, the new one is v5.0.2 but with the docker version, see https://hub.docker.com/_/redmine.
I'm using docker-compose and therefore a docker-compose.yml file for settings. I put the "files" folder and the config files as volumes, as well as the data folder of the mysql instance. It starts up well, I could also copy the files folder from the old server, but here comes the tricky part: restoring the databases (tickets, issues, users, everything).
According to this (https://www.redmine.org/projects/redmine/wiki/RedmineBackupRestore) documentation, I exported the database from the old redmine, now I have a nice 10kB .sql file (to be honest was expecting a bit larger file, so I guess I should backup data with different commands and/or options). But I don't know if I can simply just "import" it into the new version or the database structure has changed. Also, since I'm running the whole redmine with docker, I cannot simply use mysql commands, since it is running inside the docker instance. I tried to import my little 10kB sql file with the recommended mysql command as seen in its docker doc (https://hub.docker.com/_/mysql), but it doesn't really seem to work. It's either the command or the database, I don' know...
If anyone could help me, I'd really appreciate it!
Edit: sorry, I forgot to add some info about the systems.
Old system:
OS: Ubuntu 14.04 /if I remember correctly/
Redmine version: 2.3.2.stable
Ruby version: 1.9.3-p484 (2013-11-22) [x86_64-linux]
Rails version: 3.2.13
Environment: production
Database adapter: Mysql2
MySQL version: mysql Ver 14.14 Distrib 5.5.49, for debian-linux-gnu (x86_64) using readline 6.3
New system:
OS: Debian 11 /though it doesn't really matter/
Redmine version: 5.0.2.stable
Ruby version: 3.1.2-p20 (2022-04-12) [x86_64-linux]
Rails version: 6.1.6
Environment: production
Database adapter: Mysql2
MySQL version:: mysql Ver 14.14 Distrib 5.7.39, for Linux (x86_64) using EditLine wrapper
Replies (1)
RE: Upgrading from v2.3.2 to 5.0.2 (with docker) - how to restore databases? - Added by Zs Vizi about 2 years ago
After about a week I figured out the solution, here's what I did, in case anyone in the future trips into this thread.
First I exported the data from the old server, by:/usr/bin/mysqldump -u "redmine" -p redmine -h localhost > /usr/local/share/redmine-2.3.2/redmine_backup.sql
Here comes the tricky part: the mysql and redmine started via docker already made some data, but I couldn't simply import the data, since the new database used the new versions, but the old didn't, it needed to be altered. So, I deleted the contents of the database to start from scratch:
docker exec -it redmine_mysql sh
mysql -uroot -p"$MYSQL_ROOT_PASSWORD"
DROP DATABASE redmine;
CREATE DATABASE redmine;
exit
exit
Then I imported the data:docker exec -i redmine_mysql sh -c 'exec mysql -D redmine -uroot -p"$MYSQL_ROOT_PASSWORD"' < /usr/local/share/redmine-5.0.2/redmine_backup.sql
After this all I had to do was to renew the database contents:docker exec -i redmine_main sh
bundle exec rake db:migrate RAILS_ENV=production
exit