09:25:50.777 [info] Pruning objects older than 90 days, keeping non public posts, keeping threads intact, pruning orphaned activitiesRunning the forbidden task ;)
pleroma-pruned-db-winning.png
Signal feed
Post
Remote status
Context
2509:25:50.777 [info] Pruning objects older than 90 days, keeping non public posts, keeping threads intact, pruning orphaned activitiesRunning the forbidden task ;)
#!/bin/bash
to_delete=$1
batch_size=$2
do_delete () {
n=$1
out=$(psql -U pleroma -d pleroma -p 5435 -c "delete from activities where id in (select id from activities a where a.inserted_at < '2026-01-01'::date and not local and split_part('data->>object', '/', 3) != 'decayable.ink' limit $n)")
echo $out
}
i=$to_delete
while [[ $i -gt 0 ]]; do
a=$(do_delete $batch_size);
i=$((i-$batch_size))
deleted=$(($to_delete - $i))
pct=$(($deleted * 100 / $to_delete))
echo $(date --iso-8601="seconds") $pct $a
done
you probably need to adjust how psql is called, and obviously the date and the domain. The query is a little ugly in there but here it is formatted a little better:
delete from activities where id in (
select id from activities a
where
a.inserted_at < '2026-01-01'::date
and not local
and split_part(data->>'object', '/', 3) != 'decayable.ink'
limit 10000
)
The compound select is necessary to do this in batches, which keeps postgres flushing the deletes constantly instead of aggregating everything up and do one biiiiiig delete. As a bonus the script eats the output and gives you progress readouts. It's okay to go a little over the total number of rows you want to delete (you can count(*) the inner select in order to get the exact amount).
Replies
5We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect