LoginSignup
5
3

More than 5 years have passed since last update.

自鯖Mastodonを更新したらうまく動かなくなったので元のバージョンに戻す

Posted at

何か失敗したことに気づく

前のrevisionの戻そうと思う

そんな時のための git reflog

$ git reflog
c99fc08 HEAD@{0}: merge origin/master: Fast-forward
7447e7a HEAD@{1}: clone: from https://github.com/tootsuite/mastodon.git

元は 7447e7a で更新して c99fc08 になった状態です => 7447e7a に戻します

差分を確認するのです(確か更新したときに db:migrate をしたので戻さないといけません)

$ git diff 7447e7a..c99fc08 --name-status
A       db/migrate/20170409170753_add_last_webfingered_at_to_accounts.rb
A       db/migrate/20170414080609_add_devise_two_factor_backupable_to_users.rb

抜粋です 20170409170753 と 20170414080609 ですね

とりあえず鯖落とします

systemdでないので自作init.dで止めます(node.jsはまあいいや)

# /etc/init.d/mastodon_web stop
# /etc/init.d/mastodon_sidekiq stop

gitを戻す前にmigrateを戻します

migrateは昇順に適用されるので戻す時は降順に戻します。

$ RAILS_ENV=production bundle exec rake db:migrate:down VERSION=20170414080609
$ RAILS_ENV=production bundle exec rake db:migrate:down VERSION=20170409170753

gitを更新前に戻します

$ git checkout 7447e7a

ローカルブランチのmasterを消して更新前をmasterにしなおします

$ git branch -d master
$ git checkout -b master

これでgitは元の状態に戻りました

Mastodonの起動準備をします

あらためてひととおり実行

$ bundle install
$ RAILS_ENV=production bundle exec rake db:migrate # 何も実行されないはず
$ RAILS_ENV=production bundle exec rake assets:precompile

鯖を上げる

$ /etc/init.d/mastodon_web start
$ /etc/init.d/mastodon_sidekiq start

node.js は残念ながらまだ手動で再起動しています。

おわり

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3