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)
- Command:
/go/restoremail - Category: Email
- Required option:
<domain> - Output: None, apart from errors and anything
mailprints - Last updated: 2026-11-20
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:
- looks at every folder in
/home/<domain>/mail, where each folder name is an email user name - skips every account that already exists in GoAdmio
- creates the missing accounts with
mail, one for each folder - sets the ownership of the whole mail folder to the mail user
vmail
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
- Runs itself again through
sudoif the command is not run as root, and writes the command and its arguments to/var/log/go/restoremail.log. - Stops with
Domain <domain> not exists.if/home/<domain>/mailis not a folder. - Sets the owner of everything in
/home/<domain>/mailtovmail:vmail, for existing and recreated accounts alike. - Takes each entry in the mail folder as a user name, and builds the address
<name>@<domain>. - Looks the address up in the
Mailtable of/var/lib/sqlite/mail.db. If it is already there, it is skipped. - Otherwise, runs
mailwith--action addfor 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:
- Passwords. The script generates a random password, but never passes it on (it is stored in a variable that the loop doesn't use). The password of a recreated account is whatever
mailsets when none is given. Set passwords yourself withmailpwd. - Settings. Forwarding, rejection rules, keep-a-copy, the default address, suspension, the admin flag, and the description are all empty, so they are not restored.
Other notes
- The script reads the MariaDB root password but does not use it.
- The folder check appears twice in the script, with different messages. Only the first can ever run, so you will only see
Domain <domain> not exists..
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 |