Migrate DB from 2. to 3.1

I am migrating from Indico 2 to 3.1 on a new VM, Centos7, using this installation doc Instead of “indico db prepare” I have restored from a dump.

I wish to know if I have done the right steps to backup and restore the database, because I am seeing log many errors/warnings, in celery.log.

My backup command is:
runuser -l indico -c 'pg_dump indico -Fc -f /opt/indico/db-backup/20220331.dump'

Restore command and the command messages are:

(indico) [indico@indico ~]$ pg_restore -d indico -O db-backup/20220331.dump
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 5; 2615 2200 SCHEMA public postgres
pg_restore: error: could not execute query: ERROR: schema “public” already exists
Command was: CREATE SCHEMA public;

pg_restore: from TOC entry 5925; 0 0 COMMENT SCHEMA public postgres
pg_restore: error: could not execute query: ERROR: must be owner of schema public
Command was: COMMENT ON SCHEMA public IS ‘standard public schema’;

pg_restore: from TOC entry 5926; 0 0 COMMENT EXTENSION plpgsql
pg_restore: error: could not execute query: ERROR: must be owner of extension plpgsql
Command was: COMMENT ON EXTENSION plpgsql IS ‘PL/pgSQL procedural language’;

pg_restore: from TOC entry 5927; 0 0 COMMENT EXTENSION pg_trgm
pg_restore: error: could not execute query: ERROR: must be owner of extension pg_trgm
Command was: COMMENT ON EXTENSION pg_trgm IS ‘text similarity measurement and index searching based on trigrams’;

pg_restore: from TOC entry 5928; 0 0 COMMENT EXTENSION unaccent
pg_restore: error: could not execute query: ERROR: must be owner of extension unaccent
Command was: COMMENT ON EXTENSION unaccent IS ‘text search dictionary that removes accents’;

pg_restore: warning: errors ignored on restore: 5

Celery.log has messages as below:

2022-04-04 15:10:03,568 ERROR celery.app.trace Task event_reminders[2a512407-a31c-4dc2-80b7-31a66730e1c8] raised unexpected: ProgrammingError(’(psycopg2.errors.UndefinedColumn) column reminders.send_to_speakers does not exist\nLINE 1: …cipants AS events_reminders_send_to_participants, events.rem…\n ^\n’)
Traceback (most recent call last):
File “/opt/indico/.venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py”, line 1802, in _execute_context
self.dialect.do_execute(
File “/opt/indico/.venv/lib/python3.9/site-packages/sqlalchemy/engine/default.py”, line 732, in do_execute
cursor.execute(statement, parameters)
psycopg2.errors.UndefinedColumn: column reminders.send_to_speakers does not exist
LINE 1: …cipants AS events_reminders_send_to_participants, events.rem…
^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/opt/indico/.venv/lib/python3.9/site-packages/celery/app/trace.py”, line 451, in trace_task
R = retval = fun(*args, **kwargs)
File “/opt/indico/.venv/lib/python3.9/site-packages/indico/core/celery/core.py”, line 138, in call
rv = super().call(*args, **kwargs)
File “/opt/indico/.venv/lib/python3.9/site-packages/celery/app/trace.py”, line 734, in protected_call
return self.run(*args, **kwargs)
File “/opt/indico/.venv/lib/python3.9/site-packages/sentry_sdk/integrations/celery.py”, line 197, in _inner
reraise(*exc_info)
File “/opt/indico/.venv/lib/python3.9/site-packages/sentry_sdk/_compat.py”, line 54, in reraise
raise value
File “/opt/indico/.venv/lib/python3.9/site-packages/sentry_sdk/integrations/celery.py”, line 192, in _inner
return f(*args, **kwargs)
File “/opt/indico/.venv/lib/python3.9/site-packages/indico/core/celery/util.py”, line 31, in wrapper
return f(*args, **kwargs)
File “/opt/indico/.venv/lib/python3.9/site-packages/indico/modules/events/reminders/tasks.py”, line 20, in send_event_reminders
reminders = (EventReminder.query
File “/opt/indico/.venv/lib/python3.9/site-packages/sqlalchemy/orm/query.py”, line 2759, in all
return self._iter().all()
File “/opt/indico/.venv/lib/python3.9/site-packages/sqlalchemy/orm/query.py”, line 2894, in _iter
result = self.session.execute(
File “/opt/indico/.venv/lib/python3.9/site-packages/sqlalchemy/orm/session.py”, line 1692, in execute
result = conn._execute_20(statement, params or {}, execution_options)
File “/opt/indico/.venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py”, line 1614, in _execute_20
return meth(self, args_10style, kwargs_10style, execution_options)
File “/opt/indico/.venv/lib/python3.9/site-packages/sqlalchemy/sql/elements.py”, line 325, in _execute_on_connection
return connection._execute_clauseelement(
File “/opt/indico/.venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py”, line 1481, in _execute_clauseelement
ret = self._execute_context(
File “/opt/indico/.venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py”, line 1845, in _execute_context
self.handle_dbapi_exception(
File “/opt/indico/.venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py”, line 2026, in handle_dbapi_exception
util.raise
(
File “/opt/indico/.venv/lib/python3.9/site-packages/sqlalchemy/util/compat.py”, line 207, in raise

raise exception
File “/opt/indico/.venv/lib/python3.9/site-packages/sqlalchemy/engine/base.py”, line 1802, in _execute_context
self.dialect.do_execute(
File “/opt/indico/.venv/lib/python3.9/site-packages/sqlalchemy/engine/default.py”, line 732, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedColumn) column reminders.send_to_speakers does not exist
LINE 1: …cipants AS events_reminders_send_to_participants, events.rem…
^

These warnings are fine to ignore. The errors in your second paste usually happen if you forgot to run indico db upgrade… this command is mentioned here btw: Upgrade — Indico 3.1 documentation

Hi,
According to the doc, when migrating from 2 to 3, one should restore from old db dump instead of doing indico db prepare

Correct. But you still need to run indico db upgrade (upgrade, not prepare)!

Just FYI, as of the next release we’re clearer about running the upgrade command; currently it’s just implied since the regular upgrade guide should still be taken into account in addition to the 2-to-3-specific parts.