LoginSignup
7
6

More than 1 year has passed since last update.

Slack データをエクスポート

Last updated at Posted at 2022-08-30

Slack のフリープランを勉強会コミュニティのコミュニュケーションチャネルとして使っていました。
Slack はサービスにログオンして使う分には使い勝手が良かったのですが、コミュニティ用途には以下の問題がありました。

  • Slack はメッセージ数上限となると過去メッセージは流れてしまう
  • ディスカッションの内容がメンバークローズドになり、部外者が内容を閲覧できない
  • 昔の ML(メーリングリスト) ベースのコミュニケーションのように、ログをオープンにできないか
    • 公開して Google でヒットするようにしたい
    • 集合知を公開し再利用できるようにしたい
    • 同じ興味のある人間のコミュニティへの参加導線にしたい

ということを考えかねてよりログを取っていました。まだ公開の仕組みを作るのはできていませんが、この度 Slack のフリープランの内容変更の機会にログ取得の方法だけでも改めてまとめてみました。

今回のフリープランの改訂は、メッセージ数を1万件、ストレージ容量を 5GB から 過去 90 日間のメッセージ履歴とファイルストレージの利用に変更だそうです。

ということで今までもメッセージ数1万件までの制限があったはずですが、実はエクスポートなどでログを取得すると、完全ログが取得できていました。改定後は過去90日以前のログが取得できるかは不明ですが、そうであっても自動で定期的にログを取得し、アーカイブで閲覧する仕組みを作っておけばフリープラン改定しても Slack は依然として便利に使えるのかも。

また、コミュニティのSlackでなくてもこの機会にログを取得しておき、手元で過去ログを参照したり、いろんなコミュニュケーションツールに移行したりできるようにしておきたいですね。

環境

  • Ubuntu 22.04 LTS と、 MS-Windows 10 Pro で動作チェックを行いました。

ワークスペースだけをエクスポート

手動でエクスポートする方法です。

アプリでワークスペース名をクリック-「設定と管理」-「ワークスペースの設定」
image.png

あるいは、直接以下を開きます。
https://<ワークスペース名>.slack.com/admin/settings

image.png

にアクセスし、「データのインポート/エクスポート」を押します。

image.png

しばらくしたらダウンロード準備ができたという通知があるので、ダウンロードします。
image.png

DM,プライベートスペース、ファイルも全部 をエクスポート

「2022年8月版:slackのバックアップ方法|荒川 豊 (Yutaka Arakawa)|note」
https://note.com/wildriver/n/ne0f7969a9c3b
これを元に、
「rusq/slackdump: Save your private and public slack messages, threads, files, and users locally.」
https://github.com/rusq/slackdump/

を使ってみます。

slackdump の特徴

  • めんどくさいトークンを作らなくてもいい
  • ブラウザが起動し、そこから自動ダウンロード
  • ブラウザをパスワードログインする必要がある
    • google アカウント連携認証では入れない

アプリダウンロード、解凍、実行 ( Linux )

https://github.com/rusq/slackdump/releases
より、
slackdump-v2.2.0-alpha-linux-amd64.tar.gz
をダウンロードします。

image.png

解凍します

$ tar xzvf slackdump-v2.2.0-alpha-linux-amd64.tar.gz 
LICENSE
README.rst
slackdump

実行

$ ./slackdump
Slackdump v2.2.0-alpha Copyright (c) 2018-2022 rusq (build: 88158c2)

? What would you like to do?  [Use arrows to move, type to filter]
> Dump - save a list of conversations
  Export - save the workspace or conversations in Slack Export format
  List - list conversations or users on the screen
  Exit - exit Slackdump and return to OS

メニューが出てきます。しかしながら今回はこちらは使いませんでした。
一度終了し、参考サイトと同様にパラメータ指定で実行してみました。
以下のように zip ファイルを指定すると zip に、 そうでなければフォルダーに保存されます。

$ ./slackdump -export yyyy.zip -export-type standard -download
Slackdump v2.2.0-alpha Copyright (c) 2018-2022 rusq (build: 88158c2)

