1 (edited by das654rbc 2024-12-22 00:32:00)

Topic: iRedMail periodic archive plan

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 1.7.1
- Deployed with iRedMail Easy or the downloadable installer? installer
- Linux/BSD distribution name and version: Ubuntu 24.04
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): PGSQL
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro?
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Dear colleagues!
Please give me advice on backup of the iRedMail mail server.
The server is hosted at VPS with a 250GB disk. Stored emails: ~180000, ~150GB total. It serves 2 domains, with few mail users (~10 at each domain).
PostgreSQL database, Nginx+SOGO.

I plan to buy additional data storage at the same hoster and once a week make mostly full backup of needed databases and /var/vmail/vmail1 srorage.
If I accidently loose my server, I plan to reinstall it and restore data from external storage, I suppose week age of archive will fit.
Hoster offers sftp (and rsync?) access to external storage.

1. What are the necessary objects of backup?
- ~/iRedMail-1.7.1/config   (contains passwords, hashes of passwords, settings needed for new install of iRedMail)
- PGSQL databases (maybe using original script /var/vmail/backup/backup_pgsql.sh):
  vmail amavisd iredadmin sogo iredapd
- mail storage: /var/vmail/vmail1
- ...something else?
2. What is the best mechanism of backup?
- mount storage to iRedMail filesystem (/mnt/backup/) using sshfs command
  and then make tar - archive like:
  tar -czvf /mnt/backup/vmail.tar.gz /var/vmail/vmail1
- use rsync instead?
I am afraid of overquoting iRedMail storage, since mail is ~150GB, and free space is ~100GB - mwybe some temporary files will full storage of iRedMail file system?
3. I plan to make live-backup (not stopping services) - is this safe?
loss of few messages is not critical )

Thank you for any advice, and welcome to post some examples, if you please.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: iRedMail periodic archive plan

das654rbc wrote:

1. What are the necessary objects of backup?

- Dumped SQL databases. Application data are mostly stored in SQL, but not all.
- Whole mailboxes (/var/vmail/vmail1/ by default).
- Application data under /var/vmail/. Note: some applications may have data under other directories.
- Application config files.

2: You can try rsync + ssh. no need to create a temporary file on mail server before transfer.
3: it's ok to do "live-backup".

3 (edited by das654rbc 2024-12-26 00:49:53)

Re: iRedMail periodic archive plan

Thank you, ZhangHuangbin
I see no application data under /var/mail (maybe I dont have such)
Yes, I concider both rsync and tar options, thank you.

Found sogo-tool and SOGO restoration script at https://wiki.sogo.nu/backupRestore
It is better to backup DKIM key as well.
live-backup is ok - great!!

But I could not find any guide concerning restoration of postgresql databases, seems my knowledge is poor to figure this out ((  need help!

Well, this works:

user@ubnt:~/Backup/111/25$ sudo su postgres
[sudo] password for user:
postgres@ubnt:/home/user/Backup$ psql amavisd  < amavisd-2024-12-25-03-01-01.sql

databases restored: amavisd, iredadmin, sogo, iredapd, vmail.

Wow, after sql databases imported, and two mailboxes data (with few emeils) were transferred, almost everything looks fine:
- SOGO webmail shows imported emails
- iredadmin shows both domains and all its users
- all users can access their mailboxes by webmail (SOGO) and imap (dovecot)
- after first login by webmail or imap client, maildir is created in /var/vmail/vmail1

Only few moments are not clear:
iredadmin and SOGO shows incorrect amount of emails and disk usage (mailboxes with not_transferred maildata show "old" data - tons of emails and GBytes)
When these numbers are recalculated?

.. now i should use crontab -e   to plan a shedulled backup

4

Re: iRedMail periodic archive plan

das654rbc wrote:

I see no application data under /var/mail (maybe I dont have such)

It's /var/vmail/.

5 (edited by das654rbc 2024-12-26 18:52:00)

Re: iRedMail periodic archive plan

Thank you. Found no significant there, except of backup folder (sure to mind it)

I still wonder, what daemon and which event corrects vmail database?

Sending/receiving emails by webmail ir imap do not correct bytes, messages and used_quota fields..

...
Found your message (13 years gone, yeah..)  https://forum.iredmail.org/post9419.html#p9419

Dict quota is recalculated only if the quota goes below zero (v1.0.rc30+ only).
For example:
mysql> UPDATE mailbox SET bytes=-1,messages=-1 WHERE username='user@domain.ltd';

What is the syntax with postgresql backend?

6

Re: iRedMail periodic archive plan

doveadm quota recalc -A

this should do the trick

7

Re: iRedMail periodic archive plan

Thank you, Cthulhu!
This works!
Need to read more on doveadm ))