> [!warning] > 私はMastdonフォークの「kmyblue」を使用しています。Mastodonでも大まかな流れが同じだと思いますが、一部違う可能性があります。 > > また、下記の設定以外にも設定が必要になる可能性があります。必ず公式のリリースノートを読みましょう。 ## 自分が行う大まかな流れ 1. Mastodonを止める 2. DBをバックアップ 3. aptでアップデート 4. Mastodonユーザーに変更 5. Git fetch & checkout 6. (必要に応じて)Rubyアップデート 7. bundle & yarnインストール 8. (必要に応じて)DBマイグレーション・プリコンパイル 9. Mastodon再起動 ## 詳細 ### 1. Mastodonを止める メンテナンスを行う前に、Mastodonを止めます。 ``` $ sudo systemctl stop mastodon-web mastodon-streaming mastodon-sidekiq ``` ### 2. DBをバックアップ - [[Mastodon・MisskeyのデータベースをR2にバックアップする]] 私は上記記事の環境で「R2バックアップ」を行っています。そのため、bashの名前や置き場所があなたの環境とは違う可能性があります。 ``` $ bash /usr/local/bin/backup.sh ``` ### 3.aptアップデート - [[aptコマンドによるアップデートをおさらいする]] aptで必要なパッケージをアップデートします。詳細は上記記事にて。 ### 4.Mastodonユーザーに変更 Mastodonアップデートを行うために、Mastodonユーザーに変更します。 ``` $ sudo su - mastodon # cd live ``` ### 5. Git fetch & checkout MastodonのアップデートをGitで確認します。 ``` # git fetch --tags # git checkout <タグ名> ``` ### 6. (必要に応じて)Rubyアップデート - [[【Mastodon】Rubyのメンテナンス方法をおさらいする]] Rubyアップデートが必要な場合、上記記事を参考にアップデートします。 ### 7.bundle & yarn インストール bundleとyarnをインストールします。 ``` # bundle install # yarn install ``` ### 8.(必要に応じて)DBマイグレーション・プリコンパイル メジャーアップデートが来た時に必要になる作業。GitHubのリリースを読みながら行います。 ``` # RAILS_ENV=production bin/rails db:migrate # RAILS_ENV=production bin/rails assets:precompile ``` 大体この2つで大丈夫。プリコンパイルがダメだったら下記の通りに行います。 1. `clobber`を行う([kmyblueアップデートサイト](https://github.com/kmycode/mastodon/wiki/Updation)参照) 2. `mastodon-web`を止める 3. サーバー再起動 ### 9. Mastodon再起動 成功したら、`root`ユーザーに戻ってMastodonを再起動します。 ``` $ sudo systemctl restart mastodon-web mastodon-streaming mastodon-sidekiq ``` ## 関連リンク - [[aptコマンドによるアップデートをおさらいする]] - [[Mastodon・MisskeyのデータベースをR2にバックアップする]] - [[【Mastodon】Rubyのメンテナンス方法をおさらいする]] ## 参考サイト - [Releases · kmycode/mastodon](https://github.com/kmycode/mastodon/releases) - [Updation · kmycode/mastodon Wiki · GitHub](https://github.com/kmycode/mastodon/wiki/Updation) - [Releases · mastodon/mastodon](https://github.com/mastodon/mastodon/releases)