Importing sentry on-premise data from 8.x.x to 21.x.x

We have a production running on-premise sentry 8.x.x setup and I have recently created a new production running on-premise sentry 21.xx setup. Is there a way to import old sentry setup project configurations , users etc to new setup ?

This may work: https://develop.sentry.dev/self-hosted/backup/#quick-backup

But since the version difference is quite a lot, I wouldn’t get my hopes too high. You may want to try upgrading to 9.1.2 in-place (or on a separate copy with db backups) and then try moving to 21.4 from there.

Thanks, I’m struggling to dump and restore 8.2 db into 9.1.2, any docs for this ?

Is this a docker-compose based setup or something else? If it is docker-compose based and using the onpremise repo, you can checkout 9.1.2 from that repo and run ./install.sh which will take care of all the upgrades etc.

If this is a custom install you may try to move Postgres data files into a docker volume or get a full SQL dump from your DB and then load it up into a containerized Postgres and move on from there.

Thanks, Yes it is a docker-compose based setup, Is there any required .env or docker-compose.yml file related config changes?

I realized sadly it’s not using onpremise repo, It’s using this https://github.com/yhirano55/sentry-docker-compose.git

That’s okay, you are already ahead of the game. You can take 9.1.2 and rename sentry-postgres to pg-data and sentry-redis to redis-data and run ./install.sh.

After that you can do the same for 21.4.1

I managed to get it from 8.2 to 9.1.2 but It’s not allowing me to login with below, I’m trying again now.

Oops! Something went wrong

It looks like you’ve hit an issue in our server API. Don’t worry though! We use Sentry to monitor Sentry and it’s likely we’re already looking into this!

If you’re daring, you may want to try the following:

  • Give it a few seconds and reload the page.
  • If all else fails, create an issue with more details.

Alright, It worked second time, 9.1.2 works fine, then tried to upgrade to 21.4.1 with pg-data volume , ./install.sh fails with following error.

django.db.utils.OperationalError: could not translate host name “postgres” to address: Name or service not known

Logs please :slight_smile:

./install.sh script exists with that error.

:arrow_forward: Setting up / migrating database …
Starting sentry_onpremise_redis_1 …
Creating sentry_onpremise_symbolicator_1 …
Starting sentry_onpremise_redis_1 … done
Starting sentry_onpremise_clickhouse_1 …
Starting sentry_onpremise_clickhouse_1 … done
Starting sentry_onpremise_zookeeper_1 …
Creating sentry_onpremise_memcached_1 …
Starting sentry_onpremise_zookeeper_1 … done
Creating sentry_onpremise_postgres_1 …
Starting sentry_onpremise_kafka_1 …
Starting sentry_onpremise_kafka_1 … done
Creating sentry_onpremise_snuba-sessions-consumer_1 …
Creating sentry_onpremise_snuba-api_1 …
Creating sentry_onpremise_snuba-outcomes-consumer_1 …
Creating sentry_onpremise_snuba-subscription-consumer-events_1 …
Creating sentry_onpremise_snuba-subscription-consumer-transactions_1 …
Creating sentry_onpremise_snuba-consumer_1 …
Creating sentry_onpremise_snuba-replacer_1 …
Creating sentry_onpremise_snuba-transactions-consumer_1 …
Creating sentry_onpremise_memcached_1 … done
Creating sentry_onpremise_snuba-api_1 … done
Creating sentry_onpremise_symbolicator_1 … done
Creating sentry_onpremise_snuba-outcomes-consumer_1 … done
Creating sentry_onpremise_postgres_1 … done
Creating sentry_onpremise_snuba-sessions-consumer_1 … done
Creating sentry_onpremise_snuba-consumer_1 … done
Creating sentry_onpremise_snuba-subscription-consumer-transactions_1 … done
Creating sentry_onpremise_snuba-subscription-consumer-events_1 … done
Creating sentry_onpremise_snuba-transactions-consumer_1 … done
Creating sentry_onpremise_snuba-replacer_1 … done
14:22:04 [WARNING] sentry.utils.geo: Error opening GeoIP database: /geoip/GeoLite2-City.mmdb
14:22:04 [WARNING] sentry.utils.geo: Error opening GeoIP database in Rust: /geoip/GeoLite2-City.mmdb
14:22:12 [INFO] sentry.plugins.github: apps-not-configured
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 213, in ensure_connection
self.connect()
File “/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 189, in connect
self.connection = self.get_new_connection(conn_params)
File “/usr/local/lib/python3.6/site-packages/django/db/backends/postgresql/base.py”, line 176, in get_new_connection
connection = Database.connect(**conn_params)
File “/usr/local/lib/python3.6/site-packages/psycopg2/init.py”, line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: could not translate host name “postgres” to address: Name or service not known

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

