Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
243 lines (160 sloc) 16 KB
<!DOCTYPE html>
<html class="no-js">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width">
<title>Mail-in-a-Box Maintenance Guide</title>
<meta name="description" content="Maintenance instructions for Mail-in-a-Box. Take back control of your email with this easy-to-deploy mail server in a box." />
<meta property="og:site_name" content="Mail-in-a-Box">
<meta name="twitter:creator" content="@joshdata" />
<meta name="twitter:creator:id" content="352686442" />
<meta name="twitter:site" content="@mailinabox" />
<meta name="twitter:site:id" content="2612357965" />
<meta name="og:image" content="" />
<link rel="vcs-git" href="" title="code for Mail-in-a-Box website" />
<link rel="icon" type="image/png" href="/static/logo_small.png">
<link rel="apple-touch-icon" type="image/png" href="/static/logo_small.png">
<link rel="stylesheet" href="" />
<link rel="stylesheet" href="guides.css" />
<body data-spy="scroll" data-target="#nav">
<a href="" class="visible-md visible-lg"><img style="position: absolute; top: 0; right: 0; border: 0;" src="" alt="Fork me on GitHub" data-canonical-src=""></a>
<div id="back">
<div class="container">
<a href="/">
&lt; Back to Mail-in-a-Box
<div class="container">
<div class="row">
<div id="sidebar" class="col-sm-4 col-md-3">
<div id="nav" class="small">
<p style="margin: 0 0 .5em 14px; border-bottom: 1px solid #CCC; color: #888;">Table of Contents</p>
<ul class="nav nav-list">
<li><a href="#something-went-wrong">Something Went Wrong</a></li>
<li><a href="#multiple-domains">Multiple Domains</a></li>
<li><a href="#updating-software">Updating System Software</a></li>
<li><a href="#upgrade">Upgrading Mail-in-a-Box</a></li>
<li><a href="#moving-boxes">Moving to a New Box</a></li>
<div class="col-sm-8 col-md-9">
<div style="padding-left: 1em; max-width: 55em">
<h1>Mail-in-a-Box Maintenance Guide</h1>
<p>This page covers frequently asked questions about how to configure a running Mail-in-a-Box and how to keep it up to date. For help setting up a new box, see the <a href="guide.html">setup guide</a>.</p>
<h2 id="something-went-wrong">Something Went Wrong!</h2>
<p>Is something not working right? Start here. Please follow these steps before asking a question on the discussion forum:</p>
<li>Check your System Status Checks page in the control panel at <code></code>. Everything should be green. Anything not green may help you diagnose the problem on your own.</li>
<li>Re-run the setup by logging into your box (using the same <code>ssh</code> command that you used <a href="guide.html#setup">during setup</a>) and running <code>sudo mailinabox</code>. Then check the System Status Checks page again.</li>
<li>Restart your box by logging in with SSH and then typing <code>sudo reboot</code>. Once the box has started up, check the System Status Checks page again.</li>
<p>Please do these steps first. If you&rsquo;ve done these steps, then head to the <a href="">discussion forum</a> to ask your question. In your post:</p>
<li>Describe the problem you are having. Instead of saying &ldquo;it doesn&rsquo;t work&rdquo;, write the error message you see, post a screenshot, or describe what you are seeing that you don&rsquo;t want to be seeing.</li>
<li>Mention that you &ldquo;checked the status page, re-ran setup, and rebooted the box&rdquo;, per the steps above, so that anyone answering knows what you have tried so far. If you don&rsquo;t mention this, someone may ask you to do it before providing other assistance.</li>
<li>If everything in the System Status Checks is green, mention that by saying &ldquo;all checks are green&rdquo;. If something isn&rsquo;t green, mention it.</li>
<p>If you figure out the problem on your own, you are also welcome to write up your experience on the <a href="">discussion forum</a> so that it might help others.</p>
<h2 id="multiple-domains">Multiple Domain Names</h2>
<p>Your box can host email and serve static websites for more than one domain name. To set up additional domain names, just follow three steps:</p>
<li>Buy an additional domain name if you don&rsquo;t yet own it. See the <a href="guide.html#domain-name-registration">Your Domain Name</a> section of the setup guide for tips.</li>
<li>Configure its nameservers to be the same nameservers on your first domain name. Follow the <a href="guide.html#domain-name-nameservers">Domain Name Configuration — Nameservers</a> section of the setup guide for instructions.</li>
<li>Add an email account (user) or alias on your box for the new domain name using the control panel. If you only plan to serve a website, still add an email address or alias &mdash; that&rsquo;s how the box knows to handle that domain name.</li>
<h2 id="updating-software">Updating System Software</h2>
<p>Mail-in-a-Box is based on a collection of other software packages provided by <a href="">Ubuntu</a>. We call these packages system software packages. These packages may have security or other functionality updates.</p>
<p>You should periodically update the system software on your box. The box will automatically install security updates as they are made available by Ubuntu, but your control panel will let you know if a reboot is needed or if non-security updates are available for you to install.</p>
<p>When indicated to do so, log into your machine with SSH (using the same <code>ssh</code> command that you used <a href="guide.html#setup">during setup</a>) and then type:</p>
<pre>sudo apt-get update &amp;&amp; sudo apt-get upgrade</pre>
<p>If prompted to reboot, type:</p>
<pre>sudo reboot</pre>
<p>We will post security advisories to our twitter account <a href="">@mailinabox</a>, the <a href="">announcements section of the discussion forum</a>, and our Slack chat (see the homepage).</p>
<h2 id="upgrade">Upgrading Mail-in-a-Box</h2>
<p>You should move to the latest Mail-in-a-Box release as releases are posted, especially if an update addresses any security issues, although you do not necessarily need to do so. We will post release announcements to our twitter account <a href="">@mailinabox</a>, the <a href="">announcements section of the discussion forum</a>, and our Slack chat (see the homepage).</p>
<p>Check the <a href="">release notes</a> prior to updating to see what&rsquo;s been changed in the latest version.</p>
<div class="alert alert-warning" role="alert">
<p>If you are upgrading from Mail-in-a-Box version v0.30 or earlier on <strong>Ubuntu 14.04</strong> to version 0.40 or later on <strong>Ubuntu 18.04</strong>:</p>
<p>1. Follow the instructions in this section to upgrade your existing Mail-in-a-Box to v0.30, the last version supporting Ubuntu 14.04. (<a href="">As noted in the forum</a>, upgrading the Nextcloud components can be challenging now due to package deprecation.)</p>
<p>2. After your existing box is up to date with v0.30, then proceed to the section below <strong>Moving to a New Box</strong> to migrate your system to a new machine running Ubuntu 18.04 and version 0.40 of Mail-in-a-Box.</p>
<p>To upgrade Mail-in-a-Box to the latest release, first close any web browser pages related to your instance of Mail-in-a-Box, then log into your machine using <code>SSH</code> in exactly the same manner as when you were setting up the box (see the setup guide section called <a href="guide.html#setup">Setting Up The Box</a> for a reminder of what that looked like).</p>
<p>Then, once logged in, run:</p>
<pre>curl -s | sudo bash</pre>
<p>This is actually the same command you ran when setting up the box. It does upgrades too.</p>
<div class="alert alert-warning" role="alert">
<p>If you see an error message similar to:</p>
<p>Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)</p>
<p>Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?</p>
<p>then be sure that you have closed any browser pages for your Mail-in-a-Box instance and run the above command again.</p>
<h2 id="moving-boxes">Moving to a New Box / Testing Backups</h2>
<p>If you want to move your Mail-in-a-Box installation to a new machine (e.g. you&rsquo;re getting more memory, getting a new IP address, etc.), or if something is horribly wrong with your box, you can easily move all of your data to a new machine. <strong>This is also the process for upgrading a Mail-in-a-Box box from v0.30 or earlier on Ubuntu 14.04 to version 0.40 or later on Ubuntu 18.04.</strong></p>
<div class="alert alert-success" role="alert">
<p>Even if your box is working fine, it&rsquo;s a good idea to test out this procedure from time to time so that you can verify that your backups are working and that you haven&rsquo;t lost the backup secret key.</p>
<h3>Upgrade your old box first!</h3>
<p>Moving your data to a new box is only supported if your existing Mail-in-a-Box box is up to date with the latest version of Mail-in-a-Box. So follow the steps in <i>Upgrading Mail-in-a-Box</i> above to upgrade to the latest version of Mail-in-a-Box before proceeding.</p>
<div class="alert alert-warning" role="alert">
<p>If you are upgrading from Mail-in-a-Box version v0.30 or earlier on <strong>Ubuntu 14.04</strong> to version v0.40 or later on <strong>Ubuntu 18.04</strong>, you must follow the instructions in the previous section to uprade your existing Mail-in-a-Box to v0.30, the last version supporting Ubuntu 14.04, before proceeding. <a href="">Complete instructions for updating to Ubuntu 18.04 and v0.40 are posted on the forum.</a></p>
<h3>Perform one last backup on the old machine</h3>
<p>You will be performing a backup + restore to move your data to the new box. To ensure you have a final backup, first block access to your box to all services besides SSH so that no new emails are sent or received. Log into your old machine using SSH and run:</p>
<pre>sudo ufw reset
sudo ufw allow 22 # enable SSH access so you don't lock yourself out
sudo ufw enable</pre>
<p>Then perform a backup to ensure you have everything backed up since the last nightly backup run. Run:</p>
<pre>cd mailinabox
sudo management/</pre>
<h3>Create a new box</h3>
<p>Start by creating a new Mail-in-a-Box machine: Spin up a new machine following the setup guide&rsquo;s section <a href="guide.html#machine">The Machine</a>. <em>Use as many of the same settings as on your original box as makes sense.</em> On Digital Ocean you will need to use the exact same name for your box as you did previously or reverse DNS won&rsquo;t work.</p>
<p>Then follow the steps in the setup guide&rsquo;s section <a href="guide.html#setup">Setting Up The Box</a>. When you are prompted for the box&rsquo;s hostname, you will need to use the hostname that you are currently using.</p>
<h3>Restore your mail data (and other files)</h3>
<p>Next you&rsquo;ll restore your mail data and other files to the new machine.</p>
<h4>Locating your backup secret key</h4>
<p>Your backups are encrypted, and you will need your backup secret key to restore from the backup.</p>
<p>You should have already stored the backup secret key in a safe place &mdash; like in your home &mdash; per the backup instructions in the control panel. If you haven&rsquo;t done that yet... now is the time! The file is located on your old box at <code>/home/user-data/backup/secret_key.txt</code>. Copy that file to a safe place now.</p>
<p>Copy that file onto your new box. Any SFTP program like <a href="">FileZilla</a> can help you with that. (SFTP is like SSH, so you will use the same login credentials as you use with SSH.)</p>
<h4>Restoring backup files</h4>
<h5>Local backups</h5>
<p>If you are using the default backup method, which stores backups on the box itself, then hopefully you have figured out how to periodically copy those files somewhere else safe &mdash; otherwise what&rsquo;s the point!</p>
<p>Using any SFTP program like <a href="">FileZilla</a> (or <code>scp</code> if you know how) copy your backups from wherever you stored them to somewhere on your new machine. If your old box is still running, then just copy them from <code>/home/user-data/backup/encrypted</code> on your old box.</p>
<p>Then restore the files:</p>
<pre>export PASSPHRASE=$(cat your_backup_secret_key_file.txt)
sudo -E duplicity restore --force file:///path/to/copied/files /home/user-data/</pre>
<h5>Amazon S3 backups</h5>
<p>If your backups are stored in Amazon S3, get your account credentials handy and then run a duplicity restore:</p>
<pre>export AWS_ACCESS_KEY_ID=paste your AWS access key ID here
export AWS_SECRET_ACCESS_KEY=paste your AWS secret access key here
export PASSPHRASE=$(cat your_backup_secret_key_file.txt)
sudo -E duplicity restore --force s3:// /home/user-data/</pre>
<p>You may have to adjust the S3 URL depending on what AWS region you use. You can find the AWS Regions and Endpoints <a href="">here</a></p>
<h3>Re-configure the box</h3>
<p>Re-run Mail-in-a-Box setup now that your old files are back:</p>
<pre>sudo mailinabox</pre>
<p>Your box should be functioning now. Log into the control panel on your new box to see if things look right.</p>
<h3>Update your DNS</h3>
<p>Finally, update your domain name&rsquo;s glue records to the new machine&rsquo;s IP address (see the setup guide&rsquo;s section on <a href="guide.html#machine">glue records</a>.</p>
<p>DNS can take a few hours to update, so wait a while, and then see if the control panel&rsquo;s status checks report any problems and that your devices are picking up mail on your new box.</p>
<p>(Skip this if you are just testing your backups.)</p>
<div class="hidden-xs" style="height: 200px"> </div>
<script src=""> </script>
<script src=""></script>
if ($(window).width() >= 768) {
// scroll spy with a fixed TOC doesn't work on small screens
$('#nav').attr('data-spy', 'affix');