Get Kopano Database Migrations Back on Track After a MySQL Upgrade

After a MySQL or MariaDB upgrade, Kopano may refuse to start while the database migration is incomplete. The safest first response is to stop repeated restarts, preserve a consistent backup, and read the first database error in the Kopano server log. Then confirm that your exact Kopano release supports the new database version and follow that release’s schema-upgrade instructions; there is no universal SQL command that repairs every migration failure.

What usually causes the migration to fail?

A server upgrade can expose more than one problem. The Kopano package may not support the newly installed database release, the Kopano account may lack permission to apply schema changes, or the server may be attempting to migrate a database from a release path that requires an intermediate step. A failed earlier attempt can also leave the schema partly upgraded. The error message, Kopano version, database version, and last successful migration step are needed to tell these cases apart.

Kopano’s Administrator Manual says Kopano Core was tested with the MySQL or MariaDB version supplied by supported distributions. Its upgrade guidance also recommends backing up the database and configuration before an upgrade, especially when skipping minor releases. Since the published manual applies to a particular Kopano generation, check the release notes and support material for the version actually installed rather than assuming its old dependency list applies to a newer server.

1. Stop retries and make a recoverable backup

If the migration is still running, do not kill the database process or repeatedly restart Kopano. If it has stopped with an error, stop the Kopano services that can write to the database. Service names differ by distribution and installation, so use the service manager and package documentation for your host. For a systemd installation, an administrator might stop the core service with:

sudo systemctl stop kopano-server

Stop related Kopano services and pause inbound mail delivery if your maintenance procedure requires it. Copy the Kopano configuration directory and back up any attachment directory stored outside MySQL. A database dump alone does not contain filesystem attachments.

For an InnoDB database, the Kopano manual documents this dump pattern:

mysqldump -p --single-transaction --routines kopano > kopano-before-migration.sql

Replace kopano with the database name configured in server.cfg. Store the dump securely, confirm the command completed successfully, and check that the resulting file is non-empty. A dump is useful only if it can be restored; for a production system, verify the restore procedure in a staging environment before you need it.

A Linux server terminal beside a database backup symbol, representing a pre-migration Kopano database backup.
Back up the Kopano database, configuration, and external attachment storage before attempting another schema migration.

2. Capture versions and the first migration error

Record the Kopano package version and the database server version before changing packages or configuration. Depending on the distribution, package queries such as dpkg-query -W 'kopano*' or rpm -qa | grep -i kopano can show installed Kopano packages. Query the database server directly:

mysql --version
mysql -u root -p -e "SELECT VERSION();"

Next, inspect the Kopano server journal or configured log file around the failed startup. For systemd, a bounded view can help capture the initial cause:

sudo journalctl -u kopano-server -b --no-pager -n 200

Look for the first SQL statement that fails, the database error code, and any message naming a migration or schema version. Errors such as “access denied” point toward credentials or grants; “unsupported” or syntax errors may indicate a database compatibility issue; a duplicate column, table, or index can mean an earlier attempt already applied part of the change. These are clues, not a diagnosis by themselves. Save the full surrounding log and avoid posting passwords or sensitive mailbox data in a support request.

A server-monitor display with two terminal panes and green checks, representing checks of Kopano and MySQL versions.
Confirm the installed Kopano and database versions before choosing a migration procedure.

3. Check compatibility and the Kopano database account

Compare the exact Kopano release, Linux distribution, and MySQL or MariaDB version with the official release notes and package guidance. Do not treat “MySQL-compatible” as proof that an arbitrary major version is supported. If the database version is outside the documented range, the safest fix is usually a supported upgrade path: restore a pre-upgrade snapshot in an isolated environment, use a database version supported by that Kopano release, or move through documented intermediate software versions. Do not downgrade a live database package in place unless the database vendor explicitly documents that procedure.

If the log says the migration cannot alter or create an object, check which MySQL account Kopano actually uses in its configuration and whether that account can connect from the Kopano host. The Kopano manual lists schema-related privileges such as ALTER, CREATE, CREATE ROUTINE, DELETE, DROP, INDEX, INSERT, LOCK TABLES, SELECT, and UPDATE for a restricted grant. Use the database and host values from your own configuration; do not copy a sample password or broaden privileges across unrelated databases.

Test authentication without exposing a password on the command line:

mysql -u kopano -p -h localhost kopano -e "SELECT 1;"

Substitute the configured username, database name, and database host. A successful connection confirms access, but not that the account has every privilege needed by the specific schema migration.

A monitor showing highlighted terminal log rows and a key icon, representing review of migration errors and database permissions.
Use the first SQL failure to distinguish a privilege problem from a version or partially applied schema change.

4. Apply only the migration required by your release

Once the database version and permissions are appropriate, follow the official upgrade sequence for the Kopano release you are installing. Some releases apply schema changes when kopano-server starts; particular releases require a separate database-administration action. For example, Kopano’s changelog for a specific schema update says to run the documented K-1216 procedure and notes that kopano-server reports when kopano-dbadm k-1216 is still required. That command is specific to that release note; it is not a generic repair command for every migration failure.

Before rerunning an interrupted migration, determine from the log or release notes whether it is safe to run again. If the database has a partially added column or index, do not manually drop it or edit version records just to make the upgrade proceed. A hand-written SQL change can make the schema look current while leaving the actual data transformation incomplete. If the official instructions do not explain how to recover from the exact state, restore the backup to a test instance and ask Kopano support or the package maintainer with the versions, full error, and migration status.

If you suspect table-level incompatibilities after the database upgrade, MySQL documents mysqlcheck --check-upgrade as a way to invoke CHECK TABLE ... FOR UPGRADE. Run it only as a diagnostic against the Kopano database, using the appropriate account and database client for your MySQL or MariaDB distribution:

mysqlcheck -u root -p --check-upgrade kopano

This check does not apply Kopano schema migrations and does not repair every table or data issue. Follow the database vendor’s documentation for the server version in use.

A server monitor with green status indicators beside a terminal, representing a clean Kopano service restart after migration.
After applying the release-specific migration, restart Kopano and review the complete startup log for a successful schema check.

Verify the result before reopening mail service

Start kopano-server and inspect the complete startup output. The migration is successful only when the server connects to the intended database, reports no pending schema update or SQL failure, and remains active. Check the service status, then start the other Kopano services you stopped and resume queued mail according to your maintenance plan. Test a user login, mailbox listing, message read and write, and an attachment open; if you use Kopano Search, test search separately because it may have its own upgrade requirements.

If Kopano still reports a pending schema version, repeats the same SQL failure, or exits during startup, stop and return to the saved recovery point rather than marking the upgrade complete. Keep the original error, exact package versions, database flavor and version, and the last successful migration step together. These details make it possible to select the correct version-specific recovery path.

Official references

Leave a Comment

How to