GoAdmio

restoremail

Recreate a domain's missing email accounts from the mailbox folders in /home/<domain>/mail (accounts already in GoAdmio are skipped; passwords are not restored)

On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also


Overview

/go/restoremail rebuilds the list of email accounts of a domain from the mailbox folders on disk. Use it when the mail files are present but the accounts are missing from GoAdmio, for example after you restored a domain's files from a backup. It:

It restores accounts only. Passwords, forwarding, autoresponders, and other settings are not restored (see What is not restored).


Quick start

# Recreate the missing accounts of example.com
/go/restoremail example.com

# Then set passwords for the accounts

Set the passwords with mailpwd, because the recreated accounts do not get a password you know.


Syntax

/go/restoremail <domain>
Form Behavior
/go/restoremail <domain> Creates an account for each mailbox folder that has none.

If the command is not run as root, it runs itself again through sudo.


Options

This command has no options. It takes the domain as its only argument.

Argument Required Default Notes
<domain> Yes — The domain whose mail folder is used. Pass it exactly as the folder is named in /home.

Output

The command prints nothing when it works. There is no list of the accounts it created, so a quiet run is normal. Messages come only from errors, and from mail for each account it creates.

Message Meaning
Domain <domain> not exists. /home/<domain>/mail is not a folder. This also appears if you pass no domain.

Every run is also recorded in /var/log/go/restoremail.log.


Examples

# Recreate the missing accounts of a domain
/go/restoremail example.com
# See which mailbox folders exist on disk
ls /home/example.com/mail
# See which accounts GoAdmio now has for the domain
sudo sqlite3 /var/lib/sqlite/mail.db "select Email from Mail where Email like '%@example.com'"

Troubleshooting

Symptom Likely cause Fix
Domain <domain> not exists. The mail folder is missing, the domain is misspelled, or no domain was given. The message is the same even if the domain's account exists but has no mail folder. Check ls /home/<domain>/mail, and pass the domain as it appears in /home.
Nothing happens and no account is created Every folder already has an account, or the mail folder is empty. Compare the folder names with the accounts (see Examples).
An error about *@<domain> The mail folder is empty, so the loop runs once with the literal name *. Restore the mailbox folders first.
An unexpected account appears Every entry in the mail folder is treated as a user name, including stray folders or files. Remove the stray entry before running the command, or delete the extra account afterwards.
Users can't log in to the recreated accounts Passwords are not restored. Set passwords with mailpwd.
Forwarding, autoresponders, or other settings are gone Only the account is recreated. Set them again, for example with forward and responder.
New accounts don't receive mail The mail server's maps may not include them yet. Rebuild them with vmail.
Ownership of the mail files changed The command sets the owner of the whole mail folder to vmail:vmail. None. This is what the mail server needs.

Details

What it does

  1. Runs itself again through sudo if the command is not run as root, and writes the command and its arguments to /var/log/go/restoremail.log.
  2. Stops with Domain <domain> not exists. if /home/<domain>/mail is not a folder.
  3. Sets the owner of everything in /home/<domain>/mail to vmail:vmail, for existing and recreated accounts alike.
  4. Takes each entry in the mail folder as a user name, and builds the address <name>@<domain>.
  5. Looks the address up in the Mail table of /var/lib/sqlite/mail.db. If it is already there, it is skipped.
  6. Otherwise, runs mail with --action add for that address.

Existing accounts are never changed, apart from the ownership change in step 3.

What is not restored

The command passes empty values to mail for every setting except the address, domain, and action. That means:

Other notes


See also

Command Description
mail Create an email address in GoAdmio via the command line
mailpwd Bulk-change passwords for all email accounts of a single domain
vmail Rebuild the Postfix/Dovecot vmail maps
copymail Copy a domain's mailboxes to the same domain on another GoAdmio server
restore Restore accounts, databases, SSL certificates, or folders from local or remote GoAdmio backups
forward Configure per-domain email forwarding
responder Create or delete an email autoresponder