I just set up pg_repack on this instance.

I’m using the basic postgresql 14 that comes with my distro, so I was able to install postgresql using apt

apt install postgresql-14-repack

Then I had to hop into the postgres user:

sudo -u postgres bash

Next, I had to add the pg_repack extension to my database:

psql -c "CREATE EXTENSION pg_repack" -d lemmy

Finally, I was able to run pg_repack:

pg_repack -a

I don’t have a very large database at this point so it didn’t take much time. You do need to be aware that you need enough space left on your device to make a complete copy of your database because I think it actually does that.

Next, you can put it in your crontab to run routinely:

crontab -e

I like to run it weekly, but ymmv.