Traceback (most recent call last):
File “/usr/local/bin/sentry”, line 8, in
sys.exit(main())
File “/usr/local/lib/python3.6/site-packages/sentry/runner/init.py”, line 195, in main
func(**kwargs)
File “/usr/local/lib/python3.6/site-packages/click/core.py”, line 829, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python3.6/site-packages/click/core.py”, line 782, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python3.6/site-packages/click/core.py”, line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python3.6/site-packages/click/core.py”, line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python3.6/site-packages/click/core.py”, line 610, in invoke
return callback(*args, **kwargs)
File “/usr/local/lib/python3.6/site-packages/click/decorators.py”, line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File “/usr/local/lib/python3.6/site-packages/sentry/runner/decorators.py”, line 29, in inner
return ctx.invoke(f, *args, **kwargs)
File “/usr/local/lib/python3.6/site-packages/click/core.py”, line 610, in invoke
return callback(*args, **kwargs)
File “/usr/local/lib/python3.6/site-packages/click/decorators.py”, line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File “/usr/local/lib/python3.6/site-packages/sentry/runner/commands/upgrade.py”, line 171, in upgrade
_upgrade(not noinput, traceback, verbosity, not no_repair, with_nodestore)
File “/usr/local/lib/python3.6/site-packages/sentry/runner/commands/upgrade.py”, line 118, in _upgrade
_migrate_from_south(verbosity)
File “/usr/local/lib/python3.6/site-packages/sentry/runner/commands/upgrade.py”, line 90, in _migrate_from_south
if not _has_south_history(connection):
File “/usr/local/lib/python3.6/site-packages/sentry/runner/commands/upgrade.py”, line 75, in _has_south_history
cursor = connection.cursor()
File “/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 254, in cursor
return self._cursor()
File “/usr/local/lib/python3.6/site-packages/sentry/db/postgres/decorators.py”, line 40, in inner
return func(self, *args, **kwargs)
File “/usr/local/lib/python3.6/site-packages/sentry/db/postgres/base.py”, line 96, in _cursor
return super()._cursor()
File “/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 229, in _cursor
self.ensure_connection()
File “/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 213, in ensure_connection
self.connect()
File “/usr/local/lib/python3.6/site-packages/django/db/utils.py”, line 94, in exit
six.reraise(dj_exc_type, dj_exc_value, traceback)
File “/usr/local/lib/python3.6/site-packages/django/utils/six.py”, line 685, in reraise
raise value.with_traceback(tb)
File “/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 213, in ensure_connection
self.connect()
File “/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py”, line 189, in connect
self.connection = self.get_new_connection(conn_params)
File “/usr/local/lib/python3.6/site-packages/django/db/backends/postgresql/base.py”, line 176, in get_new_connection
connection = Database.connect(**conn_params)
File “/usr/local/lib/python3.6/site-packages/psycopg2/init.py”, line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: could not translate host name “postgres” to address: Name or service not known

An error occurred, caught SIGERR on line 12
Cleaning up…

Can you share what you get when you run docker-compose logs postgres?

/opt/onpremise# docker-compose logs postgres
Attaching to sentry_onpremise_postgres_1
postgres_1 |
postgres_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1 |
postgres_1 | FATAL: database files are incompatible with server
postgres_1 | DETAIL: The data directory was initialized by PostgreSQL version 9.5, which is not compatible with this version 9.6.21.
postgres_1 |
postgres_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1 |
postgres_1 | FATAL: database files are incompatible with server
postgres_1 | DETAIL: The data directory was initialized by PostgreSQL version 9.5, which is not compatible with this version 9.6.21.
postgres_1 |
postgres_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1 |
postgres_1 | FATAL: database files are incompatible with server
postgres_1 | DETAIL: The data directory was initialized by PostgreSQL version 9.5, which is not compatible with this version 9.6.21.
postgres_1 |
postgres_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1 |
postgres_1 | FATAL: database files are incompatible with server
postgres_1 | DETAIL: The data directory was initialized by PostgreSQL version 9.5, which is not compatible with this version 9.6.21.
postgres_1 |
postgres_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1 |
postgres_1 | FATAL: database files are incompatible with server
postgres_1 | DETAIL: The data directory was initialized by PostgreSQL version 9.5, which is not compatible with this version 9.6.21.
postgres_1 |
postgres_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1 |
postgres_1 | FATAL: database files are incompatible with server
postgres_1 | DETAIL: The data directory was initialized by PostgreSQL version 9.5, which is not compatible with this version 9.6.21.
postgres_1 |
postgres_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1 |
postgres_1 | FATAL: database files are incompatible with server
postgres_1 | DETAIL: The data directory was initialized by PostgreSQL version 9.5, which is not compatible with this version 9.6.21.

That’s peculiar as we have a built-in Postgres 9.5 to 9.6 migration code: onpremise/upgrade-postgres.sh at f27eaef55781a43cf00bff4bcdc64bea8d77c707 · getsentry/onpremise · GitHub

Oh wait, I think you need to modify this script to use pg-data as the volume name, instead of sentry-postgres.

Thanks, Yeah it went well and migration also completed but unable to login to sentry with previous login details. I saw some errors and complaints while running upgrade-postgres.sh and install.sh, I’m trying again now. Also I’ve got new errors

