Upgrading Bare Metal from v3 to v4 - wiso-forschungslabor/hroot-documentation GitHub Wiki
This guide details the complete procedure for upgrading an existing bare-metal (non-Docker) hroot v3.x installation directly on your Linux server to hroot v4.0+, retaining native hosting with Ruby, MySQL, and Phusion Passenger or Puma.
| Component | Legacy hroot (v3.x) | Modern hroot (v4.0+) |
|---|---|---|
| Configuration | Hardcoded in config/environments/production.rb and database.yml
|
Centralized .env file (loaded via dotenv-rails) |
| Secrets & Keys | Hardcoded in files or secrets.yml
|
Auto-generated SECRET_KEY_BASE & WebPush VAPID keys in .env
|
| Ruby Management | Legacy RVM with shell hooks and gemsets |
rbenv (lightweight, non-intrusive shims) |
| Ruby Version | Ruby 2.7 / 3.0 / 3.2 |
Ruby version specified in .ruby-version (e.g. 3.3.6) |
| Background Tasks | Basic invitation cronjob |
Expanded whenever schedule (Digests, Surveys, IMAP, Shifts) |
| Web Server Config | Pointed to RVM ruby binary | Points to rbenv shim (/home/<user>/.rbenv/shims/ruby) |
-
Export your MySQL Database:
mysqldump -u <db_user> -p --single-transaction --routines --triggers <db_name> > ~/hroot_v3_backup_$(date +%Y%m%d_%H%M).sql
-
Back Up Uploaded Files:
cp -r /path/to/hroot/public/uploads ~/hroot_uploads_v3_backup
Notify users and prevent incoming requests during the upgrade:
cd /path/to/hroot
RAILS_ENV=production bundle exec rake rack:turnout:down[reason="We are running maintenance operations. Please check back shortly."]If your server still uses RVM, switch to rbenv to eliminate shell overrides and binary gem compilation issues:
-
Remove RVM hooks from your shell:
Open
~/.bashrc,~/.bash_profile, and~/.profile, and remove any lines referencing.rvm:# Remove lines like: # source ~/.rvm/scripts/rvm # export PATH="$PATH:$HOME/.rvm/bin"
-
Unset RVM environment variables:
unset GEM_HOME GEM_PATH -
Install rbenv and ruby-build:
git clone https://github.com/rbenv/rbenv.git ~/.rbenv git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(rbenv init - bash)"' >> ~/.bashrc source ~/.bashrc
-
Install the Ruby version required by hroot v4:
cd /path/to/hroot rbenv install $(cat .ruby-version) rbenv local $(cat .ruby-version) gem install bundler
(For complete details, see Ruby and rbenv).
Fetch the latest code and checkout the target release:
cd /path/to/hroot
git fetch origin
git checkout master # or checkout a specific release tag, e.g. git checkout v4.0.0From hroot 4.0 on, all laboratory and server settings are read from .env instead of hardcoded Ruby files.
-
Initialize
.envand generate cryptographic keys:./bin/init-env
This creates
.envfrom.env.exampleand automatically generates secure keys forSECRET_KEY_BASE, WebPushVAPIDkeypairs, and internal credentials. -
Transfer your laboratory settings into
.env:
Open your oldconfig/environments/production.rb,config/secrets.yml, andconfig/database.yml, and copy your settings into.env:
| Old Location & Setting | New Variable in .env
|
Example |
|---|---|---|
production.rb: default_url_options[:host]
|
APP_DOMAIN |
APP_DOMAIN=hroot.example.org |
production.rb: default_url_options[:protocol]
|
APP_PROTOCOL |
APP_PROTOCOL=https |
production.rb: HROOT_SETTINGS[:contact_email]
|
CONTACT_EMAIL |
[email protected] |
production.rb: HROOT_SETTINGS[:sender_email]
|
SENDER_EMAIL |
[email protected] |
production.rb: HROOT_SETTINGS[:log_email]
|
LOG_EMAIL |
[email protected] |
production.rb: smtp_settings[:address]
|
SMTP_ADDRESS |
SMTP_ADDRESS=smtp.example.org |
production.rb: smtp_settings[:port]
|
SMTP_PORT |
SMTP_PORT=587 |
production.rb: smtp_settings[:user_name]
|
SMTP_USER_NAME |
SMTP_USER_NAME=mailer-user |
production.rb: smtp_settings[:password]
|
SMTP_PASSWORD |
SMTP_PASSWORD=secret-smtp-pass |
database.yml: production.host
|
DATABASE_HOST |
DATABASE_HOST=localhost |
database.yml: production.username
|
DATABASE_USERNAME |
DATABASE_USERNAME=hroot |
database.yml: production.password
|
DATABASE_PASSWORD |
DATABASE_PASSWORD=secret-db-pass |
database.yml: production.database
|
DATABASE_NAME |
DATABASE_NAME=hroot_production |
(See Environment Configuration for the full list of optional features like Shibboleth, Kimai, SMS gateways, and Bot Protection).
-
Install Ruby Gems:
bundle config set --local deployment 'true' bundle config set --local without 'development test' bundle install
-
Run Database Schema Migrations: You can apply migrations using either the command line or the In-Browser Setup Assistant:
-
Option A (CLI):
RAILS_ENV=production bin/rails db:migrate
-
Option B (In-Browser Setup Assistant):
Open
https://<APP_DOMAIN>/setupwith yourHROOT_SETUP_TOKEN, select „Upgrade from v3.x to v4.0“, verify connected database and administrators, and click „Run v4 Upgrade & Complete Setup“. (This applies all new schema additions in v4 like survey completion links, push notifications, staff roles, updated indexes, and dynamic settings while preserving all research data).
-
Option A (CLI):
Clear stale cached assets and compile the modern asset pipeline:
RAILS_ENV=production bin/rails assets:clobber
RAILS_ENV=production bin/rails assets:precompilehroot 4.0 introduces automated invitation digest processing, survey timeout monitors, and IMAP reply processing. Register the updated schedule in your system crontab:
RAILS_ENV=production bundle exec whenever --update-crontabTo inspect the registered cron jobs, run crontab -l.
If you upgraded Ruby or switched to rbenv, update your web server's Ruby path:
Edit /etc/apache2/sites-available/hroot.conf (or /etc/apache2/mods-available/passenger.conf):
# Ensure Passenger uses the rbenv shim:
PassengerRuby /home/hroot/.rbenv/shims/rubyRestart Apache:
sudo systemctl restart apache2Edit /etc/nginx/sites-available/hroot:
passenger_ruby /home/hroot/.rbenv/shims/ruby;Restart NGINX:
sudo systemctl restart nginxEdit /etc/systemd/system/hroot.service to point ExecStart to /home/hroot/.rbenv/shims/bundle exec puma ...:
sudo systemctl daemon-reload
sudo systemctl restart hroottouch tmp/restart.txt-
Disable maintenance mode:
RAILS_ENV=production bundle exec rake rack:turnout:up -
Run System Diagnostic Checks:
- Open
https://<APP_DOMAIN>/admin/options/checkin your browser. - Verify that database connectivity, mailer delivery, and background tasks are healthy.
- Send a test email from the Admin options page.
- Open