Cannot restore synapse from backup because Go is missing

App version

Synapse, 1.157.2~ynh1

YunoHost version

12.1.41.2

Hardware

VPS bought online

Describe your issue

My synapse upgrade from 1.157.2~ynh1 to 1.160.0 failed because there were not enough space left on disk.
The restore process failed too.
After freeing up some disk space, the restore process keeps failing, because Go is apparently missing:

DEBUG - + sudo -u synapse env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin COREPACK_ENABLE_DOWNLOAD_PROMPT=0 NPM_CONFIG_UPDATE_NOTIFIER=false go build -o lk-jwt-service .
DEBUG - env: ‘go’: No such file or directory

This topic describes a similar problem but didn’t find a solution in it.

My /opt/goenv/versions/ folder is empty.

Thanks in advance for your help.

Share relevant logs or error messages

Full restore log: https://paste.yunohost.org/raw/dazurazafo

Hello,
Anyone able to point me somewhere to help solve this problem?

Try restoring the archive in CLI with --no-remove-on-failure flag.

yunohost backup restore synapse-pre-upgrade1 --no-remove-on-failure

The app won’t work but it could help with debugging.
Once done, you could even try forcing the upgrade

yunohost app upgrade synapse -b --force

Thanks @otm33 !

After restoring the archive in CLI with --no-remove-on-failure I forced the upgrade and synapse is working again!

But after reconnect my differents clients (element on desktop, element on mobile), it’s look like an empty server (I loose all my channels/conversations).
Is there anything I can do to recover the data?
(It seems my backup contains the data… And folder /home/yunohost.app/synapse is still full of media)

Here’s how the story ends:
The synapse database was simply empty because it couldn’t be restored—the restore script failed before reaching that step.

So here are the steps to resolve this restoration issue if anyone else finds themselves in the same situation: (thanks a lot @otm33 for your help and @Lapineige for further details)

  1. Check that you have enough available disk space :sweat_smile:

  2. Restore the backup using the --no-remove-on-failure flag:
    yunohost backup restore synapse-pre-upgrade1 --no-remove-on-failure

  3. Make a copy of your synapse backup (or rename it) in order to prevent it from being removed in the next step (you’ll need it in step 8)

  4. Force the application upgrade:
    yunohost app upgrade synapse -b --force

  5. Stop Synapse service
    sudo systemctl stop synapse

  6. Drop Synapse database
    sudo -u postgres psql -c "DROP DATABASE synapse;"

  7. Recreate it with correct encoding:
    sudo -u postgres psql -c "CREATE DATABASE synapse OWNER synapse ENCODING 'UTF8' LC_COLLATE 'C' LC_CTYPE 'C' TEMPLATE template0;"

  8. Extract the database dump from synapse backup:
    tar -xf /home/yunohost.backup/archives/SYNAPSE_ARCHIVE.tar -C /tmp/synapse-backup apps/synapse/backup/dump.sql

  9. Restore the db dump into postgresql:
    sudo -u postgres psql -d synapse < /tmp/synapse-backup/apps/synapse/backup/dump.sql

  10. Start Synapse service
    sudo systemctl start synapse

Note that all your devices will need to be verified again. I didn’t find a way to avoid that (but there might be a trick to doing it?)

I’m facing the same issue. Thank you for this topic.

How do you do that last step ?
How can you restore it if the app is already installed ? Do you remove it first ?

For readers : please note that -b option, that will result in that forced upgrade not making a backup prior to the upgrade. If that were the case, your synapse-pre-upgradeX backup would be removed !

Oh yeah if the topic is still closed, it’s not going to work… sorry !

ping @SiM

Yes, sorry for not explaining that.

  1. I dropped the database:
    sudo -u postgres psql -c "DROP DATABASE synapse;"

  2. Then I recreated it with correct encoding:
    sudo -u postgres psql -c "CREATE DATABASE synapse OWNER synapse ENCODING 'UTF8' LC_COLLATE 'C' LC_CTYPE 'C' TEMPLATE template0;"

  3. I extracted the database dump from my synapse backup:
    tar -xf /home/yunohost.backup/archives/SYNAPSE_ARCHIVE.tar -C /tmp/synapse-backup apps/synapse/backup/dump.sql

  4. I restored the db dump into postgresql:
    sudo -u postgres psql -d synapse < /tmp/synapse-backup/apps/synapse/backup/dump.sql

Thank you !

And I guess step 0 is to stop synapse service (from accessing the database) sudo service synapse stop

You’re right, so I have edited my previous post to add all these steps.
Thanks !

So now my issue is that client needs to reconnect and to be verified again, so that content can be synced again, and that seems to fail…

Indeed, I had to enter my recovery secret to be verified again… But in my memories it has worked. :thinking:
May be there is a trick to avoid this annoying step (one of my user did not have its recovery secret), but I didn’t find how to do that)

I’m not asked for the recovery secret, only to reset everything, verify the device (which fails) or give the recovery keys file (which I don’t have with me right now so I can’t try it yet).
And I guess the recovery key sync on server side is lost/not working ? :thinking:

In fact I’m not sure if my server is correctly restored, but I can’t restore my verification key (I tried an old one, it does nothing), or if the server stays empty.
I’ve been logged out of every session btw.
It’s a pity, I don’t even have access to message history in the client app if the server is messed up…

Does someone knows how I can check if there is any data on the server ?

And if it’s possible to dump the recovery key (which are supposed to be backed up on server side) ?