/opt/onpremise# docker-compose logs postgres
Attaching to sentry_onpremise_postgres_1
postgres_1                                  | 
postgres_1                                  | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1                                  | 
postgres_1                                  | LOG:  database system was shut down at 2021-05-07 10:36:48 UTC
postgres_1                                  | LOG:  MultiXact member wraparound protections are now enabled
postgres_1                                  | LOG:  database system is ready to accept connections
postgres_1                                  | LOG:  autovacuum launcher started
postgres_1                                  | ERROR:  relation "sentry_option" does not exist at character 114
postgres_1                                  | STATEMENT:  SELECT "sentry_option"."id", "sentry_option"."key", "sentry_option"."value", "sentry_option"."last_updated" FROM "sentry_option" WHERE "sentry_option"."key" = 'system.url-prefix'
postgres_1                                  | ERROR:  relation "sentry_option" does not exist at character 114
postgres_1                                  | STATEMENT:  SELECT "sentry_option"."id", "sentry_option"."key", "sentry_option"."value", "sentry_option"."last_updated" FROM "sentry_option" WHERE "sentry_option"."key" = 'github.apps-install-url'
postgres_1                                  | ERROR:  relation "sentry_option" does not exist at character 114
postgres_1                                  | STATEMENT:  SELECT "sentry_option"."id", "sentry_option"."key", "sentry_option"."value", "sentry_option"."last_updated" FROM "sentry_option" WHERE "sentry_option"."key" = 'system.url-prefix'
postgres_1                                  | ERROR:  relation "sentry_option" does not exist at character 114
postgres_1                                  | STATEMENT:  SELECT "sentry_option"."id", "sentry_option"."key", "sentry_option"."value", "sentry_option"."last_updated" FROM "sentry_option" WHERE "sentry_option"."key" = 'system.url-prefix'
postgres_1                                  | ERROR:  relation "sentry_option" does not exist at character 114
postgres_1                                  | STATEMENT:  SELECT "sentry_option"."id", "sentry_option"."key", "sentry_option"."value", "sentry_option"."last_updated" FROM "sentry_option" WHERE "sentry_option"."key" = 'vercel.integration-slug'
postgres_1                                  | ERROR:  relation "sentry_option" does not exist at character 114
postgres_1                                  | STATEMENT:  SELECT "sentry_option"."id", "sentry_option"."key", "sentry_option"."value", "sentry_option"."last_updated" FROM "sentry_option" WHERE "sentry_option"."key" = 'system.url-prefix'
postgres_1                                  | ERROR:  relation "sentry_option" does not exist at character 114
postgres_1                                  | STATEMENT:  SELECT "sentry_option"."id", "sentry_option"."key", "sentry_option"."value", "sentry_option"."last_updated" FROM "sentry_option" WHERE "sentry_option"."key" = 'msteams.app-id'
postgres_1                                  | ERROR:  relation "sentry_projectkey" does not exist at character 371
postgres_1                                  | STATEMENT:  SELECT "sentry_projectkey"."id", "sentry_projectkey"."project_id", "sentry_projectkey"."label", "sentry_projectkey"."public_key", "sentry_projectkey"."secret_key", "sentry_projectkey"."roles", "sentry_projectkey"."status", "sentry_projectkey"."date_added", "sentry_projectkey"."rate_limit_count", "sentry_projectkey"."rate_limit_window", "sentry_projectkey"."data" FROM "sentry_projectkey" WHERE ("sentry_projectkey"."project_id" = 1 AND "sentry_projectkey"."roles" = (("sentry_projectkey"."roles" | 1)) AND "sentry_projectkey"."status" = 0) ORDER BY "sentry_projectkey"."id" ASC LIMIT 1
postgres_1                                  | ERROR:  relation "south_migrationhistory" does not exist at character 15
postgres_1                                  | STATEMENT:  SELECT 1 FROM south_migrationhistory LIMIT 1
postgres_1                                  | LOG:  received fast shutdown request
postgres_1                                  | LOG:  aborting any active transactions
postgres_1                                  | LOG:  autovacuum launcher shutting down
postgres_1                                  | LOG:  shutting down
postgres_1                                  | LOG:  database system is shut down
postgres_1                                  | 
postgres_1                                  | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1                                  | 
postgres_1                                  | LOG:  database system was shut down at 2021-05-07 10:40:45 UTC
postgres_1                                  | LOG:  MultiXact member wraparound protections are now enabled
postgres_1                                  | LOG:  database system is ready to accept connections
postgres_1                                  | LOG:  autovacuum launcher started
1 Like

Not sure about those errors but since it says autovacuum launcher started, maybe Postgres is doing a vacuum which may cause availability issues.

Also, if you can share some logs from the web container, we can see what’s going on from Sentry’s perspective when you try to login.

1 Like

I had multiple technical difficulties to attend to this task and thanks for the patience, It looks like a fresh setup once execute ./install.sh and upgrade from 9.1.2 to 21.4.1 was success without provisioning old data set, If I create a new user and log web it works but old project data is not available, if I inspect postgres container it uses old volume though.

Hello again! There should have been a lengthy migration if the volume was pointing to the old instance to get the old events to the new system. If you haven’t seen it, you probably have a slight error with how you configure your volumes.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.