{"id":10196,"date":"2020-10-06T00:10:24","date_gmt":"2020-10-05T23:10:24","guid":{"rendered":"http:\/\/cogito-ergo-blog.de\/blog\/?p=10196"},"modified":"2020-10-06T00:10:24","modified_gmt":"2020-10-05T23:10:24","slug":"migrating-dovecot-mailboxes-from-one-host-to-another","status":"publish","type":"post","link":"https:\/\/cogito-ergo-blog.de\/blog\/2020\/10\/06\/migrating-dovecot-mailboxes-from-one-host-to-another\/","title":{"rendered":"Migrating dovecot mailboxes from one host to another"},"content":{"rendered":"<p>I needed to move my mail system based on dovecot \/ postfix from one host to another preserving all mailboxes and also all imap UUIDs, so that imap clients can still identify mails.<\/p>\n<p>There are some tools that come with dovecot but every how to that google returns for the problem seems much too complicated for that simple problem.<\/p>\n<p>When you look at the man page of doveadm or dsync you know why: both tools have an overwhelming number of options.<\/p>\n<p>After some reading and trying, is it basically use dsync for backup and restore and &#8211; also important &#8211; create same user accounts on both machines source and destination.<\/p>\n<p>Then it goes like this:<\/p>\n<ol>\n<li>create a world writeable tmpdir to dump the mailbox to e.g. \/tmp\/dump: <em><strong>mkdir \/tmp\/dump &amp;&amp; chmod a+w \/tmp\/dump<\/strong><\/em><\/li>\n<li>use dsync to dump:\u00a0<strong><em>dsync -o plugin\/quota= -f -u\u00a0&lt;email&gt; backup maildir:\/tmp\/dump<\/em><\/strong><\/li>\n<li>compress with tar preseving time \/ permissions:\u00a0<em><strong>tar cvzf dump.tgz \/tmp\/dump\/ &#8211;atime-preserve &#8211;preserve-permissions<\/strong><\/em><\/li>\n<li>copy the tar archive to new machine: <strong><em>scp dump.tgz user@target:<\/em><\/strong><\/li>\n<li>decompress into a world readable directory e.g. again \/tmp\/dump<\/li>\n<li>If the mail account was touched already remove the complete mail directory (path depends on your setup, in most cases somewhere below \/var\/vmail\/&#8230; or \/var\/mail\/&#8230;.)<\/li>\n<li>Restore the mailbox with: <strong><em>dsync -R -f -u &lt;email&gt; backup maildir:\/tmp\/dump\/<\/em><\/strong><\/li>\n<\/ol>\n<p>That&#8217;s basically it. Just repeat for alle mailboxes you need to move and your done. Also a very fast and portable way to <em>backup<\/em> mailboxes.<\/p>\n<p>Surprisingly this simple 7 step approach is not mentioned in any FAQ or manual I read, so here we are: just use it and your done.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I needed to move my mail system based on dovecot \/ postfix from one host to another preserving all mailboxes and also all imap UUIDs, so that imap clients can still identify mails. There are some tools that come with &hellip; <a href=\"https:\/\/cogito-ergo-blog.de\/blog\/2020\/10\/06\/migrating-dovecot-mailboxes-from-one-host-to-another\/\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,10],"tags":[],"_links":{"self":[{"href":"https:\/\/cogito-ergo-blog.de\/blog\/wp-json\/wp\/v2\/posts\/10196"}],"collection":[{"href":"https:\/\/cogito-ergo-blog.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cogito-ergo-blog.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cogito-ergo-blog.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cogito-ergo-blog.de\/blog\/wp-json\/wp\/v2\/comments?post=10196"}],"version-history":[{"count":1,"href":"https:\/\/cogito-ergo-blog.de\/blog\/wp-json\/wp\/v2\/posts\/10196\/revisions"}],"predecessor-version":[{"id":10197,"href":"https:\/\/cogito-ergo-blog.de\/blog\/wp-json\/wp\/v2\/posts\/10196\/revisions\/10197"}],"wp:attachment":[{"href":"https:\/\/cogito-ergo-blog.de\/blog\/wp-json\/wp\/v2\/media?parent=10196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cogito-ergo-blog.de\/blog\/wp-json\/wp\/v2\/categories?post=10196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cogito-ergo-blog.de\/blog\/wp-json\/wp\/v2\/tags?post=10196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}