forked-synapse/docs/usage/administration/database_maintenance_tools.md
Shay 84dc50e160
Port wiki pages to documentation website (#11402)
* move wiki pages to synapse/docs and add a few titles where necessary

* update SUMMARY.md with added pages

* add changelog

* move incorrectly located newsfragment

* update changelog number

* snake case added files and update summary.md accordingly

* update issue/pr links

* update relative links to docs

* update changelog to indicate that we moved wiki pages to the docs and state reasoning

* revert unintentional change to CHANGES.md

* add link

Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>

* Update CHANGES.md

Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>

Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
2021-12-01 10:12:19 -08:00

2.4 KiB

This blog post by Victor Berger explains how to use many of the tools listed on this page: https://levans.fr/shrink-synapse-database.html

List of useful tools and scripts for maintenance Synapse database:

Purge Remote Media API

The purge remote media API allows server admins to purge old cached remote media.

Purge local media

There is no purge API for local media because you may be the only one with a copy. If you are sure you want to delete local media you could use something like the following to delete media that hasn't been accessed in a while.

find /path/to/synapse/media_store/local_content -atime +365 -delete
find /path/to/synapse/media_store/local_thumbnails -atime +365 -delete

This will delete media that hasn't been accessed in 365 days.

Warning, check noatime flag: You also have to double-check that the filesystem where synapse's media store don't have noatime flag. Check it with mount, noatime is something that is usually enabled by default to reduce read-write operations in the filesystem for a feature is not so demanded.

Purge History API

The purge history API allows server admins to purge historic events from their database, reclaiming disk space.

synapse_janitor.sql

Cleans a synapse Postgres database of deleted messages and abandoned rooms.

synapse-compress-state

Tool for compressing (deduplicating) state_groups_state table.

SQL for analyzing Synapse PostgreSQL database stats

Some easy SQL that reports useful stat about Matrix Synapse database.