Readme
Slack to Matrix Migration
This project is a fork from https://github.com/Awesome-Technologies/slack-matrix-migration
Migrates Users, Channels and all the conversations from a Slack export to Matrix Warning: It’s not recommended to use anything but a fresh/empty Synapse instance for migration
However, you can configure it to import the Slack workspace to an empty federated server and use that to effectively migrate rooms to an existing Matrix server via federation. See ‘Federated setup (import to an existing Matrix server)’ below.
Why the Fork.
We need complete refactor directory project from Awesome-Technologies/slack-matrix-migration To ensure the next enhacements.
- pip to pipenv
- Docker
- logging
- python 3.9
- alive-progress
- better logging
- Env configuration and dot.env support
- Fix massive Invites for large Slack Teams.
- Multiarch
- linux/arm64/v8
- linux/amd64
- linux/arm/v7
Build And Push to docker registry
version=0.1.1
docker build \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg VCS_REF=$(git rev-parse --short HEAD) \
--tag sapian/slack-matrix-migration:latest \
--tag sapian/slack-matrix-migration:${version} \
--tag quay.io/sapian/slack-matrix-migration:latest \
--tag quay.io/sapian/slack-matrix-migration:${version} \
--build-arg VERSION=${version} .
build multiarch and push
version=0.1.1
docker buildx build --push \
--platform linux/arm64/v8,linux/amd64,linux/arm/v7 \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg VCS_REF=$(git rev-parse --short HEAD) \
--tag sapian/slack-matrix-migration:latest \
--tag quay.io/sapian/slack-matrix-migration:latest \
--tag sapian/slack-matrix-migration:${version} \
--tag quay.io/sapian/slack-matrix-migration:${version} .
Set developing enviroment
conda create -n slack-matrix-migration python=3.9
/opt/$USER/anaconda3/envs/slack-matrix-migration/bin/pip install pipenv
/opt/$USER/anaconda3/envs/slack-matrix-migration/bin/pipenv --python=/opt/$USER/anaconda3/envs/slack-matrix-migration/bin/python install
/opt/$USER/anaconda3/envs/slack-matrix-migration/bin/pipenv --python=/opt/$USER/anaconda3/envs/slack-matrix-migration/bin/python install --dev
Ipyhon
cd ~/Workspace/slack-matrix-migration/
conda activate slack-matrix-migration
/opt/$USER/anaconda3/envs/slack-matrix-migration/bin/pipenv run ipython
Activate Conda and Pipenv
cd ~/Workspace/slack-matrix-migration/
conda activate slack-matrix-migration
/opt/$USER/anaconda3/envs/slack-matrix-migration/bin/pipenv shell
Do migration
Prerequisites
- Set up a Synapse Homeserver
- Create an admin user on the Homeserver (make sure the username of the admin user does not match any existing slack user id)
- Copy
conf/matrix/migration_service.yaml
to somewhere reachable by your Homeserver - Replace the
as_token
andhs_token
in theconf/matrix/migration_service.yaml
with a random string - Add the Application Service to your
homeserver.yaml
:
app_service_config_files:
- /<path to the yaml file>/migration_service.yaml
- Restart Synapse
Notes:
- Make sure the migration script can access the
/_matrix/client
api and the/_synapse
admin api - Other Homeserver implementations may not support timestamped massaging, see https://matrix.org/docs/spec/application_service/r0.1.0#timestamp-massaging
- You may have to increase your homserver rate limits
Federated setup (import to an existing Matrix server)
The idea is to migrate Slack to a fresh/empty Synapse instance, that is federated with your existing Matrix homeserver. All imported Slack users will be kicked after the migration is done, leaving only the admin user in the migrated rooms. Invite any users from your existing Matrix homeserver to the rooms manually using the admin user.
You will need the following configuration:
# Set to 'True' to invite all users to all rooms
invite-all: True
# Set to 'True' to invite the admin user to all rooms
create-as-admin: True
# Set to 'True' to kick all imported users from imported rooms
kick-imported-users: True
# Set to 'True' to allow rooms to be joined from other homeservers
federate-rooms: True
# Append room and displayname suffixes
room-suffix: " (slack import)"
name-suffix: " (slack import)"
Running the migration
Set Enviroment variables
Fill de file .env
#LOG_LEVEL=DEBUG
LOG_LEVEL=INFO
ADMIN_USER_MATRIX = changeme
ADMIN_PASS_MATRIX = changeme
PYTHONWARNINGS="ignore:Unverified HTTPS request"
Local (see docker run)
- Set developing enviroment
- Activate Conda and Pipenv
- Get a zipped Export of your Slack Workspace (https://slack.com/help/articles/201658943) and put on
data/
- Copy
config/config_example.yaml
toconfig/config.yaml
and edit to your needs (use theas_token
from yourmigration_service.yaml
) - Run
python3 slack-matrix-migration/slack-matrix-migration/migrate.py
Cleanup
- Remove the Application Service from your
homeserver.yaml
- Delete the
migration_service.yaml
- Reset any increased rate limits
- Restart Synapse
Run in Docker
-
Get a zipped Export of your Slack Workspace (https://slack.com/help/articles/201658943) and put on
data/
-
Copy
config/config_example.yaml
toconfig/config.yaml
and edit to your needs (use theas_token
from yourmigration_service.yaml
) -
Run Docker
docker run --env-file .env -v $(pwd)/log:/usr/src/app/slack-matrix-migration/log -v $(pwd)/data:/usr/src/app/slack-matrix-migration/data -v $(pwd)/run:/usr/src/app/slack-matrix-migration/run -v $(pwd)/conf:/usr/src/app/slack-matrix-migration/conf --rm -it sapian/slack-matrix-migration:latest