Edit ‘infrastructure_and_operations/inventory/matrix’ by forest

Edit ‘infrastructure_and_operations/inventory/matrix’ (by forest at 24 Dec 25 00:33 UTC)

Hyphae affected: infrastructure_and_operations/inventory/matrix

diff --git a/infrastructure_and_operations/inventory/matrix.myco b/infrastructure_and_operations/inventory/matrix.myco
index 7ffc3c0..2816ac1 100644
--- a/infrastructure_and_operations/inventory/matrix.myco
+++ b/infrastructure_and_operations/inventory/matrix.myco
@@ -32,2 +32,3 @@ root@matrix:~#
* Backup info
+* how to set retention period on matrix rooms

@@ -198 +199,93 @@ This is helpful because it tells us where the matrix-synapse code is located (`/

+## Upgrade Procedures
+
+TODO
+
+## Backup info
+
+The entire VM including all the data is backed up via the normal capsul.org backup system
+
+Remote backup for the matrix server DB is configured by:
+```
+root@matrix:~# cat /etc/cron.daily/pgbackup
+#!/bin/sh
+
+/opt/postgres-backup/run-backup.sh 2>&1 >> /var/log/pgbackup.log
+```
+
+```
+root@matrix:~# cat /opt/postgres-backup/run-backup.sh
+#!/usr/bin/env bash
+
+set -o pipefail
+
+echo "pg-backup is starting up!"
+echo "this script is run by cron.daily"
+date
+
+cd /opt/postgres-backup
+sudo -u postgres pg_dump synapse | pv --interval 5 | zstd -fo "synapse.zst"
+
+backup_exitcode="$?"
+
+echo "pg_dump | pv | zstd -fo 'synapse.zst' exited with status code $backup_exitcode"
+date
+
+if [[ $backup_exitcode -eq 0 ]]; then
+ set -e
+ echo "transferring backup offsite.."
+ rsync --whole-file --recursive --delete-after --progress --stats --human-readable \
+ -e "ssh -p 2022 -i /opt/postgres-backup/id_ed25519 -o UserKnownHostsFile=/opt/postgres-backup/known_hosts -o IdentitiesOnly=yes" \
+ /opt/postgres-backup/synapse.zst backups@layerze.ro:/tank/backups/postgres/synapse.zst
+ date
+ echo "running prom-collect..."
+ prom-collect postgresql_backup
+ echo "success!"
+fi
+```
+
+
+
+## how to set retention period on matrix rooms
+
+SEE: https://github.com/matrix-org/matrix-spec-proposals/blob/matthew/msc1763/proposals/1763-configurable-retention-periods.md
+
+TBH i'm struggling a bit to set the retention in an automated fashion at all. We don't have a tool for it and it requires having admin in the room.
+The best I was able to figure out so far
+
+ 1. go to the cyberia space with the network tab of the dev tools open
+
+ 2. look for the _matrix/client/v1/rooms/!XJhdXteYnRMldzWFyX%3Acyberia.club/hierarchy?suggested_only=true&max_depth=1&limit=20 GET request and copy its json response
+
+ 3. extract the room ids with `jq`
+ 4. ssh into the matrix server and run `./reset-password ed-209:cyberia.club`
+ 5. log in as ed-209
+ 6. go to a room then type `/devtools` to open the devtools, and make sure the browser network tab is open
+ 7. send a custom room state event with event type m.room.retention and body `{"max_lifetime":86400000000}`
+ 8. find the `PUT _matrix/client/r0/rooms/!roqAKCndauLBfhLdGs%3Acyberia.club/state/m.room.retention/` request in the network tab and right click -> copy as curl
+ 9. write a script that runs this curl command for every room ID that you collected
+
+```
+(()=>{
+
+ const list = `!JFYMcOkcWtccikJlkA%3Acyberia.club
+!SfvWHaBPcmgzTWdvZB%3Acyberia.club
+!hYrELkZnhpqlzZoQZZ%3Acyberia.club
+blahbalahblahbah....`.split("\n");
+
+const space = `
+
+
+`;
+ console.log(space +
+ list.map(roomid => {
+ return `curl 'https://matrix.cyberia.club/_matrix/client/r0/rooms/${roomid}/state/m.room.retention/' -X PUT AUTH HEADER GOES HERE!!! --data-raw '{"max_lifetime":86400000000}'`
+ }).join('\n\n\n')+space);
+
+})()
+
+```
+
+so far its been slightly hit and miss but I'll check a few rooms and make sure it at least appears to have worked
+
+( you can check a room by typing `/devtools` in the message box and then going to the explore room state section, there should be an entry for m.room.retention )