Skip to content

Instantly share code, notes, and snippets.

@DartPower
Created June 4, 2025 11:24
Show Gist options
  • Save DartPower/557ae65c581538e927eea1a958f022b0 to your computer and use it in GitHub Desktop.
Save DartPower/557ae65c581538e927eea1a958f022b0 to your computer and use it in GitHub Desktop.
Скрипт для чистки всех писем от начала времен до определенной даты Dovecot
doveadm expunge -A mailbox '*' savedbefore 2024-01-01
TOUCH_TS=$(date -d "2023-12-31 23:59:59" +%Y%m%d%H%M.%S)
touch -t $TOUCH_TS /tmp/timestamp_ref
cd /var/www/www-root/data/email/company.name
find . -type f -path "*/.maildir/*" \( -name "*,*" -o -name "*,*:2,*" \) ! -newer /tmp/timestamp_ref -delete
find . -name "dovecot.index*" -exec rm {} \;
doveadm force-resync -A '*'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment