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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
|
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Deleting and Undeleting Messages and Folders — Cyrus IMAP 3.10.2 documentation</title>
<link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../../../_static/graphviz.css" type="text/css" />
<link rel="stylesheet" href="../../../../_static/cyrus.css" type="text/css" />
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
<script src="../../../../_static/jquery.js"></script>
<script src="../../../../_static/underscore.js"></script>
<script src="../../../../_static/_sphinx_javascript_frameworks_compat.js"></script>
<script src="../../../../_static/doctools.js"></script>
<script src="../../../../_static/sphinx_highlight.js"></script>
<script src="../../../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../../../genindex.html" />
<link rel="search" title="Search" href="../../../../search.html" />
<link rel="next" title="Running Cyrus IMAP Services on Non-Standard Ports" href="administration-running.html" />
<link rel="prev" title="Alternative Namespace" href="altnamespace.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../../../index.html" class="icon icon-home">
Cyrus IMAP
</a>
<div class="version">
3.10.2
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Cyrus IMAP</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../../../download.html">Download</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../quickstart.html">Quickstart Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../overview.html">Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../setup.html">Setup</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../../../operations.html">Operations</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../../manpages/index.html">Man pages</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../../admin.html">Administrator Guide</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../../admin.html#architecture">Architecture</a></li>
<li class="toctree-l3 current"><a class="reference internal" href="../../admin.html#management">Management</a><ul class="current">
<li class="toctree-l4"><a class="reference internal" href="../locations.html">File & Directory Locations</a></li>
<li class="toctree-l4"><a class="reference internal" href="../ports-sockets.html">Ports and Sockets</a></li>
<li class="toctree-l4"><a class="reference internal" href="../access-control.html">Access Control</a></li>
<li class="toctree-l4"><a class="reference internal" href="../quotas.html">Quotas</a></li>
<li class="toctree-l4"><a class="reference internal" href="../sieve.html">Cyrus Sieve</a></li>
<li class="toctree-l4"><a class="reference internal" href="../backups.html">Cyrus Backups</a></li>
<li class="toctree-l4"><a class="reference internal" href="../nntp.html">Cyrus NNTP</a></li>
<li class="toctree-l4"><a class="reference internal" href="../protlayer.html">Cyrus Prot Layer</a></li>
<li class="toctree-l4 current"><a class="reference internal" href="../sop.html">Standard Operating Procedures</a></li>
<li class="toctree-l4"><a class="reference internal" href="../eventsource.html">Cyrus Event Source</a></li>
<li class="toctree-l4"><a class="reference internal" href="../monitoring.html">Monitoring</a></li>
<li class="toctree-l4"><a class="reference internal" href="../config-mailboxdistribution.html">Mailbox Distribution</a></li>
<li class="toctree-l4"><a class="reference internal" href="../murder/murder.html">Cyrus Murder</a></li>
<li class="toctree-l4"><a class="reference internal" href="../nginx-proxy.html">HOWTO: Using an NGINX IMAP Proxy</a></li>
<li class="toctree-l4"><a class="reference internal" href="../tweaking.html">Tweaking Cyrus IMAP</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../faq.html">Frequently Asked Questions</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../../developers.html">Developers</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../support.html">Support/Community</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Cyrus SASL</span></p>
<ul>
<li class="toctree-l1"><a class="reference external" href="http://www.cyrusimap.org/sasl">Cyrus SASL</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../../../index.html">Cyrus IMAP</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../../../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="../../../../operations.html">Operations</a></li>
<li class="breadcrumb-item"><a href="../../admin.html">Administrator Guide</a></li>
<li class="breadcrumb-item"><a href="../sop.html">Standard Operating Procedures</a></li>
<li class="breadcrumb-item active">Deleting and Undeleting Messages and Folders</li>
<li class="wy-breadcrumbs-aside">
<a href="https://github.com/cyrusimap/cyrus-imapd/blob/master/docsrc/imap/reference/admin/sop/deleting.rst" class="fa fa-github"> Edit on GitHub</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="deleting-and-undeleting-messages-and-folders">
<span id="imap-admin-sop-restoring-expunged-messages"></span><h1>Deleting and Undeleting Messages and Folders<a class="headerlink" href="#deleting-and-undeleting-messages-and-folders" title="Permalink to this heading"></a></h1>
<section id="terminology-definitions">
<h2>Terminology & Definitions<a class="headerlink" href="#terminology-definitions" title="Permalink to this heading"></a></h2>
<p>This section clarifies some of the subtle nuances between delete,
expunge and expire in different contexts, used throughout this chapter.</p>
<section id="message-context">
<h3>Message context<a class="headerlink" href="#message-context" title="Permalink to this heading"></a></h3>
<p>Delete</p>
<blockquote>
<div><p>sets the <code class="docutils literal notranslate"><span class="pre">\Deleted</span></code> flag on the message using
<code class="docutils literal notranslate"><span class="pre">STORE</span> <span class="pre">+Flags</span> <span class="pre">\Deleted</span></code> via IMAP client</p>
</div></blockquote>
<p>Expunge</p>
<blockquote>
<div><p>delete messages from the cyrus folder index that have the
<code class="docutils literal notranslate"><span class="pre">\Deleted</span></code> flag set using EXPUNGE via IMAP client. With
<code class="docutils literal notranslate"><span class="pre">expunge_mode:</span> <span class="pre">delayed</span></code>, this doesn't delete the file from
the filesystem.</p>
</div></blockquote>
<p>Unexpunge</p>
<blockquote>
<div><p>recover messages into the cyrus folder index based on filesystem
content (only possible with <code class="docutils literal notranslate"><span class="pre">expunge_mode:</span> <span class="pre">delayed</span></code>)</p>
</div></blockquote>
<p>Undelete</p>
<blockquote>
<div><p>remove the <code class="docutils literal notranslate"><span class="pre">\Deleted</span></code> flag on the message using
<code class="docutils literal notranslate"><span class="pre">STORE</span> <span class="pre">-Flags</span> <span class="pre">\Deleted</span></code> via IMAP client.</p>
</div></blockquote>
</section>
<section id="folder-context">
<h3>Folder context<a class="headerlink" href="#folder-context" title="Permalink to this heading"></a></h3>
<p>Delete</p>
<blockquote>
<div><p>deletes the folder and all messages inside it using <code class="docutils literal notranslate"><span class="pre">DELETE</span></code>
via IMAP client. If using <code class="docutils literal notranslate"><span class="pre">delete_mode:</span> <span class="pre">delayed</span></code>, this renames
the folder, rather than deletes the folder, as discussed below.</p>
<p>Otherwise, the folder and messages are removed from the mailbox
list and the filesystem.</p>
</div></blockquote>
<p>Undelete</p>
<blockquote>
<div><p>rename the deleted folder back to the original location using
<code class="docutils literal notranslate"><span class="pre">renamemailbox</span></code> in <code class="docutils literal notranslate"><span class="pre">cyradm</span></code>.</p>
</div></blockquote>
</section>
</section>
<section id="expiring-deleted-messages-and-folders">
<h2>Expiring Deleted Messages and Folders<a class="headerlink" href="#expiring-deleted-messages-and-folders" title="Permalink to this heading"></a></h2>
<p>In the EVENTS block of cyrus.conf, you should have a line similar to the
following:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">delprune</span> <span class="n">cmd</span><span class="o">=</span><span class="s2">"cyr_expire -E 1 -D 7 -X 7 -a"</span> <span class="n">at</span><span class="o">=</span><span class="mi">2300</span>
</pre></div>
</div>
<p>-D 7</p>
<blockquote>
<div><p>permanently deletes from the filesystem mailboxes and folders that
were deleted more than 7 days ago.</p>
</div></blockquote>
<p>-E 1</p>
<blockquote>
<div><p>prunes entries older than 1 day from the duplicate delivery
suppression database.</p>
</div></blockquote>
<p>-X 7</p>
<blockquote>
<div><p>permanently deletes from the filesystem expunged messages that were
expunged more than 7 days ago.</p>
</div></blockquote>
<p>To use delayed deletion of mailboxes, you need the following entry in
<a class="reference internal" href="../../manpages/configs/imapd.conf.html#std-cyrusman-imapd.conf-5">imapd.conf(5)</a>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">delete_mode</span><span class="p">:</span> <span class="n">delayed</span>
</pre></div>
</div>
<div class="versionadded">
<p><span class="versionmodified added">New in version 2.3.9.</span></p>
</div>
<p>The default prefix for deleted mailboxes is <code class="docutils literal notranslate"><span class="pre">DELETED</span></code> but it probably
doesn't hurt to specify it in <a class="reference internal" href="../../manpages/configs/imapd.conf.html#std-cyrusman-imapd.conf-5">imapd.conf(5)</a> as well:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">deletedprefix</span><span class="p">:</span> <span class="n">DELETED</span>
</pre></div>
</div>
<div class="versionadded">
<p><span class="versionmodified added">New in version 2.3.9.</span></p>
</div>
</section>
<section id="undeleting-folders">
<h2>Undeleting Folders<a class="headerlink" href="#undeleting-folders" title="Permalink to this heading"></a></h2>
<p>The following assumes that you are using the UNIX hierarchy separator.
If it's off then replace '/' in the names with '.'</p>
<p>With the previous configuration options in place, whenever a mail folder
or mailbox is deleted, it will be renamed to
<code class="docutils literal notranslate"><span class="pre">DELETED/mailfoldername/4D5C6B7A</span></code> where <code class="docutils literal notranslate"><span class="pre">4D5C6B7A</span></code> is a hex-encoded
timestamp and <code class="docutils literal notranslate"><span class="pre">DELETED</span></code> is the prefix for deleted mailboxes.</p>
<p><code class="docutils literal notranslate"><span class="pre">4D5C6B7A</span></code> can be converted back to a human-readable time using a
simple one-liner in Perl:</p>
<pre class="literal-block">$ <strong class="command">perl -le 'print scalar(localtime(hex("4D5C6B7A")));'</strong>
Thu Feb 17 00:27:38 2011</pre>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The ACL on the deleted folder remains the same so undeleting it is
as simple as renaming it as a sub-folder of the recreated mailbox or
back to the original folder name depending on whether the mailbox
has been recreated or not. If you have to add an ACL to be able to
delete the mailbox, you may wish to remove the ACL after the
undelete has been finished.</p>
</div>
<p>The following examples assume a mailbox for <a class="reference external" href="mailto:john%40example.org">john<span>@</span>example<span>.</span>org</a> has been
deleted:</p>
<pre class="literal-block">cyradm> <strong class="command">listmailbox user/john*@example.org</strong></pre>
<p>If there's no output from the above command, the mailbox has not been
recreated since being deleted and you can rename the mailbox and any
folders back to the original name as follows. If the mailbox has been
recreated, you will probably want to rename the deleted folders into a
subfolder of the new mailbox, for example
<code class="docutils literal notranslate"><span class="pre">user/john/4D88AF31@example.org</span></code> becomes
<code class="docutils literal notranslate"><span class="pre">user/john/restored@example.org</span></code> and
<code class="docutils literal notranslate"><span class="pre">user/john/Sent/4D88AF34@example.org</span></code> becomes
<code class="docutils literal notranslate"><span class="pre">user/john/restored/Sent@example.org</span></code></p>
<p>In either case the commands are similar but with the latter option you
need to insert the extra "/restored" after the <code class="docutils literal notranslate"><span class="pre">user/john</span></code>:</p>
<pre class="literal-block">cyradm> <strong class="command">listmailbox DELETED/user/john*@example.org</strong>
<a class="reference external" href="mailto:DELETED/user/john/4D88AF31%40example.org">DELETED/user/john/4D88AF31<span>@</span>example<span>.</span>org</a> (HasNoChildren)
<a class="reference external" href="mailto:DELETED/user/john/Drafts/4D88AF34%40example.org">DELETED/user/john/Drafts/4D88AF34<span>@</span>example<span>.</span>org</a> (HasNoChildren)
<a class="reference external" href="mailto:DELETED/user/john/Sent/4D88AF34%40example.org">DELETED/user/john/Sent/4D88AF34<span>@</span>example<span>.</span>org</a> (HasNoChildren)
<a class="reference external" href="mailto:DELETED/user/john/Trash/4D88AF35%40example.org">DELETED/user/john/Trash/4D88AF35<span>@</span>example<span>.</span>org</a> (HasNoChildren)
cyradm> <strong class="command">renamemailbox DELETED/user/john/4D88AF31@example.org user/john@example.org</strong>
cyradm> <strong class="command">renamemailbox DELETED/user/john/Drafts/4D88AF34@example.org user/john/Drafts@example.org</strong>
cyradm> <strong class="command">renamemailbox DELETED/user/john/Sent/4D88AF34@example.org user/john/Sent@example.org</strong>
cyradm> <strong class="command">renamemailbox DELETED/user/john/Trash/4D88AF35@example.org user/john/Trash@example.org</strong></pre>
<p>Unfortunately there's no easy way to rename the entire mailbox back
including all the subfolders and the hex timestamp can vary between
folders in the same mailbox if it was a mailbox with some large folders.</p>
<p>This is because it's the time that particular folder was deleted, not
when the first folder was deleted.</p>
</section>
<section id="undeleting-messages-in-a-mailbox">
<h2>Undeleting messages in a mailbox<a class="headerlink" href="#undeleting-messages-in-a-mailbox" title="Permalink to this heading"></a></h2>
<p>The following examples assume you have an installation of cyrus where
there are binaries in <code class="docutils literal notranslate"><span class="pre">/usr/lib/cyrus-imapd/</span></code> - if not, adjust path to
suit.</p>
<p>List messages available to unexpunge:</p>
<pre class="literal-block"># <strong class="command">/usr/lib/cyrus-imapd/unexpunge -l user/john@example.org</strong></pre>
<p>Each message will give you something like the following:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">UID</span><span class="p">:</span> <span class="mi">11422</span>
<span class="n">Size</span><span class="p">:</span> <span class="mi">7786</span>
<span class="n">Sent</span><span class="p">:</span> <span class="n">Mon</span> <span class="n">Mar</span> <span class="mi">10</span> <span class="mi">12</span><span class="p">:</span><span class="mi">00</span><span class="p">:</span><span class="mi">00</span> <span class="mi">2014</span>
<span class="n">Recv</span><span class="p">:</span> <span class="n">Mon</span> <span class="n">Mar</span> <span class="mi">10</span> <span class="mi">16</span><span class="p">:</span><span class="mi">06</span><span class="p">:</span><span class="mi">32</span> <span class="mi">2014</span>
<span class="n">Expg</span><span class="p">:</span> <span class="n">Mon</span> <span class="n">Mar</span> <span class="mi">10</span> <span class="mi">16</span><span class="p">:</span><span class="mi">53</span><span class="p">:</span><span class="mi">55</span> <span class="mi">2014</span>
<span class="n">From</span><span class="p">:</span> <span class="n">john</span> <span class="n">doe</span> <span class="o"><</span><span class="n">john</span><span class="o">.</span><span class="n">doe</span><span class="nd">@example</span><span class="o">.</span><span class="n">org</span><span class="o">></span>
<span class="n">To</span> <span class="p">:</span> <span class="o"><</span><span class="n">info</span><span class="o">-</span><span class="n">cyrus</span><span class="nd">@lists</span><span class="o">.</span><span class="n">andrew</span><span class="o">.</span><span class="n">cmu</span><span class="o">.</span><span class="n">edu</span><span class="o">></span>
<span class="n">Cc</span> <span class="p">:</span>
<span class="n">Bcc</span> <span class="p">:</span>
<span class="n">Subj</span><span class="p">:</span> <span class="p">{</span><span class="mi">44</span><span class="p">}</span>
<span class="n">re</span><span class="p">:</span> <span class="n">some</span> <span class="n">random</span> <span class="n">subject</span> <span class="n">of</span> <span class="n">length</span> <span class="mi">44</span> <span class="n">chars</span><span class="o">.</span><span class="s2">"</span>
</pre></div>
</div>
<p>To unexpunge a single message:</p>
<pre class="literal-block"># <strong class="command">/usr/lib/cyrus-imapd/unexpunge -udv user/john@example.org 11422</strong>
restoring expunged messages in mailbox <a class="reference external" href="mailto:'user/john%40example.org">'user/john<span>@</span>example<span>.</span>org</a>'
Unexpunged <a class="reference external" href="mailto:user/john%40example.org">user/john<span>@</span>example<span>.</span>org</a>: 11422 => 11438
restored 1 expunged messages</pre>
<p>To unexpunge all the messages and mark them as undeleted as well:</p>
<pre class="literal-block"># <strong class="command">/usr/lib/cyrus-imapd/unexpunge -adv user/john@example.org</strong></pre>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This isn't recursive. It will only restore the messages in the
folder specified.</p>
</div>
<p>To find other folders, <a class="reference internal" href="../../manpages/systemcommands/ctl_mboxlist.html#imap-reference-manpages-systemcommands-ctl-mboxlist"><span class="std std-ref">ctl_mboxlist</span></a> can be
used.</p>
<pre class="literal-block"># <strong class="command">/usr/lib/cyrus-imapd/ctl_mboxlist -d | grep example.org</strong>
example.org!user.john 0 default <a class="reference external" href="mailto:john%40example.org">john<span>@</span>example<span>.</span>org</a> lrswipkxtecda
example.org!user.john.Lists 0 default <a class="reference external" href="mailto:john%40example.org">john<span>@</span>example<span>.</span>org</a> lrswipkxtecda
example.org!user.john.Lists.cyrus 0 default <a class="reference external" href="mailto:john%40example.org">john<span>@</span>example<span>.</span>org</a> lrswipkxtecda
example.org!user.john.Deleted Messages 0 default <a class="reference external" href="mailto:john%40example.org">john<span>@</span>example<span>.</span>org</a> lrswipkxtecda</pre>
<p>Run the unexpunge command for every folder that needs to have mail
undeleted.</p>
<p>For folder names that have spaces ' ', the spaces need to be escaped
with a backslash.</p>
<pre class="literal-block"># <strong class="command">/usr/lib/cyrus-imapd/unexpunge -adv user/john/DeletedMessages@example.org</strong></pre>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="altnamespace.html" class="btn btn-neutral float-left" title="Alternative Namespace" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="administration-running.html" class="btn btn-neutral float-right" title="Running Cyrus IMAP Services on Non-Standard Ports" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>© Copyright 1993–2025, The Cyrus Team.</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>
|