copymail
Copy a domain's mailboxes to the same domain on another GoAdmio server
- Command:
/go/copymail - Category: Migration
- Required arguments:
<domain>,<remote server>,<remote root password> - Output: None unless an error occurs (also logged to
/var/log/go/copymail.log) - Last updated: 2026-11-20
On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also
Overview
/go/copymail copies a domain's mail folder, /home/<domain>/mail/, from this server to the same path on a remote GoAdmio server, then fixes file permissions on the remote server. It is used when moving a domain's email to a new server.
The domain keeps its name. This command does not copy mail from one domain to another on the same server.
Only the mail folder is copied. The website files, databases, DNS, and the hosting account itself are not. The account must already exist on the remote server (see Requirements).
Quick start
# Copy example.com's mail to the server at 203.0.113.20
/go/copymail example.com 203.0.113.20 'RemoteRootPassword'
[!WARNING] The remote root password is saved in plain text in
/var/log/go/copymail.log, although the log line ends with asterisks. It is also visible in the process list while the command runs, and the command doesn't verify the remote server's SSH host key. Use it only on a network you trust, and remove the password from the log afterwards.
Syntax
/go/copymail <domain> <remote server> <remote root password> [<port>]
Run it as root on the source server.
Arguments
| Position | Argument | Required | Default | Notes |
|---|---|---|---|---|
| 1 | <domain> |
Yes | — | The domain whose mail is copied. /home/<domain>/mail/ must exist on this server. |
| 2 | <remote server> |
Yes | — | The IP address or hostname of the destination server. |
| 3 | <remote root password> |
Yes | — | The root SSH password of the destination server. Put it in single quotes if it contains special characters. |
| 4 | <port> |
No | 22 |
The SSH port of the destination server. |
With fewer than three arguments the command prints Invalid Parameters and does nothing.
Output
The command prints nothing when it works, because rsync runs without verbose output. Errors from sshpass, rsync, or ssh are shown.
Every run is logged with a timestamp, for example [Nov 20 09:15:02]# copymail example.com 203.0.113.20 ********. The password appears in the log line before the asterisks. See the warning in Quick start.
Examples
# Copy mail to a server that uses the default SSH port
/go/copymail example.com 203.0.113.20 'RemoteRootPassword'
# Copy mail to a server that uses SSH port 2222
/go/copymail example.com 203.0.113.20 'RemoteRootPassword' 2222
# Avoid saving the password in your shell history
read -rs RemotePass
/go/copymail example.com 203.0.113.20 "$RemotePass" 2222
# Compare the size of the mail folder on both servers
du -sh /home/example.com/mail
ssh root@203.0.113.20 "du -sh /home/example.com/mail"
# Run it again just before switching DNS to copy mail that arrived in the meantime
/go/copymail example.com 203.0.113.20 'RemoteRootPassword'
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Invalid Parameters |
Fewer than three arguments were given. | Pass the domain, remote server, and remote root password. |
sshpass: command not found |
sshpass isn't installed on this server. |
Install it, then run again. |
Permission denied, please try again or rsync error ... (code 255) |
The password is wrong, root password login is disabled on the remote server, or the port is wrong. | Check the password and port. Allow root password login on the remote server (see permitrootlogin). |
rsync: mkdir ... failed: No such file or directory |
The account doesn't exist on the remote server. | Create it there first with create. |
sudo: command not found from the remote server |
The remote server needs sudo, because the copy runs sudo rsync there. |
Install sudo on the remote server. |
/go/fix: command not found |
GoAdmio isn't installed on the remote server. | Install GoAdmio there first. |
rsync: change_dir ... failed or No such file or directory for the source |
/home/<domain>/mail/ doesn't exist here. |
Check the domain name. |
| Mailboxes don't appear in the remote panel | The files were copied, but the mail accounts weren't recreated there. | Run restoremail on the remote server. |
| Wrong file ownership on the remote server | User IDs differ between the servers. | Run /go/fix <domain> on the remote server, or see checkid. |
| The copy is slow or was interrupted | Large mailboxes, or the connection dropped. | Run the command again. It copies only what is missing or changed. |
Details
Requirements
- Source server:
sshpassandrsyncinstalled, and run as root. - Remote server:
rsyncandsudoinstalled- SSH login as
rootwith a password allowed - GoAdmio installed, because the command runs
/go/fixthere - the domain's account already created, so
/home/<domain>exists
Steps
- Runs
/go/mailconf <domain>on this server. This command isn't listed in the command index. It prepares the domain's mail configuration before the copy. - Copies
/home/<domain>/mail/toroot@<remote server>:/home/<domain>/mail/withrsync. - Connects to the remote server over SSH and runs
/go/fix <domain>, which corrects file and folder permissions.
How the copy behaves
rsync option |
Effect |
|---|---|
-a |
Archive mode: keeps permissions, timestamps, ownership, and folder structure. |
-z |
Compresses data during the transfer. |
-l |
Copies symbolic links as links. |
-h |
Human-readable numbers (nothing is printed unless an error occurs). |
--rsync-path="sudo rsync" |
Runs rsync on the remote server through sudo. |
The copy is incremental: running it again transfers only new or changed files. Files that were deleted on this server are not deleted on the remote server. If a file differs on both servers, the source version replaces the remote one.
The SSH connection ignores and doesn't save host keys (StrictHostKeyChecking=no and UserKnownHostsFile=/dev/null), so it never asks to trust the remote server, but it also can't detect a server impersonating it.
The permissions step runs even if the copy failed, so check for errors before relying on the result.
See also
| Command | Description |
|---|---|
copy |
Copy a GoAdmio site from one server to another |
create |
Create a GoAdmio account from the command line |
fix |
Fix GoAdmio file and folder permissions |
restoremail |
Recreate mail accounts from folders on disk |
checkid |
Renumber UIDs/GIDs to match the source server |
copywww |
Copy the www directory from one domain to another |
permitrootlogin |
Allow root SSH login from a specific IP |