2022/08/31 01:30:18 Downloading driver to /home/nanbuwks/.cache/ms-playwright-go/1.20.0-beta-1647057403000
2022/08/31 01:30:36 Downloaded driver successfully
Downloading Playwright build of chromium v978106 - 130.7 Mb [====================] 100% 0.0s 
Playwright build of chromium v978106 downloaded to /home/nanbuwks/.cache/ms-playwright/chromium-978106
Downloading Playwright build of ffmpeg v1007 - 2.6 Mb [====================] 100% 0.0s 
Playwright build of ffmpeg v1007 downloaded to /home/nanbuwks/.cache/ms-playwright/ffmpeg-1007

最初はブラウザなどがダウンロードされます。
その後、ワークスペース名を入力します。

? Enter Slack Workspace Name:  akbrobot
Please login in the browser...

chromium が起動し、ログインを促されます。

image.png

「Google でサインインする」は機能しませんでしたので、メールアドレスとパスワードでログインします。


2022/08/31 02:04:55 > checking user cache...
2022/08/31 02:04:55   caching users for the first time
2022/08/31 02:04:55 Export:  staring export to: <zip archive: yyyy.zip>
2022/08/31 02:04:56   thread request #    1, fetched:    2, total:        2, process results:  (speed:  10.35/sec, avg:  10.35/sec)
2022/08/31 02:04:56   thread fetch complete, total: 2
2022/08/31 02:04:56 messages request #    1, fetched:   42 (threads: 1, files: 0), total:       42 (speed:  98.39/sec, avg:  98.39/sec)
2022/08/31 02:04:56 messages fetch complete, total: 42
2022/08/31 02:04:57   thread request #    1, fetched:    3, total:        3, process results:  (speed:  15.83/sec, avg:  15.83/sec)
2022/08/31 02:04:57   thread fetch complete, total: 3
2022/08/31 02:04:57   thread request #    1, fetched:    7, total:        7, process results:  (speed:  19.96/sec, avg:  19.96/sec)
2022/08/31 02:04:57   thread fetch complete, total: 7
2022/08/31 02:04:57   thread request #    1, fetched:    4, total:        4, process results:  (speed:  11.20/sec, avg:  11.20/sec)
.
.
.
2022/08/31 02:08:29 file "F01K2JL8NBT-image (5).png" saved to attachments: 1433079 bytes written
2022/08/31 02:08:29 file "F01JQ5USK19-image (3).png" saved to attachments: 1755874 bytes written
2022/08/31 02:08:29 file "F03N6HV31PZ-マイプロ資料.zip" saved to attachments: 5581527 bytes written
2022/08/31 02:08:30 file "F02UFNUP0C9-2022未踏adv公募説明会配布資料.pdf" saved to attachments: 2739224 bytes written
2022/08/31 02:08:30 file "F019ZFM6L3T-image.png" saved to attachments: 1676687 bytes written
2022/08/31 02:08:30 file "F01CJ493N0L-VID_20191211_144508.mp4" saved to attachments: 10090255 bytes written
2022/08/31 02:08:30 file "F0123U4C1N3-RUMICAR.sch" saved to attachments: 18977 bytes written
2022/08/31 02:08:31 file "F019ZFKFRSM-image.png" saved to attachments: 645816 bytes written
2022/08/31 02:08:31 completed, time taken: 3m36.292105914s

これで、 yyyy.zip にダウンロードされました。

資格情報

https://github.com/rusq/slackdump/blob/master/doc/login-auto.rst
によると、

Your credentials will be stored in an encrypted file in a Slackdump cache subdirectory of your user's Local Cache directory.

How safe is the storage

The encrypted file is protected with AES-256 encryption using your Operating System unique Machine ID. It is not possible to copy it to another machine: it will not be able to be decrypted anywhere else but your computer.

となっていました。資格情報は保存されるので、次回以降はブラウザログオンしなくても自動で同じワークスペースを操作できます。

別のワークスペースを操作する

一度ログインするとログイン情報を覚え込むので、それを破棄するには

Reset the Authentication (Logout)

