1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

F OpenNebula/one#5178: Add onedb upgrade (#606)

Signed-off-by: Petr Ospalý <pospaly@opennebula.io>
This commit is contained in:
Petr Ospalý 2021-01-11 10:06:14 +01:00 committed by GitHub
parent ba3bf2b183
commit 10fa7ca4ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 0 deletions

View File

@ -147,3 +147,15 @@ wait_for_file()
return 1
)
is_true()
(
_value=$(echo "$1" | tr '[:upper:]' '[:lower:]')
case "$_value" in
yes|true|1)
return 0
;;
esac
return 1
)

View File

@ -53,6 +53,43 @@ fi
msg "Database is running - continue"
# upgrade database if needed
msg "Check database version"
# to avoid script termination on non-zero code from command - we wrap the
# command in if-else construct
if onedb version -v ; then
_status=0
else
_status=$?
fi
case "$_status" in
0)
msg "Database is up-to-date - continue"
;;
1)
msg "Database was not created yet - continue"
;;
2)
msg "Upgrading database..."
if is_true "${ONED_DB_BACKUP_ENABLED:-yes}" ; then
_mysqldump="/var/lib/one/backups/db/opennebula-$(date +%Y-%m-%d-%s).sql"
onedb upgrade --backup "${_mysqldump}"
else
onedb upgrade --no-backup
fi
;;
3)
err "Database is newer than this opennebula version - ABORT"
exit 1
;;
*)
err "Returned unknown error by onedb - ABORT"
exit 1
;;
esac
# TODO: remove this once oned fix this:
# https://github.com/OpenNebula/one/issues/5189
#