@girish Yay! Thank you.
I am all new to this Linux game so I wasn't aware I could just set the environment variables like that.
For everyone else, this is what you need to do:
ββββββββββββββββββββββββββββββ
Set up S3 with Synapse. See my post here: https://forum.cloudron.io/post/60415
Create a database.yaml file in /app/data/configs that contains the postgres database credentials.
You can find those in the existing homeserver.yaml file.
user: xxx
password: xxx
database: xxx
host: postgresql
Create a script (e.g.,
s3cleanup.sh) with the following contents:
#!/bin/bash
cd /app/data/configs
export AWS_ACCESS_KEY_ID=[your S3 compatible access key]
export AWS_SECRET_ACCESS_KEY=[your s3 compatible secret access key]
/app/code/env/bin/s3_media_upload update /app/data/data/media_store 1m
/app/code/env/bin/s3_media_upload upload --delete --endpoint-url https://yours3storageendpoint.com /app/data/data/media_store [your s3_bucket_name]
Run the
s3cleanup.sh script.
It will look up media that hasn't been touched for 1m (= 1 month) or whatever you set above. It needs to be an integeger value, followed by either m = month(s), d = day(s) or y = year(s).
It will create a cache.db file that refers to the media that matches your criteria.
In the second step, it will upload all files from the cache.db to your s3 storage and delete the local copies.
The output looks like this:
Syncing files that haven't been accessed since: 2022-12-25 14:59:14.674154
Synced 603 new rows
100%|ββββββββββββββββββββββββββββββββββββ| 603/603 [00:00<00:00, 16121.24files/s]
Updated 0 as deleted
100%|ββββββββββββββββββββββββββββββββββββ| 603/603 [03:25<00:00, 2.93files/s]
Uploaded 603 media out of 603
Uploaded 3203 files
Uploaded 263.6M
Deleted 603 media
Deleted 3203 files
Deleted 263.6M
Edit: Added path /app/data/configs to script to make it work as cron job.
Edit2: Added more choices for duration suffixes in 's3_media_upload update' job.
Disclaimer: This is to the best of my knowledge and understanding. It worked for me, but I accept no liability for loss of data on your server caused by my incompetence. π