In order to be able to login again (or to another workspace), run the Slackdump with -auth-reset flag:

./slackdump -auth-reset

This will delete the stored credentials and you'll be able to login with EZ-Login 3000 again.
``

とありますが操作がめんどくさいです。

$  rm -rf  ~/.cache/slackdump

とするのが簡単でした。

mattermost 用のエクスポートデータを作る

執筆時の v2.2.0-alpha ではアルファ版ではあるものの、

$ ./slackdump -export akbrobot_2mattermost.zip -export-type mattermost -download

として mattermost 形式で出力できるようです。zip 出力を指定します。

詳細はドキュメント参照:
https://github.com/rusq/slackdump/blob/master/doc/usage-export.rst

アプリダウンロード、解凍、実行 ( Windows )

https://github.com/rusq/slackdump/releases
より、

slackdump-v2.2.0-alpha-windows-amd64.zip

をダウンロードします。

image.png

解凍します
image.png

ダブルクリックで一度実行して、セキュリティ設定を更新します。
image.png

Slackdump v2.2.0-alpha Copyright (c) 2018-2022 rusq (build: 88158c2)

? What would you like to do?  [Use arrows to move, type to filter]
> Dump - save a list of conversations
  Export - save the workspace or conversations in Slack Export format
  List - list conversations or users on the screen
  Exit - exit Slackdump and return to OS

Linux の場合と同じように Exit します。

image.png

> cd Downloads\slackdump-v2.2.0-alpha-windows-amd64
> slackdump -export skacklog.zip -export-type standard -download
Slackdump v2.2.0-alpha Copyright (c) 2018-2022 rusq (build: 88158c2)

2022/08/31 17:31:22 Downloading driver to C:\Users\hoken\AppData\Local\ms-playwright-go\1.20.0-beta-1647057403000
2022/08/31 17:31:25 Downloaded driver successfully
Downloading Playwright build of chromium v978106 - 103.8 Mb [====================] 100% 0.0s
Playwright build of chromium v978106 downloaded to C:\Users\hoken\AppData\Local\ms-playwright\chromium-978106
Downloading Playwright build of ffmpeg v1007 - 1.4 Mb [====================] 100% 0.0s
Playwright build of ffmpeg v1007 downloaded to C:\Users\hoken\AppData\Local\ms-playwright\ffmpeg-1007
? Enter Slack Workspace Name:  [? for help]

最初はブラウザなどがダウンロードされます。
その後、ワークスペース名を入力するとchromium が起動し、ログインを促されるのは Linux の場合と
同様です。

「Google でサインインする」は機能しませんので、メールアドレスとパスワードでログインします。

これで、 slackexport.zip にダウンロードされました。

資格情報を削除して別のワークスペースを操作する

Linux では以下のようにしましたが、

$  rm -rf  ~/.cache/slackdump

Windowsでは以下のようにします。

>rmdir /S %LOCALAPPDATA%\slackdump
C:\Users\hoken\AppData\Local\slackdump, Are you sure (Y/N)? y

mattermost 用のエクスポートデータを作る

執筆時の v2.2.0-alpha ではアルファ版ではあるものの、

> slackdump -export slack_2mattermost.zip -export-type mattermost -download

として mattermost 形式で出力できるようです。zip 出力を指定します。

詳細はドキュメント参照:
https://github.com/rusq/slackdump/blob/master/doc/usage-export.rst

Slack Log Viewer を使ってみる (MS-Windows)

ダウンロードしたログを閲覧してみます。

https://github.com/thayakawa-gh/SlackLogViewer/releases
から、Windows用ZIPファイルをダウンロード、解凍
image.png
image.png
https://docs.microsoft.com/ja-jp/cpp/windows/latest-supported-vc-redist?view=msvc-170
より、「Visual Studio 2015、2017、2019、および2022 のサポートされている最新の英語版 (en-us) Microsoft Visual C++ 再頒布可能パッケージ」をダウンロード、インストールします。

image.png

image.png

OpenでフォルダーとZipと両方選べるようです。

7
6
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
7
6