Mastodon restore from backup fails - Could not find 'bundler'

What app is this about, and its version: Mastodon v4.3.6
What YunoHost version are you running: 12.1.40.1
What type of hardware are you using: Other ARM board

Describe your issue

Upgrading Mastodon failed, so I tried to restore from a backup, but now I can’t get that to work

It says:
To install the version of bundler this project requires, run gem install bundler -v '~> 2.6'

But gem is installed with Mastodon, and deleted when the backup restore fails, so I never have a chance to run that

Any help would be much appreciated

Share relevant logs or error messages

paste (dot) yunohost (dot) org/raw/ejitikihan

(New users apparently can’t post links)

Trying to update Mastodon v4.3.6 to v4.5.11?

Yes!

But I can’t update anything until I can restore from backup

How did you make the updates on your server?
Web administrator
SSH

It is requested to execute: run gem install bundler -v '~> 2.6'

I just used the web admin

Try this:

sudo yunohost app remove mastodon
sudo yunohost backup restore mastodon-pre-upgrade1

Even less success on that front I’m afraid

Info: Preparing archive for restoration…
Info: Restoring mastodon…
Error: Failed to read info for mastodon : Invalid version: ‘0:’
Error: Failed to read info for mumbleserver : Invalid version: ‘0:’
Error: Could not restore mastodon: Something unexpected went wrong:
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/yunohost/backup.py”, line 1380, in _restore_app
_tools_migrations_run_before_app_restore(
File “/usr/lib/python3/dist-packages/yunohost/tools.py”, line 1079, in _tools_migrations_run_before_app_restore
current_version = version.parse(ynh_packages_version()[“yunohost”][“version”])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3/dist-packages/packaging/version.py”, line 52, in parse
return Version(version)
^^^^^^^^^^^^^^^^
File “/usr/lib/python3/dist-packages/packaging/version.py”, line 197, in init
raise InvalidVersion(f"Invalid version: ‘{version}’")
packaging.version.InvalidVersion: Invalid version: ‘0:’

Info: The operation ‘Restore ‘mastodon’ from a backup archive’ could not be completed. Please share the full log of this operation using the command ‘yunohost log share 20260609-200950-backup_restore_app-mastodon’ to get help
sh: 0: getcwd() failed: No such file or directory
sh: 0: getcwd() failed: No such file or directory
Error: Nothing was restored

root@mossy:/var/www/mastodon/live# yunohost log share 20260609-200950-backup_restore_app-mastodon
Error: Something wrong happened while trying to paste data on paste.yunohost.org: HTTPSConnectionPool(host=‘paste.yunohost.org’, port=443): Read timed out. (read timeout=30)

It would have been better to update as they came rather than make version 4.3.6 to version 4.5.11.
You missed a lot of them

Here are the versions you missed:
v4.5.11
v4.5.10
v4.5.8
v4.5.7
v4.5.6
v4.5.5

List:

How is it possible to do that through web admin?

To be honest, the best thing would be to do a new installation on its own.

Via SSH
Create folder to put backups

Ex:

mkdir /var/www/backups/mastodon_backup

BACKUP :floppy_disk: :

cd /var/www/mastodon/live
pg_dump -U mastodon -W -F t mastodon > /var/www/backups/mastodon_backup/mastodon_backup.dump

RESTORE :hammer_and_wrench::

cd /var/www/mastodon/live
pg_restore -U mastodon -d mastodon < /var/www/backups/mastodon_backup/mastodon_backup.dump

Here’s another example of backup.

Then make a new installation

Thanks so much. I will try tomorrow. Would there be any issue importing my old database into the latest version of Mastodon?

I don’t know, I’ve always done normally Mastodon updates…
You have to try.
Good Luck :crossed_fingers:

I ended up installing the latest version and unzipping the YunoHost backup to restore manually. Here’s what I did, for anyone’s future reference. Should let you update to any new mastodon version from the backup of any old one (if you also follow any version-specific upgrade instructions)

systemctl stop ‘mastodon-*.service’

cd /var/www/mastodon/live
mkdir backup
cd backup
tar -xvf /home/yunohost.backup/archives/mastodon-pre-upgrade1.tar
cd ..
chown -R mastodon backup/

sudo -u postgres psql
DROP DATABASE mastodon;
ALTER USER mastodon CREATEDB;
\q

cd /var/www/mastodon/live && sudo -u mastodon RAILS_ENV=production PATH=/opt/rbenv/versions/mastodon/bin bin/rails db:create

cd backup/apps/mastodon/backup/

(password for psql mastodon user is in live/.env.production)

sudo -u mastodon psql mastodon < “./db.sql”

su - mastodon

(copy keys from live/backup/apps/mastodon/backup/var/www/mastodon/live/.env.production to live/.env.production)

rm -rf live/public/system/
mv live/backup/apps/mastodon/backup/var/www/mastodon/live/public/system live/public/

cd /var/www/mastodon/live && sudo -u mastodon RAILS_ENV=production

LD_PRELOAD=libjemalloc.so PATH=/opt/rbenv/versions/mastodon/bin bin/bundle exec rails db:migrate

cd /var/www/mastodon/live && sudo -u mastodon RAILS_ENV=production PATH=/opt/rbenv/versions/mastodon/bin bin/rails runner rename.rb