因為不好升級的 Gitlab 都升級成功,就想順便把 Redmine 也升級,畢竟是兩年前的版本。
- 在舊機 啟動ssh
sudo mv /etc/init/ssh.conf.back
/etc/init/ssh.conf
sudo service ssh start - 匯出 MySQL database
先找出密碼
grep password /opt/bitnami/apps/redmine/htdocs/config/database.yml
mkdir /opt/backup
/opt/bitnami/mysql/bin/mysqldump bitnami_redmine -u bitnami -p找出的密碼 > /opt/backup/bitnami_redmine.sql - 備份已上傳檔案
cd /opt/bitnami/apps/redmine/htdocs
sudo tar czf /opt/backup/files.tgz files - 換到新機 同樣 啟動ssh
sudo mv /etc/init/ssh.conf.back
/etc/init/ssh.conf
sudo service ssh start - 停止服務
sudo sh /opt/bitnami/ctlscript.sh
啟動MySQL
sudo sh /opt/bitnami/ctlscript.sh mysql - 匯入MySQL database
先找出密碼
grep password /opt/bitnami/apps/redmine/htdocs/config/database.yml
mkdir /opt/backup
scp root@舊機:/opt/backup/bitnami_redmine.sql /opt/backup
這次新版Bitnami Redmine 的 Mysql root密碼是 bitnami 而不是 bitnami1
/opt/bitnami/mysql/bin/mysql -u root -p
進入MySQL shell後輸入
drop database bitnami_redmine;
create database bitnami_redmine;
grant all privileges on bitnami_redmine.* to 'bitnami'@'localhost' identified by 'bitnami密碼';
grant all privileges on bitnami_redmine.* to 'redmine'@'localhost' identified by 'bitnami密碼';
flush privileges;
\q - 真正從備份檔匯入
/opt/bitnami/mysql/bin/mysql -u bitnami -p找出的密碼 bitnami_redmine < /opt/backup/bitnami_redmine.sql - 接下來要做Database Migration
cd /opt/bitnami/apps/redmine/htdocs
sudo ruby bin/rake db:migrate RAILS_ENV=production - 匯入檔案
scp root@舊機:/opt/backup/files.tgz /opt/backup
cd /opt/bitnami/apps/redmine/htdocs
sudo tar xzf /opt/backup/files.tgz
必要時得改權限 chmod -R g+w /opt/bitnami/apps/redmine/htdocs/files - 最後重啟服務
sudo sh /opt/bitnami/ctlscript.sh restart
確認修改成功後就可以關閉舊機,修改 Hostname 與IP,取代原來的Redmine VM。
留言