Mattermost のアップデート　v5.34.2→v5.37.9(ESR)→v6.3.6

インストール 作業メモ [22/03/25]

#### Apache & Subdirectry 運用設定です。
- Ubuntu 20.04.2 LTS
 - Mattermost Team Edition v5.34.2 からのUpdate
 - PostgreSQL 12.6 (Ubuntu 12.6-0ubuntu0.20.04.1)


・ ×Mattermost Enterprise Edition v5.37.9
　　~~https://releases.mattermost.com/5.37.9/mattermost-5.37.9-linux-amd64.tar.gz~~
・ 〇Mattermost Team Edition v5.37.9　('-team-'の文字が付きます。)
　　https://releases.mattermost.com/5.37.9/mattermost-team-5.37.9-linux-amd64.tar.gz
・ 〇Mattermost Team Edition v6.3.6　('-team-'の文字が付きます。)
　　https://releases.mattermost.com/6.3.6/mattermost-team-6.3.6-linux-amd64.tar.gz



### ■作業前にデータのバックアップ
~~~
apacheを停止
# sudo systemctl stop apache2
 
データベースのバックアップ (開封パスワード付き)
# pg_dump --username mmuser --password -f /tmp/mattermost.dump mattermost
 
PostgreSQLを停止
# sudo service postgresql stop
~~~

## 結論：↓このページのコマンドを手順に沿って入力すれば大丈夫
https://docs.mattermost.com/upgrade/upgrading-mattermost-server.html

### ※但し、ESRバージョンで刻みバージョンアップを行うべし！
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/166558/36a20813-51ce-7ef7-71bd-c05cfbbf796e.png)



### ■v5.34.2→v5.37.9(ESR) のアップデート
~~~
cd /tmp
sudo wget https://releases.mattermost.com/5.37.9/mattermost-team-5.37.9-linux-amd64.tar.gz
sudo tar -xf ./mattermost-team-5.37.9-linux-amd64.tar.gz --transform='s,^[^/]\+,\0-upgrade,'
cd /opt
sudo cp -ra mattermost/ mattermost-back-$(date +'%F-%H-%M')/
sudo find mattermost/ mattermost/client/ -mindepth 1 -maxdepth 1 \! \( -type d \( -path mattermost/client -o -path mattermost/client/plugins -o -path mattermost/config -o -path mattermost/logs -o -path mattermost/plugins -o -path mattermost/data \) -prune \) | sort | sudo xargs rm -r
sudo find mattermost/ mattermost/client/ -mindepth 1 -maxdepth 1 \! \( -type d \( -path mattermost/client -o -path mattermost/client/plugins -o -path mattermost/config -o -path mattermost/logs -o -path mattermost/plugins -o -path mattermost/data \) -prune \) | sort
sudo cp -an /tmp/mattermost-upgrade/. mattermost/
sudo chown -R mattermost:mattermost mattermost
sudo setcap cap_net_bind_service=+ep ./mattermost/bin/mattermost
sudo systemctl start mattermost
~~~


### ■v5.37.9(ESR) →　v6.3.6　へのアップデート
~~~
cd /tmp
sudo wget https://releases.mattermost.com/6.3.6/mattermost-team-6.3.6-linux-amd64.tar.gz
sudo tar -xf ./mattermost-team-6.3.6-linux-amd64.tar.gz --transform='s,^[^/]\+,\0-upgrade,'
cd /opt
sudo cp -ra mattermost/ mattermost-back-$(date +'%F-%H-%M')/
sudo find mattermost/ mattermost/client/ -mindepth 1 -maxdepth 1 \! \( -type d \( -path mattermost/client -o -path mattermost/client/plugins -o -path mattermost/config -o -path mattermost/logs -o -path mattermost/plugins -o -path mattermost/data \) -prune \) | sort | sudo xargs rm -r
sudo find mattermost/ mattermost/client/ -mindepth 1 -maxdepth 1 \! \( -type d \( -path mattermost/client -o -path mattermost/client/plugins -o -path mattermost/config -o -path mattermost/logs -o -path mattermost/plugins -o -path mattermost/data \) -prune \) | sort
sudo cp -an /tmp/mattermost-upgrade/. mattermost/
sudo chown -R mattermost:mattermost mattermost
sudo setcap cap_net_bind_service=+ep ./mattermost/bin/mattermost
sudo systemctl start mattermost
~~~


##### ■参考にさせていただいたページ
https://docs.mattermost.com/upgrade/upgrading-mattermost-server.html#
https://chotto.news/archives/27216
https://rixwwd.hatenablog.jp/entry/2018/03/31/205934