CentOS 7.x update lightsail redmine instance
From Notes_Wiki
<yambe:breadcrumb self="update lightsail redmine instance">CentOS 7.x redmine|redmine</yambe:breadcrumb> <yambe:breadcrumb self="update lightsail redmine instance">CentOS 7.x Setup lightsail instances|Setup lightsail instances</yambe:breadcrumb>
CentOS 7.x update lightsail redmine instance
Steps for updating redmine instance by creating a new instance and terminating old one are: Note that it is also possible to update redmine within same instance using similar steps
For updating redmine use:
- Create a new machine for newer version of redmine
- Install required packages
- yum -y install vim epel-release wget
- yum -y install perl-Data-Dumper byobu
- Copy self admin station public key as authorized for root user of new instance
- Download new version of redmine from https://bitnami.com/stack/redmine/installer
- 'chmod +x' downloaded file.
- If required add appropriate swap by referring CentOS 7.x adding swap space using file
- Install new redmine with following values
- Language
- English (Default)
- Subversion
- Yes (Default)
- PhpMyAdmin
- Yes (Default)
- Git
- Yes (Default)
- Folder
- /opt/redmine-<version> (Default)
- Username
- admin
- Email address
- saurabh [at] sbarjatiya.com
- Login user
- admin
- Password
- Something very simple (It is overwritten by old redmine admin password during database restore anyway)
- Data language
- English (Default)
- Email support
- : Y (Custom, saurabh [at] sbarjatiya.com, secret, mail.sbarjatiya.com, 587, TLS)
- Continue redmine bitnami installation
- Login into older redmine server and go to '/opt/redmine-<version>'. Execute './ctlscript.sh stop apache'. For extra safety you can stop access to ports 80, 443 of old redmine via firewall.
- If mysql is not running start it using './ctlscript.sh start mysql'
- On old server go to location '/opt/redmine-<version>/apps/redmine/htdocs/config'. Open database.yml and note production database details.
- Take MySQL database backup of old redmine using
- cd /root
- /opt/redmine-<version>/mysql/bin/mysqldump -u bitnami -p<old-server-password> bitnami_redmine > bitnami_redmine.sql
- In /etc/hosts of old server add entry for new-<fqdn> pointing to new servers private IP
- If required generate root ssh-key pair on old server. Copy old server root public key on new server as authorized
- Copy MySQL database dump to new server /root
- On new server go to location '/opt/redmine-<version>/apps/redmine/htdocs/config'. Open database.yml and note production database details.
- Restore MySQL database on new redmine using
- cd /root
- /opt/redmine-<version>/mysql/bin/mysql -u bitnami -p<new-server-password> bitnami_redmine < bitnami_redmine.sql
- Copy files from '/opt/redmine-<version>/apps/redmine/htdocs/files' of old server to new server
- rsync -a /opt/redmine-<old-version>/apps/redmine/htdocs/files/ root@new-<fqdn>:/opt/redmine-<new-version>/apps/redmine/htdocs/files/
- Same for /opt/redmine-<version>/apps/redmine/htdocs/plugins after validating that plugins are compatible with new version
- rsync -a /opt/redmine-<old-version>/apps/redmine/htdocs/plugins/ root@new-<fqdn>:/opt/redmine-<new-version>/apps/redmine/htdocs/plugins/
- On new server migrate database to new version using:
- cd /opt/redmine-<version>
- ./use_redmine
- cd /opt/redmine-<version>/apps/redmine/htdocs
- sudo /opt/redmine-<version>/ruby/bin/ruby bin/rake db:migrate RAILS_ENV=production
- Optionally import plugins if copied and compatible using:
- sudo /opt/redmine-<version>/ruby/bin/ruby bin/rake redmine:plugins RAILS_ENV=production
- Clear cache
- sudo /opt/redmine-<version>/ruby/bin/ruby bin/rake tmp:clear
- Restart redmine
- /opt/redmine-<version>/ctrlscript.sh restart
- Copy '/opt/redmine-<version>/apache2/htdocs/index.html to new server at similar location
- Allow access to port 80 and 443 of new redmine server
- Access new server and test. Note that admin password of old-server would work and not the password typed during installation
- Search for issues with any file. Try to access files uploaded on any issue and check that uploaded files are accessible
- Setup fail2ban using CentOS 7.x fail2ban including firewalld using CentOS 7.x Basic firewalld configuration
- Set correct time zone CentOS 7.x Change system timezone
- Configure system to store history date time using Storing date / time along with commands in history
- Stop old instance or server
- Associate public IP or old instance with new instance or Update DNS to point to static IP of new instance
- Generate SSL certificate using:
- /opt/redmine-4.1.1-4/bncert-tool #Update tool if prompted and re-run
- Inputs for update are: Domain list - <fqdn>, No www.<fqdn> domain, Enable HTTPS redirection - Yes, Agree to multiple changes, Email address - saurabh [at] sbarjatiya.com, Agree to Let's encrypt agreement
- Refer - https://docs.bitnami.com/general/how-to/understand-bncert/
- Access site using https://<fqdn> and validate
- Configure backups to happen from new server
- Install packages
- yum -y install bzip2
- Edit /etc/rsnapshot.conf private IP in backup server
- Copy backup server SSH keys as authorized on new redmine server
- ssh from backup server to new redmine server and test
- Create /opt/take-database-backup.sh on redmine server with following contents
- /opt/redmine-<ver>/mysql/bin/mysqldump -u bitnami -p<password> bitnami_redmine | bzip2 > /opt/bitnami_redmine.sql.bz2
- Validate name of script take-database-backup.sh in /etc/rsnapshot.conf of backup server
- chmod +x /opt/take-database-backup.sh
- /opt/take-database-backup.sh #Ignore some of the errors shown
- bunzip2 the dump and validate it is proper
- rsnapshot hourly #Validate
- Install packages
- Configure logwatch
- yum -y install logwatch
- Set correct hostname. Reconnect if required
- vim /etc/logwatch/conf/logwatch.conf
- MailTo = saurabh [at] sbarjatiya.com
- MailFrom = saurabh [at] sbarjatiya.com
- Edit /etc/aliases and set root: saurabh [at] sbarjatiya.com
- Edit /etc/postfix/main.cf
- myhostname = redmine.sbarjatiya.com
- mydomain = sbarjatiya.com
- myorigin = $myhostname
- inet_interfaces = all
- inet_protocols = ipv4
- relayhost = mail.sbarjatiya.com
- Ensure public IP of redmine.sbarjatiya.com is part of mynetworks on mail.sbarjatiya.com
- Run newaliases
- systemctl restart postfix
- /etc/cron.daily/0logwatch #Test
- Delete old instance
Refer:
<yambe:breadcrumb self="update lightsail redmine instance">CentOS 7.x redmine|redmine</yambe:breadcrumb> <yambe:breadcrumb self="update lightsail redmine instance">CentOS 7.x Setup lightsail instances|Setup lightsail instances</yambe:breadcrumb>