Feature #5138
closed
Automatically upgrade the database in a post-install script and create a backup
Added by osmith about 3 years ago.
Updated almost 3 years ago.
Description
As discussed in the team meeting last week, for some users it makes sense to automatically upgrade the database (because osmo-hlr will refuse to start if the db was not upgraded but a new version is required) and for others it does not (just want to try out a osmo-hlr version, but be able to go back to the previous version).
The solution we arrived at:
- post-install script, which checks if the database needs to be upgraded (exit 0 otherwise)
- create a backup of the database
- upgrade the database
It was discussed to do it in a pre-install instead of post-install, but that's not possible as the migration tool is only available at post-install.
- Status changed from New to In Progress
- % Done changed from 0 to 60
Output examples¶
Nothing to do¶
Setting up osmo-hlr (1.3.0) ...
osmo-hlr-post-upgrade: nothing to do (no existing database)
Setting up osmo-hlr (1.3.0) ...
osmo-hlr-post-upgrade: nothing to do (database version is up to date)
Upgrade while osmo-hlr is not running¶
Setting up osmo-hlr (1.3.0) ...
osmo-hlr-post-upgrade: database upgrade is required
osmo-hlr-post-upgrade: osmo-hlr service is not running
osmo-hlr-post-upgrade: creating backup: /var/lib/osmocom/hlr.db.20210531143250.bak
osmo-hlr-post-upgrade: performing database upgrade
<0001> db.c:531 using database: /var/lib/osmocom/hlr.db
<0001> db.c:609 Database '/var/lib/osmocom/hlr.db' has HLR DB schema version 4
<0001> db.c:620 Database '/var/lib/osmocom/hlr.db' has been upgraded to HLR DB schema version 5
osmo-hlr-post-upgrade: database upgrade successful
Upgrade while osmo-hlr is running¶
Setting up osmo-hlr (1.3.0) ...
osmo-hlr-post-upgrade: database upgrade is required
osmo-hlr-post-upgrade: stopping osmo-hlr service
osmo-hlr-post-upgrade: creating backup: /var/lib/osmocom/hlr.db.20210531142649.bak
osmo-hlr-post-upgrade: performing database upgrade
<0001> db.c:531 using database: /var/lib/osmocom/hlr.db
<0001> db.c:609 Database '/var/lib/osmocom/hlr.db' has HLR DB schema version 4
<0001> db.c:620 Database '/var/lib/osmocom/hlr.db' has been upgraded to HLR DB schema version 5
osmo-hlr-post-upgrade: database upgrade successful
osmo-hlr-post-upgrade: starting osmo-hlr service
The above output examples are from debian. How it looks like in centos8:
Upgrading : libosmo-mslookup0-1.3.0.4.5200.202105311447-3.1.x86_64 8/18
Running scriptlet: libosmo-mslookup0-1.3.0.4.5200.202105311447-3.1.x86_64 8/18
Upgrading : osmo-hlr-1.3.0.4.5200.202105311447-3.1.x86_64 9/18
Running scriptlet: osmo-hlr-1.3.0.4.5200.202105311447-3.1.x86_64 9/18
osmo-hlr-post-upgrade: nothing to do (no existing database)
Cleanup : osmo-hlr-1.3.0.3.ca8e.202106010026-1.1.x86_64 10/18
Cleanup : libosmoctrl0-1.5.1.125.208c5.202106010026-1.1.x86_64 11/18
Running scriptlet: libosmoctrl0-1.5.1.125.208c5.202106010026-1.1.x86_64 11/18
Cleanup : libosmo-mslookup0-1.3.0.3.ca8e.202106010026-1.1.x86_64 12/18
Running scriptlet: libosmo-mslookup0-1.3.0.3.ca8e.202106010026-1.1.x86_64 12/18
With failure:
Running transaction
Preparing : 1/1
Running scriptlet: osmo-hlr-1.3.0.4.5200.202105311447-3.1.x86_64 1/1
Upgrading : osmo-hlr-1.3.0.4.5200.202105311447-3.1.x86_64 1/2
Running scriptlet: osmo-hlr-1.3.0.4.5200.202105311447-3.1.x86_64 1/2
osmo-hlr-post-upgrade: database upgrade is required
osmo-hlr-post-upgrade: osmo-hlr service is not running
osmo-hlr-post-upgrade: creating backup: /var/lib/osmocom/hlr.db.20210601071723.bak
osmo-hlr-post-upgrade: performing database upgrade
<0001> db.c:531 using database: /var/lib/osmocom/hlr.db
<0001> db.c:100 (26) file is not a database in "PRAGMA journal_mode=WAL; PRAGMA synchonous = NORMAL;"
<0001> db.c:587 Unable to set Write-Ahead Logging: file is not a database
<0001> db.c:100 (26) statement aborts at 1: [PRAGMA user_version] file is not a database
<0001> db.c:514 SQL statement 'PRAGMA user_version' failed: 26
<0001> db.c:593 Unable to read user version number from database '/var/lib/osmocom/hlr.db'
<0000> hlr_db_tool.c:509 Error opening database
warning: %post(osmo-hlr-1.3.0.4.5200.202105311447-3.1.x86_64) scriptlet failed, exit status 1
Error in POSTIN scriptlet in rpm package osmo-hlr
Cleanup : osmo-hlr-1.3.0.4.5200.202105311447-2.1.x86_64 2/2
Running scriptlet: osmo-hlr-1.3.0.4.5200.202105311447-2.1.x86_64 2/2
Verifying : osmo-hlr-1.3.0.4.5200.202105311447-3.1.x86_64 1/2
Verifying : osmo-hlr-1.3.0.4.5200.202105311447-2.1.x86_64 2/2
Upgraded:
osmo-hlr-1.3.0.4.5200.202105311447-3.1.x86_64
- % Done changed from 60 to 90
- Status changed from In Progress to Resolved
- % Done changed from 90 to 100
Also available in: Atom
PDF