<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Musings of an Apple Systems Administrator &#187; dovecot</title>
	<atom:link href="http://www.jonsblog.org/tag/dovecot/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jonsblog.org</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 11 Jan 2012 19:33:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Better Quota notifications for OSX Server</title>
		<link>http://www.jonsblog.org/2011/10/07/better-quota-notifications-for-osx-server/</link>
		<comments>http://www.jonsblog.org/2011/10/07/better-quota-notifications-for-osx-server/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 23:15:49 +0000</pubDate>
		<dc:creator>Jon Brown</dc:creator>
				<category><![CDATA[Mail Server]]></category>
		<category><![CDATA[OSX Server Configuration]]></category>
		<category><![CDATA[OSX System Administration]]></category>
		<category><![CDATA[bash script]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[quota]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.jonsblog.org/?p=418</guid>
		<description><![CDATA[OSX Server comes pre-packaged with Dovecot one of the best IMAP services out there and one of the most extensible and flexible in my opinion. That is its flexible and extensible as long as you know how to configure Dovecot which most OSX Server Administrators are not. I had a conversation with a co-worker not too long ago about being an OSX Server Administrator and I joked that Apple made great hardware and a great OS but most if not all of the services under the hood for Web, Mail, Mailing Lists, etc... were all borrowed open source technologies and that Apple really does not offer any sort of support base for the open source technologies that they use. However without these pieces of software their entire PR Campaign would hold no water. What I praise Apple for is taking these tools and utilizing them and making them easier to use while leaving the ability to tinker and improve these services.]]></description>
			<content:encoded><![CDATA[<p>OSX Server comes pre-packaged with Dovecot one of the best IMAP services out there and one of the most extensible and flexible in my opinion. That is its flexible and extensible as long as you know how to configure Dovecot which most OSX Server Administrators are not. I had a conversation with a co-worker not too long ago about being an OSX Server Administrator and I joked that Apple made great hardware and a great OS but most if not all of the services under the hood for Web, Mail, Mailing Lists, etc&#8230; were all borrowed open source technologies and that Apple really does not offer any sort of support base for the open source technologies that they use. However without these pieces of software their entire PR Campaign would hold no water. What I praise Apple for is taking these tools and utilizing them and making them easier to use while leaving the ability to tinker and improve these services.</p>
<p>One such service is the topic today, Dovecot. Dovecot is integrated with Server Admin, Apples GUI Server Administration tool. You can set two different kind of notifications to trigger here, a quota notification that will send an email out when someone is over a certain percentage of email quota and an email warning them when they have gone over quota. In my experience it takes more than a couple emails to make a user clean up their inbox.</p>
<p>What I wanted was a way to say, send out an email when a user goes over a specified limit and then send an email every ten percent they go over the original limit. When they reach ten percent before their quota is exceeded increase the email notification rate to one email every percent until they reach their quota and then at that time continue to send an email a day until their quota has been reduced. On top of that I wanted it to also notify me of people who have gone over quota so that I can prove to them that they did indeed get the notification. For me a good solution was having all quota notifications CC&#8217;d to our help desk which in turn opened a ticket on the behalf of the offender in a sense sending them two emails each time they went over quota. I am going to cover the necessary steps needed to accomplish this task on your OSX Mail server.<br />
<span id="more-418"></span><br />
** Note what we are about to do will mean that you will no longer be able to use Server Admin to manage email notifications.</p>
<h4>1. Locate the Dovecot Configuration file.</h4>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>dovecot.conf</pre></td></tr></table></div>

<h4>2. Edit the file</h4>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"> <span style="color: #c20cb9; font-weight: bold;">sudo</span> pico <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>dovecot.conf</pre></td></tr></table></div>

<h4>3. Find this line</h4>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"> quota_warning = <span style="color: #007800;">storage</span>=<span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>quota-exceeded.sh</pre></td></tr></table></div>

<p>we are going to modify this line and add the following lines.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">  quota_warning = <span style="color: #007800;">storage</span>=<span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>quota-exceeded.sh
  quota_warning2 = <span style="color: #007800;">storage</span>=<span style="color: #000000;">99</span><span style="color: #000000; font-weight: bold;">%%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>quota-exceeded.sh
  quota_warning3 = <span style="color: #007800;">storage</span>=<span style="color: #000000;">98</span><span style="color: #000000; font-weight: bold;">%%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>quota-exceeded.sh
  quota_warning4 = <span style="color: #007800;">storage</span>=<span style="color: #000000;">97</span><span style="color: #000000; font-weight: bold;">%%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>quota-exceeded.sh
  quota_warning5 = <span style="color: #007800;">storage</span>=<span style="color: #000000;">96</span><span style="color: #000000; font-weight: bold;">%%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>quota-exceeded.sh
  quota_warning6 = <span style="color: #007800;">storage</span>=<span style="color: #000000;">95</span><span style="color: #000000; font-weight: bold;">%%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>quota-exceeded.sh
  quota_warning7 = <span style="color: #007800;">storage</span>=<span style="color: #000000;">94</span><span style="color: #000000; font-weight: bold;">%%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>quota-exceeded.sh
  quota_warning8 = <span style="color: #007800;">storage</span>=<span style="color: #000000;">93</span><span style="color: #000000; font-weight: bold;">%%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>quota-exceeded.sh
  quota_warning9 = <span style="color: #007800;">storage</span>=<span style="color: #000000;">92</span><span style="color: #000000; font-weight: bold;">%%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>quota-exceeded.sh
  quota_warning10 = <span style="color: #007800;">storage</span>=<span style="color: #000000;">91</span><span style="color: #000000; font-weight: bold;">%%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>quota-exceeded.sh
  quota_warning11 = <span style="color: #007800;">storage</span>=<span style="color: #000000;">90</span><span style="color: #000000; font-weight: bold;">%%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>quota-exceeded.sh
  quota_warning12 = <span style="color: #007800;">storage</span>=<span style="color: #000000;">87</span><span style="color: #000000; font-weight: bold;">%%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>quota-warning.sh
  quota_warning13 = <span style="color: #007800;">storage</span>=<span style="color: #000000;">85</span><span style="color: #000000; font-weight: bold;">%%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>quota-warning.sh
  quota_warning14 = <span style="color: #007800;">storage</span>=<span style="color: #000000;">80</span><span style="color: #000000; font-weight: bold;">%%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>quota-warning.sh
  quota_warning15 = <span style="color: #007800;">storage</span>=<span style="color: #000000;">75</span><span style="color: #000000; font-weight: bold;">%%</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>quota-warning.sh</pre></td></tr></table></div>

<p>What we are saying here is that we are going to send out an email every time someone is over their limit. Here the limit is 75% and every 5% they go over they will get another warning until they get to 90% then the warnings become more frequent one every 1%. Not only that but there are two different messages the quota-warning and the quota-exceeded.</p>
<h4>4. We are going to create a new quota-warning.sh file</h4>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot
<span style="color: #c20cb9; font-weight: bold;">sudo</span> pico quota-warning.sh</pre></td></tr></table></div>

<p>This is the current default Apple script that triggers the default email created in Server Admin.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #007800;">_quota_txt</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>mail<span style="color: #000000; font-weight: bold;">/</span>quota_warning.txt
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-e</span> <span style="color: #007800;">$_quota_txt</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$_quota_txt</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>deliver <span style="color: #660033;">-d</span> <span style="color: #007800;">$USER</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

<p>We are going to modify this script to send out an email of our choice and to do so to another recipient so we have a record of users getting notifications.Here is the script that I wrote that does just that.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">PERCENT</span>=<span style="color: #007800;">$1</span>
<span style="color: #007800;">FROM_SMTP</span>=<span style="color: #ff0000;">&quot;support@somedomain.com&quot;</span>
<span style="color: #007800;">FROM</span>=<span style="color: #ff0000;">&quot;FWW Support &lt;support@somedomain.com&gt;&quot;</span>
<span style="color: #007800;">TO</span>=<span style="color: #ff0000;">&quot;FWW Support &lt;mail-server-admini@somedomain.com&gt;&quot;</span>
<span style="color: #007800;">qwf</span>=<span style="color: #ff0000;">&quot;/tmp/quota.warning.$$&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;From: <span style="color: #007800;">$FROM</span>
To: <span style="color: #007800;">$USER</span>
Subject: Quota Notification
Content-Type: text/plain; charset=&quot;</span>UTF-<span style="color: #000000;">8</span><span style="color: #ff0000;">&quot;
&nbsp;
Hello-
This is a warning email that was automatically sent. You are nearing your quota limit. The current quota is 1 GB of storage space per user. However you can store more offline.
&nbsp;
Q: What can I do now?
&nbsp;
A: Start backing up your emails and storing them in a folder under the On My Mac heading, this will ensure that your emails will still be stored and it will free up space on your online account.
&nbsp;
If you need more assistance please contact Jon Brown at 
support@somedomain.com.
&nbsp;
Thank you for your cooperation!
&nbsp;
-- Some Organization Mail Server&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$qwf</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$qwf</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sendmail</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$FROM_SMTP</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$USER</span>&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$qwf</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;From: <span style="color: #007800;">$USER</span>
To: support@somedomain.com
Subject: Quota Notification
Content-Type: text/plain; charset=&quot;</span>UTF-<span style="color: #000000;">8</span><span style="color: #ff0000;">&quot;
&nbsp;
Hello  -
&nbsp;
<span style="color: #007800;">$USER</span> Is nearing their quota. Please follow these steps.
&nbsp;
1. Call the user and make sure they understand how to archive their email.
&nbsp;
2. Explain to the user that they can sort their email by largest size, tell them to discard or remove the largest emails first.
&nbsp;
3. Ensure that the quota has been reduced in Server Admin, do not increase the quota unless it is an emergency.
&nbsp;
-- Some Organization Mail Server&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$qwf</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$qwf</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sendmail</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$FROM_SMTP</span> <span style="color: #ff0000;">&quot;support@somedomain.com&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$qwf</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></td></tr></table></div>

<p>You must replace the above script with the old script entirely. This will negate the ability to use the text file that Server Admin uses for email notifications but allows you to send the notification to multiple people.</p>
<h4>4. We are going to create a new quota-exceeded.sh file</h4>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot
<span style="color: #c20cb9; font-weight: bold;">sudo</span> pico quota-warning.sh</pre></td></tr></table></div>

<p>This is the current default Apple script that triggers the default email created in Server Admin.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #007800;">_quota_txt</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>mail<span style="color: #000000; font-weight: bold;">/</span>quota_exceeded.txt
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-e</span> <span style="color: #007800;">$_quota_txt</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$_quota_txt</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>deliver <span style="color: #660033;">-d</span> <span style="color: #007800;">$USER</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

<p>We are going to re-write this script and use the following to do similar to the above but at a more aggressive rate.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">PERCENT</span>=<span style="color: #007800;">$1</span>
<span style="color: #007800;">FROM_SMTP</span>=<span style="color: #ff0000;">&quot;support@somedomain.com&quot;</span>
<span style="color: #007800;">FROM</span>=<span style="color: #ff0000;">&quot;FWW Support &lt;support@somedomain.com&gt;&quot;</span>
<span style="color: #007800;">TO</span>=<span style="color: #ff0000;">&quot;FWW Support &lt;mail-server-admin@somedomain.com&gt;&quot;</span>
<span style="color: #007800;">qwf</span>=<span style="color: #ff0000;">&quot;/tmp/quota.warning.$$&quot;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;From: <span style="color: #007800;">$FROM</span>
To: <span style="color: #007800;">$USER</span>
Subject: FWW ***You're Over Your Quota***
Content-Type: text/plain; charset=&quot;</span>UTF-<span style="color: #000000;">8</span><span style="color: #ff0000;">&quot;
&nbsp;
Hello-
This is a warning email that was automatically sent. You are nearing your quota limit. The current quota is 1 GB of storage space per user. However you can store more offline.
&nbsp;
Q: What can I do now?
&nbsp;
A: Start backing up your emails and storing them in a folder under the On My Mac heading, this will ensure that your emails will still be stored and it will free up space on your online account.
&nbsp;
If you need more assistance please contact Jon Brown at support@somedomain.com.
&nbsp;
Thank you for your cooperation!
&nbsp;
-- FWW Mac Server&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$qwf</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$qwf</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sendmail</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$FROM_SMTP</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$USER</span>&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$qwf</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;From: <span style="color: #007800;">$USER</span>
To: support@somedomain.com
Subject: FWW ***You're Over Your Quota***
Content-Type: text/plain; charset=&quot;</span>UTF-<span style="color: #000000;">8</span><span style="color: #ff0000;">&quot;
&nbsp;
Hello  -
&nbsp;
<span style="color: #007800;">$USER</span> Is nearing their quota. Please follow these steps.
&nbsp;
1. Call the user and make sure they understand how to archive their email.
&nbsp;
2. Explain to the user that they can sort their email by largest size, tell them to discard or remove the largest emails first.
&nbsp;
3. Ensure that the quota has been reduced in Server Admin, do not increase the quota unless it is an emergency.
&nbsp;
4. Explain to the user that their email will stop working if they reach 99% capacity.
&nbsp;
-- FWW Mac Server&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$qwf</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$qwf</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sendmail</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$FROM_SMTP</span> <span style="color: #ff0000;">&quot;support@somedomain.com&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$qwf</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></td></tr></table></div>

<p>That is it, once you are done you must restart dovecot.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> serveradmin stop mail
<span style="color: #c20cb9; font-weight: bold;">sudo</span> serveradmin start mail</pre></td></tr></table></div>

<p>Once done you will now be able to enjoy the fruits of your labor. Your users will now get a lot more notifications which will mean that they will be more likely to tame their unruly inboxes on their own and you will be notified as to when they are getting notifications so that you can better assist them with this task. As always I encourage your comments, suggestions and questions. I hope you all enjoyed my post and thanks for reading!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonsblog.org/2011/10/07/better-quota-notifications-for-osx-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>10.6.2 Dovecot Mail Backups</title>
		<link>http://www.jonsblog.org/2010/01/24/10-6-2-dovecot-mail-backups/</link>
		<comments>http://www.jonsblog.org/2010/01/24/10-6-2-dovecot-mail-backups/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 00:08:15 +0000</pubDate>
		<dc:creator>Jon Brown</dc:creator>
				<category><![CDATA[Mail Server]]></category>
		<category><![CDATA[OSX Server Configuration]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.jonsblog.org/?p=33</guid>
		<description><![CDATA[Before migrating to 10.6 Server we were running our entire mailstore on the 10.5.8 platform. Say what you will about Leopard, once we had it set up correctly it ran fine. We migrated because of the greater benefits of Dovecot over Cyrus. Many of the other features intriqued us as well such as the improved [...]]]></description>
			<content:encoded><![CDATA[<p>Before migrating to 10.6 Server we were running our entire mailstore on the 10.5.8 platform. Say what you will about Leopard, once we had it set up correctly it ran fine. We migrated because of the greater benefits of Dovecot over Cyrus. Many of the other features intriqued us as well such as the improved Wiki server and iCal server. However we were really excited about Dovecots ability to repair itself basically doing away with the need to ever have to rebuild a users mailbox.</p>
<p>The one great thing about 10.5.8 was the development of <a href="http://osx.topicdesk.com/content/view/41/41/">Mailbfr</a> this was an amazing script that would help you backup your entire mailstore, recover email accounts, repair quotas, and of course rebuild or repair the entire mail-store. This was an invaluable tool, however since switching we have had to come up with our own solution.</p>
<p>We tried at first to get RSYNC running however this did not work because we did not have the permission to copy the mailstore with the permissions in tact. The reason is that while the root account does have access to look at the mailstore the secondary user on the mailstore folder is the mail user itself. Without running the script as each user then its near impossible to use RSYNC to move the mailstore or to even perform a simple backup.</p>
<p>Our solution was to create a backup script that use SCP with SCP we were able to move our mail-store to another drive on the server. It copies the store over and it resets the permissions to the administrator account. This solution works very well however after some time with a large mailstore you will run out of space on the target volume. Unlike RSYNC which uses hard links to save space SCP creates a new copy of the mailstore each time it is run.</p>
<p>In order to save space on the backup volume the oldest 2 weeks worth of backed up email gets dumped to DVD and removed from the drive on a monthly basis. This is fine but not optimal. Here is a copy of the script that we use on our server.<span id="more-33"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> backup started daily backup <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>Volumes<span style="color: #000000; font-weight: bold;">/</span>EMAIL\ BACKUP<span style="color: #000000; font-weight: bold;">/</span>Backup<span style="color: #000000; font-weight: bold;">/</span>Logs<span style="color: #000000; font-weight: bold;">/</span>Backup_log.txt
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">scp</span> <span style="color: #660033;">-r</span> <span style="color: #000000; font-weight: bold;">/</span>Volumes<span style="color: #000000; font-weight: bold;">/</span>Mailstore-Location<span style="color: #000000; font-weight: bold;">/</span>spool <span style="color: #000000; font-weight: bold;">/</span>Volumes<span style="color: #000000; font-weight: bold;">/</span>EMAIL\ BACKUP<span style="color: #000000; font-weight: bold;">/</span>Email-Backups<span style="color: #000000; font-weight: bold;">/</span>$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>d<span style="color: #7a0874; font-weight: bold;">&#41;</span>-$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>m<span style="color: #7a0874; font-weight: bold;">&#41;</span>-$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>Y<span style="color: #7a0874; font-weight: bold;">&#41;</span>backup 
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> backup daily backup completed <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>Volumes<span style="color: #000000; font-weight: bold;">/</span>EMAIL\ BACKUP<span style="color: #000000; font-weight: bold;">/</span>Backup<span style="color: #000000; font-weight: bold;">/</span>Logs<span style="color: #000000; font-weight: bold;">/</span>Backup_log.txt</pre></td></tr></table></div>

<p>This will backup the mailstore and then log each time that it does so. To recover an email to the original mailstore is not as hard as it seems. Navigate to the backed up mailstore destination and match up the name of the folder to the users UID of which you want to recover. For example if the users UID is 7458-58713-952554-544226 then you would look for a folder with the same name. Once in the folder you can copy or look at individual email files. Find the ones or one that you need and copy it to the folder of the original mailstore. In order to do this you will have to use sudo. For example this is how you would restore the entire folder</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">scp</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">&quot;Volumes/EMAIL\ BACKUP/Email-Backups/7458-58713-952554-544226/.*&quot;</span> <span style="color: #ff0000;">&quot;/Volumes/Mailstore-Location/spool/7458-58713-952554-544226/.*&quot;</span></pre></td></tr></table></div>

<p>Until <a href="http://osx.topicdesk.com/content/view/41/41/">Mailbfr</a> comes back for Dovecot this is how we are protecting ourself against the accidental loss of email. I am not saying that this is the best method it is simply the one we are using. If you have another solution that works bette than please let me know and share your own experience!</p>
<p>*** UPDATE 12/8/2011 ***<br />
Here is the script that I am using to date for your use. It logs the backups and emails me when they are complete.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># This adds a record to our backup log</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> backup started daily backup <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>Scripts<span style="color: #000000; font-weight: bold;">/</span>Logs<span style="color: #000000; font-weight: bold;">/</span>Backup_log.txt
&nbsp;
<span style="color: #666666; font-style: italic;"># This backs up the files</span>
&nbsp;
rsync <span style="color: #660033;">-avu</span> <span style="color: #000000; font-weight: bold;">/</span>location<span style="color: #000000; font-weight: bold;">/</span>of<span style="color: #000000; font-weight: bold;">/</span>mail<span style="color: #000000; font-weight: bold;">/</span>spool <span style="color: #000000; font-weight: bold;">/</span>Volumes<span style="color: #000000; font-weight: bold;">/</span>backup-volume<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># This adds another record to our backup log</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> backup daily backup completed <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>Scripts<span style="color: #000000; font-weight: bold;">/</span>Logs<span style="color: #000000; font-weight: bold;">/</span>Backup_log.txt
&nbsp;
<span style="color: #666666; font-style: italic;"># This emails the Sys Admin</span>
&nbsp;
<span style="color: #007800;">NOW</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #ff0000;">&quot;%m-%d-%Y&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #007800;">SUBJECT</span>=<span style="color: #ff0000;">&quot;Email Backed Up - &quot;</span><span style="color: #007800;">$NOW</span><span style="color: #ff0000;">&quot;&quot;</span>
&nbsp;
<span style="color: #007800;">EMAIL</span>=<span style="color: #ff0000;">&quot;email@user.com&quot;</span>
&nbsp;
<span style="color: #007800;">EMAILMESSAGE</span>=<span style="color: #ff0000;">&quot;/Scripts/Logs/Backup_log.txt&quot;</span>
&nbsp;
mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$SUBJECT</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$EMAIL</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$EMAILMESSAGE</span>&quot;</span></pre></td></tr></table></div>

<p>The easiest way to start / stop  this is to setup a LaunchD or Cronjob, I prefer Cron since its easier in my opinion to setup. Setup the rsync script that you have below and put the code in a bash script. I use a GUI tool called Cronix http://code.google.com/p/cronnix/ once you download this launch it and put the full path to the bash script at the bottom the cron job code for every ten minutes is</p>
<p>0/10 * * * * * /path/to/bash/script.sh</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jonsblog.org/2010/01/24/10-6-2-dovecot-mail-backups/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
	</channel>
</rss>

