Question Backup old mailbox to S3 and clear space

williamplk

Basic Pleskian
Server operating system version
Ubuntu 22.04.5 LTS
Plesk version and microupdate number
Plesk Obsidian 18.0.73 Update #5
Hi,

My users use IMAP and my server now 1T storage for mailbox on server, are there any method can I backup all user IMAP mailbox older then 1 year to S3 for cost saving?

Ex: Backup IMAP mailbox oder than 1 year to S3 then auto remove that successful backup mailbox file for space saving then if user need older data we can individual restore to the main mailbox.
 
There isn't any feature available in Plesk that archives and backups only old email messages. You'll have to create your own solution for that.

For example, what you could consider doing, is to
1) Configure S3 remote store for Plesk backups.
2) Configure a scheduled backup in Plesk to run monthly to only backup Mail Message to the S3 remote storage.
3) Create a custom Bash script that deletes all messages older than one year. For example:
Bash:
#!/bin/bash

for i in $(/usr/local/psa/bin/mail -l | sed '/^Alias/d' | tr '\t' ' ' | cut -d' ' -f 3-); do
    # Empty (expunge) message from inbox that are >= 1 old
    doveadm expunge -u "$i" mailbox INBOX after 365d

    # Empty (expunge) message from the Sent folder that are >= 1 year old
    doveadm expunge -u "$i" mailbox INBOX.Sent after 365d
done
4) Create a cronjob (Scheduled Task) to run the custom Bash script once a month after the backup has run.

A few things to be aware of when using this route:
  • This creates a lot of overhead, as each backup contains all current email messages too. So you need a lot of S3 storage, which will probably be expensive.
  • If for some reason the monthly backup fails, the messages will still be deleted and are lost if you have no other backup.
 
Back
Top