GoAdmio

smtpsync

Copy this server's SMTP configuration database to another GoAdmio server, replacing the one there, then rebuild the mail maps on that server

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


Overview

/go/smtpsync copies the global SMTP configuration database, /var/lib/sqlite/smtp.db, from this server to another GoAdmio server over SSH. Use it to keep a second server's SMTP settings the same as this one's, for example after you move accounts with copy or serversync.

After the copy, the command runs vmail on the remote server, so the Postfix and Dovecot mail maps are rebuilt there.

[!WARNING] The copy is one-way and replaces the database on the remote server. Anything that was only on the remote server's smtp.db is lost.


Quick start

/go/smtpsync 203.0.113.10 'RemoteRootPassword'

Syntax

/go/smtpsync <remote-server> <root-password> [ssh-port]

The command writes the call and a timestamp to /var/log/go/smtpsync.log. That log also contains the root password you typed. See Security.


Arguments

Position Argument Required Default Notes
1 <remote-server> Yes — The host name or IP address of the other server.
2 <root-password> Yes — The root SSH password of the other server. Quote it in single quotes.
3 [ssh-port] No 22 The SSH port of the other server. Pass it when the port was changed with port.

Nothing is validated. A wrong server or password shows up only as an SSH or rsync error.


Output

The first line says which server is being used:

Copying WA to 203.0.113.10...

[!NOTE] The text says "WA", but the file copied is the SMTP database. The word is a leftover from a similar command and doesn't affect what happens.

After that, rsync shows the file name and the transfer progress, then any output of vmail from the remote server. There is no final message, so you can't tell from the output alone whether the copy worked. Check that the remote server's /var/lib/sqlite/smtp.db has a recent modification time.


Examples

# Copy to a server on the default SSH port
/go/smtpsync 203.0.113.10 'RemoteRootPassword'
# Copy to a server whose SSH port is 2222
/go/smtpsync backup.example.com 'RemoteRootPassword' 2222
# Review recent calls (this log contains the passwords)
tail /var/log/go/smtpsync.log

Troubleshooting

Symptom Likely cause Fix
sshpass: command not found sshpass is not installed on this server. Install sshpass.
Permission denied or rsync error ... (code 255) Wrong password, or the remote server doesn't allow root to log in with a password from this server. Check the password. Allow the login with permitrootlogin on the remote server.
Connection refused, or it waits and times out Wrong port, or the remote firewall blocks SSH. Pass the right port as the third argument. Open it with allow on the remote server.
rsync: command not found on the remote side rsync is not installed on the remote server. Install rsync there.
/go/vmail: No such file or directory The remote server is not a GoAdmio server. Use a GoAdmio server.
The copy failed, but vmail still ran vmail runs even when the copy fails. Fix the cause and run the command again.
The remote server lost its own SMTP settings The database is replaced as a whole. By design. Back up the remote file before you run it.
Your password appears in /var/log/go/smtpsync.log The script logs every argument. Delete the entry. See Security.

Details

What it does

  1. Records the call, including the password, in the log.
  2. Uses port 22 if no port was given.
  3. Prints Copying WA to <remote-server>....
  4. Copies /var/lib/sqlite/smtp.db to the same path on the remote server as root, using rsync over SSH with the given password. File permissions, owner, and times are kept, and the data is compressed while it travels.
  5. Runs /go/vmail on the remote server over SSH.
flowchart TD
    A["smtpsync server password [port]"] --> B["Log the call"]
    B --> C["rsync smtp.db to root@server"]
    C --> D["ssh to server: run /go/vmail"]

What is and isn't changed

Item Result
/var/lib/sqlite/smtp.db on this server Not changed.
/var/lib/sqlite/smtp.db on the remote server Replaced with a copy of this server's file.
Postfix and Dovecot mail maps on the remote server Rebuilt by vmail.
Other files and databases Not copied.

The database is copied as a plain file while this server may be using it. If SMTP activity writes to it at that moment, the copy might be incomplete. Run the command at a quiet time, or run it again.

What is needed


Security


See also

Command Description
vmail Rebuild the Postfix/Dovecot vmail maps
smtp Manage the SMTP port: block, unblock, and change it
serversync Copy a whole GoAdmio server to another server over SSH
copy Copy one or all GoAdmio accounts to another GoAdmio server over SSH
copymail Copy a domain's mailboxes to the same domain on another GoAdmio server
sslsync Copy domain account SSL certificates from a local to a remote server
mysqlsync Copy MySQL databases from a local to a remote server
postgresync Copy PostgreSQL data to a remote server
permitrootlogin Allow root SSH login from a specific IP
port Change the default SSH port (22) to another port