Discussion:
Dovecot domain quota
Filip Bartmann
2014-10-12 17:28:06 UTC
Permalink
I have dovecot version 2.1.7 and I have quota configured as:
-----------------------------------
dict {
quota_domain = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
}
mail_plugins = quota
protocol imap {
mail_plugins = quota quota imap_quota
}
plugin {
quota = dict:domain:%d:proxy::quota_domain
quota_rule = *:storage=1M
quota_rule2 = Trash:storage=+100M
}
-----------------------------------
/etc/dovecot/dovecot-dict-sql.conf.ext:
-----------------------------------
map {
pattern = priv/quota/storage
table = quota_dict
username_field = domain
value_field = bytes
}
map {
pattern = priv/quota/messages
table = quota_dict
username_field = domain
value_field = messages
}
map {
pattern = shared/expire/$user/$mailbox
table = expires
value_field = expire_stamp
fields {
username = $user
mailbox = $mailbox
}
}
-----------------------------------
But the problem is that quota table created as:
-----------------------------------
CREATE TABLE `quota_dict` (
`domain` varchar(255) NOT NULL,
`bytes` bigint(20) NOT NULL DEFAULT '0',
`messages` int(5) NOT NULL DEFAULT '0',
PRIMARY KEY (`domain`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
-----------------------------------
counts quota only for last user as defined /etc/dovecot/users or in database table.
So if I have in /etc/dovecot/users (the contents is from testing VPS):
-----------------------------------
test at debian.jd:{plain}radegast:8:8::/srv/mail/debian.jd/::userdb_quota_rule=*:storage=500k
bartmann at debian.jd:{plain}radegast:8:8::/srv/mail/debian.jd/::userdb_quota_rule=*:storage=500k
-----------------------------------
After running `doveadm quota recalc -A` I have in my db:
-----------------------------------
+-----------+--------+----------+
| domain | bytes | messages |
+-----------+--------+----------+
| debian.jd | 505758 | 81 |
+-----------+--------+----------+
-----------------------------------
whith is from account bartmann at debian.jd not both accounts at testing VPS domain debian.jd. The same is with quota enforcing - quota if enforced on the latter of the accounts in /etc/dovecot/users on testing machine or database in production machine.

What I do wrong?
Thanks
Filip Bartmann
Robert Schetterer
2014-10-12 19:35:15 UTC
Permalink
Post by Filip Bartmann
-----------------------------------
dict {
quota_domain = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
}
mail_plugins = quota
protocol imap {
mail_plugins = quota quota imap_quota
}
plugin {
quota = dict:domain:%d:proxy::quota_domain
quota_rule = *:storage=1M
quota_rule2 = Trash:storage=+100M
}
-----------------------------------
-----------------------------------
map {
pattern = priv/quota/storage
table = quota_dict
username_field = domain
value_field = bytes
}
map {
pattern = priv/quota/messages
table = quota_dict
username_field = domain
value_field = messages
}
map {
pattern = shared/expire/$user/$mailbox
table = expires
value_field = expire_stamp
fields {
username = $user
mailbox = $mailbox
}
}
-----------------------------------
-----------------------------------
CREATE TABLE `quota_dict` (
`domain` varchar(255) NOT NULL,
`bytes` bigint(20) NOT NULL DEFAULT '0',
`messages` int(5) NOT NULL DEFAULT '0',
PRIMARY KEY (`domain`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
-----------------------------------
counts quota only for last user as defined /etc/dovecot/users or in database table.
-----------------------------------
test at debian.jd:{plain}radegast:8:8::/srv/mail/debian.jd/::userdb_quota_rule=*:storage=500k
bartmann at debian.jd:{plain}radegast:8:8::/srv/mail/debian.jd/::userdb_quota_rule=*:storage=500k
-----------------------------------
-----------------------------------
+-----------+--------+----------+
| domain | bytes | messages |
+-----------+--------+----------+
| debian.jd | 505758 | 81 |
+-----------+--------+----------+
-----------------------------------
whith is from account bartmann at debian.jd not both accounts at testing VPS domain debian.jd. The same is with quota enforcing - quota if enforced on the latter of the accounts in /etc/dovecot/users on testing machine or database in production machine.
What I do wrong?
Thanks
Filip Bartmann
domain quota may be tricky

never tested but perhaps reread

http://serverstutorial.wordpress.com/2012/12/28/configuring-domain-user-mailbox-quotas-in-dovecot-via-postfixadmin-on-ubuntu-12-04lts/

http://wiki2.dovecot.org/Quota/Configuration

Best Regards
MfG Robert Schetterer
--
[*] sys4 AG

http://sys4.de, +49 (89) 30 90 46 64
Franziskanerstra?e 15, 81669 M?nchen

Sitz der Gesellschaft: M?nchen, Amtsgericht M?nchen: HRB 199263
Vorstand: Patrick Ben Koetter, Marc Schiffbauer
Aufsichtsratsvorsitzender: Florian Kirstein
Gedalya
2014-10-12 22:08:03 UTC
Permalink
Post by Filip Bartmann
-----------------------------------
+-----------+--------+----------+
| domain | bytes | messages |
+-----------+--------+----------+
| debian.jd | 505758 | 81 |
+-----------+--------+----------+
-----------------------------------
whith is from accountbartmann at debian.jd not both accounts at testing VPS domain debian.jd. The same is with quota enforcing - quota if enforced on the latter of the accounts in /etc/dovecot/users on testing machine or database in production machine.
What I do wrong?
As I remember from previous conversations here, this is a limitation of
the current design.
The comment in example-config/conf.d/90-quota.conf says:
# Multiple quota roots are also possible, for example this gives each user
# their own 100MB quota and one shared 1GB quota within the domain
It doesn't really support accounting for the *sum* of *multiple storage
quotas* within a domain.
As a hack: you can just not run quota recalc ;-) or more realistically,
separately track user quotas individually (you really should!), and post
recalc immediately update the domain by running something like
update domain_quota set bytes=(select sum(bytes) from user_quota where
username like '%@debian.jd') where domain='debian.jd';
Jiri Bourek
2014-10-13 08:47:56 UTC
Permalink
Post by Gedalya
Post by Filip Bartmann
-----------------------------------
+-----------+--------+----------+
| domain | bytes | messages |
+-----------+--------+----------+
| debian.jd | 505758 | 81 |
+-----------+--------+----------+
-----------------------------------
whith is from accountbartmann at debian.jd not both accounts at testing
VPS domain debian.jd. The same is with quota enforcing - quota if
enforced on the latter of the accounts in /etc/dovecot/users on
testing machine or database in production machine.
What I do wrong?
As I remember from previous conversations here, this is a limitation of
the current design.
I remember the same thing.
Post by Gedalya
As a hack: you can just not run quota recalc ;-) or more realistically,
separately track user quotas individually (you really should!), and post
recalc immediately update the domain by running something like
update domain_quota set bytes=(select sum(bytes) from user_quota where
This won't accout for changes made during the recalc - although to my
knowledge it's still the best solution in this type of configuration.

When I was trying to make both user and domain quotas work properly, the
only way I figured out was to track domain quota as group quota in the
filesystem. Forcing users/domains to have separate system user and group
of course.
Gedalya
2014-10-13 09:11:03 UTC
Permalink
Post by Jiri Bourek
Post by Gedalya
As a hack: you can just not run quota recalc ;-) or more realistically,
separately track user quotas individually (you really should!), and post
recalc immediately update the domain by running something like
update domain_quota set bytes=(select sum(bytes) from user_quota where
This won't accout for changes made during the recalc - although to my
knowledge it's still the best solution in this type of configuration.
We're talking about making the domain quota equal to the sum of the user
quotas, using a single SQL statement. After execution of this statement,
the domain quota will be correct, assuming that the user quotas are
correct. If recalc doesn't account for changes done during the recalc,
then that's a bug.
Jiri Bourek
2014-10-13 11:49:00 UTC
Permalink
Post by Gedalya
Post by Jiri Bourek
Post by Gedalya
As a hack: you can just not run quota recalc ;-) or more realistically,
separately track user quotas individually (you really should!), and post
recalc immediately update the domain by running something like
update domain_quota set bytes=(select sum(bytes) from user_quota where
This won't accout for changes made during the recalc - although to my
knowledge it's still the best solution in this type of configuration.
We're talking about making the domain quota equal to the sum of the user
quotas, using a single SQL statement. After execution of this statement,
the domain quota will be correct, assuming that the user quotas are
correct. If recalc doesn't account for changes done during the recalc,
then that's a bug.
Well if I understand OP's configuration correctly, his Dovecot is not
using per-user quotas, which means that when recalc finishes for a
mailbox, nothing is updating information about that mailbox. I don't
think that's a bug in recalc, just defficiency in OP's setup.

Although after reading your post again I now understood you suggested to
add per-user quotas into his Dovecot's config too. My bad, that could work.
Loading...