Upgrade "Kiwi" R3 2021 hf1 to "Lotus" R1 2022 hf2
Introducing thoughts
We have three systems to distinct:
Current System
This is the old system we want to migrate
Migration System
This is the system where the migration itself will be done. Preferably these are cloned VMs so that whenever we run to failed or inconsitent state we easliy can start over.
Target System
This will be the new production machine. URLs can move by DNS-Switching or proxy configuration
Short steps are:
- Dump Folio Database from Current System
- Load this dump into a clean Migration System which only have back end modules installed
- Prepare Folio data and prequisites as mentioned in the release notes
- Migrate to new release
- Dump Folio Database from Migration System
- Load this dump in a clean Target System which only back end modules installed
- Now install/publish front end modules on Target System
Current System
Save Database
# switch to database user
su postgres
# Dump folio database
pg_dump folio > folio-dump.psql
#Now copy dump to Migration System
Migration System
Restore dump of instance to be migrated into fresh R1 instance without front end modules :
#stop okapi
systemctl stop okapi
# clear folio database
su -c psql postgres postgres
DROP DATABASE folio;
CREATE DATABASE folio WITH OWNER folio;
# create some roles before restoring dump (are missing for some reason)
CREATE ROLE diku_mod_password_validator;
ALTER ROLE diku_mod_password_validator WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN NOREPLICATION NOBYPASSRLS PASSWORD 'xxx';
ALTER ROLE diku_mod_password_validator SET search_path TO '$user';
GRANT diku_mod_password_validator TO folio GRANTED BY folio;
CREATE ROLE diku_mod_tags;
ALTER ROLE diku_mod_tags WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN NOREPLICATION NOBYPASSRLS PASSWORD 'xxx';
ALTER ROLE diku_mod_tags SET search_path TO '$user';
GRANT diku_mod_tags TO folio GRANTED BY folio;
CREATE ROLE diku_mod_notes;
ALTER ROLE diku_mod_notes WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN NOREPLICATION NOBYPASSRLS PASSWORD 'xxx';
ALTER ROLE diku_mod_notes SET search_path TO '$user';
GRANT diku_mod_notes TO folio GRANTED BY folio;
\q
# restore folio dump
su postgres
psql -d folio < folio-dump.psql
exit
#start okapi
systemctl start okapi
Preparation for Lotus
Before upgrade:
Change all duplicate externalSystemIds.
Find them with this SQL:SET search_path TO diku_mod_users;
SELECT left(lower(f_unaccent( jsonb->>'externalSystemId')), 600)
FROM users
GROUP BY 1
HAVING count(*) > 1;
## For ub20 it seems there are some reference data that stops the upgrade so lets truncate this tables:
SET search_path TO diku_mod_data_export;
truncate mapping_profiles CASCADE;
Before fetching new module descriptors upgrade Okapi to a version >= 4.13.2 (or >= 4.12.2).
apt-get update
apt-get -y --allow-change-held-packages install okapi=4.14.2-1
Upgrade to R3 2021 hf3
cd /opt
## move old platform-complete
mv platform-complete platform-complete-r3hf1
## get platform--complete in R3 2021 hotfix3
git clone https://github.com/folio-org/platform-complete
cd platform-complete
git checkout R3-2021-hotfix-3
## update module descriptors
curl -w '\n' -D - -X POST -H "Content-type: application/json" -d @registry.json http://localhost:9130/_/proxy/pull/modules
## Backend upgrade (Test)
curl -w '\n' -D - -X POST -H "$TOKEN" -H "X-Okapi-Tenant: $TENANT" -H "Content-type: application/json" -d @/opt/platform-complete/okapi-install.json http://localhost:9130/_/proxy/tenants/diku/install?simulate=true\&preRelease=false
## backend upgrade
curl -w '\n' -D - -X POST -H "$TOKEN" -H "X-Okapi-Tenant: $TENANT" -H "Content-type: application/json" -d @/opt/platform-complete/okapi-install.json http://localhost:9130/_/proxy/tenants/diku/install?deploy=true\&preRelease=false\&tenantParameters=loadReference%3Dtrue
Upgrade to R1 2022 hf2
mv platform-complete platform-complete-r3hf3
## get platform--complete in R1 2022
git clone https://github.com/folio-org/platform-complete
cd platform-complete
git checkout R1-2022-hotfix-2
## Backend upgrade (Test)
curl -w '\n' -D - -X POST -H "$TOKEN" -H "X-Okapi-Tenant: $TENANT" -H "Content-type: application/json" -d @/opt/platform-complete/okapi-install.json http://localhost:9130/_/proxy/tenants/diku/install?simulate=true\&preRelease=false
## backend upgrade
curl -w '\n' -D - -X POST -H "$TOKEN" -H "X-Okapi-Tenant: $TENANT" -H "Content-type: application/json" -d @/opt/platform-complete/okapi-install.json http://localhost:9130/_/proxy/tenants/diku/install?deploy=true\&preRelease=false\&tenantParameters=loadReference%3Dtrue
# dump migrated folio database
su postgres
pg_dump folio > /tmp/folio-lotus-hf2-migrated.psql
# now copy dump to Target System
Target System
Set up Target System similar to Productive System but make sure you don't have front end modules installed/published in Okapi. This will be the last step.
Restore dump of instance to be migrated into fresh Lotus HF2 instance without front end modules :
#stop okapi
systemctl stop okapi
# clear folio database
su -c psql postgres postgres
DROP DATABASE folio;
CREATE DATABASE folio WITH OWNER folio;
# create some roles before restoring dump (are missing for some reason)
CREATE ROLE diku_mod_password_validator;
ALTER ROLE diku_mod_password_validator WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN NOREPLICATION NOBYPASSRLS PASSWORD 'xxx';
ALTER ROLE diku_mod_password_validator SET search_path TO '$user';
GRANT diku_mod_password_validator TO folio GRANTED BY folio;
CREATE ROLE diku_mod_tags;
ALTER ROLE diku_mod_tags WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN NOREPLICATION NOBYPASSRLS PASSWORD 'xxx';
ALTER ROLE diku_mod_tags SET search_path TO '$user';
GRANT diku_mod_tags TO folio GRANTED BY folio;
CREATE ROLE diku_mod_notes;
ALTER ROLE diku_mod_notes WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN NOREPLICATION NOBYPASSRLS PASSWORD 'xxxc';
ALTER ROLE diku_mod_notes SET search_path TO '$user';
GRANT diku_mod_notes TO folio GRANTED BY folio;
\q
# restore folio dump
su postgres
psql -d folio < folio-lotus-hf2-migrated.psql
exit
#start okapi
systemctl start okapi
Now you can install/publish the front end modules which will also install missing permissions
## front end install (Test)
curl -w '\n' -D - -X POST -H "$TOKEN" -H "X-Okapi-Tenant: $TENANT" -H "Content-type: application/json" -d @/opt/platform-complete/stripes-install.json http://localhost:9130/_/proxy/tenants/diku/install?simulate=true\&preRelease=false
## front end install (Test)
curl -w '\n' -D - -X POST -H "$TOKEN" -H "X-Okapi-Tenant: $TENANT" -H "Content-type: application/json" -d @/opt/platform-complete/stripes-install.json http://localhost:9130/_/proxy/tenants/diku/install?preRelease=false