mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2025-09-19 04:18:46 +02:00
.config
.github
LICENSES
bin
collections
docs
assets
README.md
alternative-architectures.md
ansible.md
configuring-captcha.md
configuring-dns.md
configuring-playbook-alertmanager-receiver.md
configuring-playbook-appservice-double-puppet.md
configuring-playbook-appservice-draupnir-for-all.md
configuring-playbook-backup-borg.md
configuring-playbook-base-domain-serving.md
configuring-playbook-bot-baibot.md
configuring-playbook-bot-buscarron.md
configuring-playbook-bot-chatgpt.md
configuring-playbook-bot-draupnir.md
configuring-playbook-bot-go-neb.md
configuring-playbook-bot-honoroit.md
configuring-playbook-bot-matrix-registration-bot.md
configuring-playbook-bot-matrix-reminder-bot.md
configuring-playbook-bot-maubot.md
configuring-playbook-bot-mjolnir.md
configuring-playbook-bridge-appservice-discord.md
configuring-playbook-bridge-appservice-irc.md
configuring-playbook-bridge-appservice-kakaotalk.md
configuring-playbook-bridge-appservice-slack.md
configuring-playbook-bridge-appservice-webhooks.md
configuring-playbook-bridge-beeper-linkedin.md
configuring-playbook-bridge-go-skype-bridge.md
configuring-playbook-bridge-heisenbridge.md
configuring-playbook-bridge-hookshot.md
configuring-playbook-bridge-matrix-bridge-sms.md
configuring-playbook-bridge-mautrix-bridges.md
configuring-playbook-bridge-mautrix-discord.md
configuring-playbook-bridge-mautrix-facebook.md
configuring-playbook-bridge-mautrix-gmessages.md
configuring-playbook-bridge-mautrix-googlechat.md
configuring-playbook-bridge-mautrix-hangouts.md
configuring-playbook-bridge-mautrix-instagram.md
configuring-playbook-bridge-mautrix-meta-instagram.md
configuring-playbook-bridge-mautrix-meta-messenger.md
configuring-playbook-bridge-mautrix-signal.md
configuring-playbook-bridge-mautrix-slack.md
configuring-playbook-bridge-mautrix-telegram.md
configuring-playbook-bridge-mautrix-twitter.md
configuring-playbook-bridge-mautrix-whatsapp.md
configuring-playbook-bridge-mautrix-wsproxy.md
configuring-playbook-bridge-mx-puppet-discord.md
configuring-playbook-bridge-mx-puppet-groupme.md
configuring-playbook-bridge-mx-puppet-instagram.md
configuring-playbook-bridge-mx-puppet-skype.md
configuring-playbook-bridge-mx-puppet-slack.md
configuring-playbook-bridge-mx-puppet-steam.md
configuring-playbook-bridge-mx-puppet-twitter.md
configuring-playbook-bridge-postmoogle.md
configuring-playbook-bridge-wechat.md
configuring-playbook-cactus-comments.md
configuring-playbook-client-cinny.md
configuring-playbook-client-element-web.md
configuring-playbook-client-hydrogen.md
configuring-playbook-client-schildichat-web.md
configuring-playbook-conduit.md
configuring-playbook-dendrite.md
configuring-playbook-dimension.md
configuring-playbook-dynamic-dns.md
configuring-playbook-email.md
configuring-playbook-email2matrix.md
configuring-playbook-etherpad.md
configuring-playbook-external-postgres.md
configuring-playbook-federation.md
configuring-playbook-jitsi.md
configuring-playbook-ldap-auth.md
configuring-playbook-ma1sd.md
configuring-playbook-matrix-authentication-service.md
configuring-playbook-matrix-corporal.md
configuring-playbook-matrix-ldap-registration-proxy.md
configuring-playbook-matrix-media-repo.md
configuring-playbook-matrix-registration.md
configuring-playbook-nginx.md
configuring-playbook-ntfy.md
configuring-playbook-own-webserver.md
configuring-playbook-pantalaimon.md
configuring-playbook-postgres-backup.md
configuring-playbook-prometheus-grafana.md
configuring-playbook-prometheus-nginxlog.md
configuring-playbook-prometheus-postgres.md
configuring-playbook-rageshake.md
configuring-playbook-rest-auth.md
configuring-playbook-riot-web.md
configuring-playbook-s3-goofys.md
configuring-playbook-s3.md
configuring-playbook-shared-secret-auth.md
configuring-playbook-sliding-sync-proxy.md
configuring-playbook-ssl-certificates.md
configuring-playbook-sygnal.md
configuring-playbook-synapse-admin.md
configuring-playbook-synapse-auto-accept-invite.md
configuring-playbook-synapse-auto-compressor.md
configuring-playbook-synapse-s3-storage-provider.md
configuring-playbook-synapse-simple-antispam.md
configuring-playbook-synapse-usage-exporter.md
configuring-playbook-synapse.md
configuring-playbook-telemetry.md
configuring-playbook-traefik.md
configuring-playbook-turn.md
configuring-playbook-user-verification-service.md
configuring-playbook.md
configuring-well-known.md
container-images.md
faq.md
getting-the-playbook.md
howto-server-delegation.md
howto-srv-server-delegation.md
importing-postgres.md
importing-synapse-media-store.md
importing-synapse-sqlite.md
installing.md
just.md
maintenance-and-troubleshooting.md
maintenance-checking-services.md
maintenance-migrating.md
maintenance-postgres.md
maintenance-synapse.md
maintenance-upgrading-services.md
obtaining-access-tokens.md
playbook-tags.md
prerequisites.md
quick-start.md
registering-users.md
self-building.md
uninstalling.md
updating-users-passwords.md
examples
group_vars
i18n
roles
.editorconfig
.envrc
.gitattributes
.gitignore
.yamllint
CHANGELOG.md
LICENSE
Makefile
README.md
YEAR-IN-REVIEW.md
ansible.cfg
conf.py
flake.lock
flake.nix
jitsi_jvb.yml
justfile
requirements.yml
reuse.toml
setup.yml
127 lines
5.9 KiB
Markdown
127 lines
5.9 KiB
Markdown
# Storing Matrix media files on Amazon S3 with Goofys (optional)
|
|
|
|
If you'd like to store Synapse's content repository (`media_store`) files on Amazon S3 (or other S3-compatible service), you can let this playbook configure [Goofys](https://github.com/kahing/goofys) for you.
|
|
|
|
Another (and better performing) way to use S3 storage with Synapse is [synapse-s3-storage-provider](configuring-playbook-synapse-s3-storage-provider.md).
|
|
|
|
Using a Goofys-backed media store works, but performance may not be ideal. If possible, try to use a region which is close to your Matrix server.
|
|
|
|
If you'd like to move your locally-stored media store data to Amazon S3 (or another S3-compatible object store), we also provide some migration instructions below.
|
|
|
|
## Adjusting the playbook configuration
|
|
|
|
After [creating the S3 bucket and configuring it](configuring-playbook-s3.md#bucket-creation-and-security-configuration), add the following configuration to your `inventory/host_vars/matrix.example.com/vars.yml` file (adapt to your needs):
|
|
|
|
```yaml
|
|
matrix_s3_media_store_enabled: true
|
|
matrix_s3_media_store_bucket_name: "your-bucket-name"
|
|
matrix_s3_media_store_aws_access_key: "access-key-goes-here"
|
|
matrix_s3_media_store_aws_secret_key: "secret-key-goes-here"
|
|
matrix_s3_media_store_region: "eu-central-1"
|
|
```
|
|
|
|
You can use any S3-compatible object store by **additionally** configuring these variables:
|
|
|
|
```yaml
|
|
matrix_s3_media_store_custom_endpoint_enabled: true
|
|
matrix_s3_media_store_custom_endpoint: "https://your-custom-endpoint"
|
|
```
|
|
|
|
If you have local media store files and wish to migrate to Backblaze B2 subsequently, follow our [migration guide to Backblaze B2](#migrating-to-backblaze-b2) below instead of applying this configuration as-is.
|
|
|
|
## Migrating from local filesystem storage to S3
|
|
|
|
It's a good idea to [make a complete server backup](faq.md#how-do-i-back-up-the-data-on-my-server) before migrating your local media store to an S3-backed one.
|
|
|
|
After making the backup, follow one of the guides below for a migration path from a locally-stored media store to one stored on S3-compatible storage:
|
|
|
|
- [Migrating to any S3-compatible storage (universal, but likely slow)](#migrating-to-any-s3-compatible-storage-universal-but-likely-slow)
|
|
- [Migrating to Backblaze B2](#migrating-to-backblaze-b2)
|
|
|
|
### Migrating to any S3-compatible storage (universal, but likely slow)
|
|
|
|
1. Proceed with the steps below without stopping Matrix services
|
|
|
|
2. Start by adding the base S3 configuration in your `vars.yml` file (seen above, may be different depending on the S3 provider of your choice)
|
|
|
|
3. In addition to the base configuration you see above, add this to your `vars.yml` file:
|
|
|
|
```yaml
|
|
matrix_s3_media_store_path: /matrix/s3-media-store
|
|
```
|
|
|
|
This enables S3 support, but mounts the S3 storage bucket to `/matrix/s3-media-store` without hooking it to your homeserver yet. Your homeserver will still continue using your local filesystem for its media store.
|
|
|
|
4. Run the playbook to apply the changes: `ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,start`
|
|
|
|
5. Do an **initial sync of your files** by running this **on the server** (it may take a very long time):
|
|
|
|
```sh
|
|
sudo -u matrix -- rsync --size-only --ignore-existing -avr /matrix/synapse/storage/media-store/. /matrix/s3-media-store/.
|
|
```
|
|
|
|
You may need to install `rsync` manually.
|
|
|
|
6. Stop all Matrix services (`ansible-playbook -i inventory/hosts setup.yml --tags=stop`)
|
|
|
|
7. Start the S3 service by running this **on the server**: `systemctl start matrix-goofys`
|
|
|
|
8. Sync the files again by re-running the `rsync` command you see in step #5
|
|
|
|
9. Stop the S3 service by running this **on the server**: `systemctl stop matrix-goofys`
|
|
|
|
10. Get the old media store out of the way by running this command on the server:
|
|
|
|
```sh
|
|
mv /matrix/synapse/storage/media-store /matrix/synapse/storage/media-store-local-backup
|
|
```
|
|
|
|
11. Remove the `matrix_s3_media_store_path` configuration from your `vars.yml` file (undoing step #3 above)
|
|
|
|
12. Run the playbook: `ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,start`
|
|
|
|
13. You're done! Verify that loading existing (old) media files works and that you can upload new ones.
|
|
|
|
14. When confident that it all works, get rid of the local media store directory: `rm -rf /matrix/synapse/storage/media-store-local-backup`
|
|
|
|
### Migrating to Backblaze B2
|
|
|
|
1. While all Matrix services are running, run the following command on the server:
|
|
|
|
(you need to adjust the 3 `--env` line below with your own data)
|
|
|
|
```sh
|
|
docker run -it --rm -w /work \
|
|
--env='B2_KEY_ID=YOUR_KEY_GOES_HERE' \
|
|
--env='B2_KEY_SECRET=YOUR_SECRET_GOES_HERE' \
|
|
--env='B2_BUCKET_NAME=YOUR_BUCKET_NAME_GOES_HERE' \
|
|
--mount type=bind,src=/matrix/synapse/storage/media-store,dst=/work,ro \
|
|
--entrypoint=/bin/sh \
|
|
docker.io/tianon/backblaze-b2:3.6.0 \
|
|
-c 'b2 authorize-account $B2_KEY_ID $B2_KEY_SECRET && b2 sync /work b2://$B2_BUCKET_NAME --skipNewer'
|
|
```
|
|
|
|
This is some initial file sync, which may take a very long time.
|
|
|
|
2. Stop all Matrix services (`ansible-playbook -i inventory/hosts setup.yml --tags=stop`)
|
|
|
|
3. Run the command from step #1 again.
|
|
|
|
Doing this will sync any new files that may have been created locally in the meantime.
|
|
|
|
Now that Matrix services aren't running, we're sure to get Backblaze B2 and your local media store fully in sync.
|
|
|
|
4. Get the old media store out of the way by running this command on the server:
|
|
|
|
```sh
|
|
mv /matrix/synapse/storage/media-store /matrix/synapse/storage/media-store-local-backup
|
|
```
|
|
|
|
5. Put the [Backblaze B2 settings](configuring-playbook-s3.md#backblaze-b2) in your `vars.yml` file
|
|
|
|
6. Run the playbook: `ansible-playbook -i inventory/hosts setup.yml --tags=setup-all,start`
|
|
|
|
7. You're done! Verify that loading existing (old) media files works and that you can upload new ones.
|
|
|
|
8. When confident that it all works, get rid of the local media store directory: `rm -rf /matrix/synapse/storage/media-store-local-backup`
|