TL;DR: It's possible, and not too hard, but has oddities a restart will address.
Due to my self-hosted Sentry instance getting into a weird state (I couldn't get an upgrade to work due not being able to make it past a hard-stop upgrade process), I decided the best option forward was to build a new VM and reinstall a fresh Sentry setup. However, I wanted my existing apps out there to still report in (without updating), which meant that I had to ensure that the DSNs out in the wild would still work.
Thankfully, this wasn't too hard. Given that the Postgres database of my current instance wasn't in the right state, and I didn't have anything important in the existing install, I decided just ensuring the existing DSN URLs worked was what I wanted, rather than dealing with copying the database over.
Disclaimer: I don't work for Sentry, and this might not work for you, and I'm not providing warranty or support of the below.
This worked for me on Sentry 25.3.0.
Getting the data you need from the existing instance
Get the contents of the sentry_project
and sentry_projectkey
table: docker compose exec postgres psql -U postgres -c "select * from sentry_project;"
docker compose exec postgres psql -U postgres -c "select * from sentry_project;" > project.txt
docker compose exec postgres psql -U postgres -c "select * from sentry_projectkey;" > projectkey.txt
Set up new Sentry instance
Follow the instructions provided by Sentry to install this on your fresh VM.
Rebuild the projects
Now, you'll need to ensure the project ID and the public key are the same for this to work.
I used the Sentry interface to create the projects in the right order to ensure the project IDs were correct. However, I made a mistake and had to resort to resetting the sequence with SELECT setval('sentry_project_id_seq', <largest current id>);
You probably don't have to do it to sentry_projectkey
but I did.
Update the keys
To update the keys, set the public_key
and secret_key
(probably don't need it but I figured it couldn't hurt) to the values.
docker compose exec psql -U postgres
UPDATE sentry_projectkey SET public_key = '<public key>', secret_key = '<secret key>' WHERE project_id = <project id>;
Restart Sentry
There's some kind of caching around the public_keys
, which makes sense as event ingestion is a hot path, so you'll need to restart the relevant process. I didn't know which one it was, so restarting Sentry completely worked for me in the end. I did see it working without restarting after one project but it wasn't reliable.
docker compose restart
# nginx sometimes needs a kick
docker compose restart web
# if still no go, complete restart
docker compose stop
docker compose up -d
That's it!
I hope you've found this useful.
Comments