GoAdmio Command Line: copy with /go/copy

/go/copy migrates a hosting account from this server to another GoAdmio server. For each domain it: The source account is not changed, suspended, or deleted, and DNS is not updated. After the copy, both servers hold the site. Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.

Quick start

# Copy one account to another GoAdmio server
/go/copy example.com 203.0.113.10 'RemoteRootPassword'

Options

copy takes positional arguments, not -- options.

Position Name Required Default Notes
1 Domain, or all Yes — Must exist in the Site table, or the command prints Domain <domain> not exists. and exits.
2 Remote server Yes — IP address or hostname of the destination server.
3 Remote root password Yes — Used with sshpass for every SSH and rsync connection.
4 SSH port No 22

Internal modes

The command calls itself on the remote server with these flags. They are not meant to be run by hand, and each one exits with status 1.

Call What it does
copy <domain> <username> --shadow Replaces the user’s line in /etc/shadow with the line saved in /home/<domain>/log/shadow, then deletes that file.
copy <database> <user> <hash> --grant Sets the database user’s password hash with GRANT USAGE ... IDENTIFIED BY PASSWORD.
copy <database> --import Imports /usr/local/goadmio/tmp/<database>.sql into the database, with a pv progress bar.

The flags are detected anywhere in the argument list, so avoid passwords or domains that contain --shadow, --grant, or --import.

Examples

# One account, default SSH port
/go/copy example.com 203.0.113.10 'RemoteRootPassword'

# One account, SSH on port 2222
/go/copy example.com 203.0.113.10 'RemoteRootPassword' 2222

# Every account on this server
/go/copy all 203.0.113.10 'RemoteRootPassword'

[1/12] Copying example.com...
Copying example.com to 203.0.113.10...
Creating Account example.com...
Copying WWW Files example.com...
.

Output

Progress is printed as the copy runs. rsync shows its own transfer progress, and a . follows each rsync step.

Message Meaning
[<n>/<total>] Copying <domain>... Progress line in all mode.
Copying <domain> to <server>... Start of one account.
Creating Account <domain>... create runs on the remote server. Its JSON result is printed.
Copying WWW Files <domain>... www folder transfer.
Copying MAIL Files <domain>... mail folder transfer.
Copying SQLITE Files <domain>... sqlite folder transfer.
Set Password <domain>... Linux password hash copied.
Set Up Mail <domain>... Mail accounts recreated from the mail folders.
Copying Databases... MySQL/MariaDB databases dumped and imported.
Missing Domain No arguments were given.
Domain <domain> not exists. The domain is not in the Site table.
Instance (copy) already running. An all run started less than an hour ago holds the lock.

Exit status

Situation Exit status
Single domain copied 0, unless the last cleanup command fails.
No arguments, unknown domain, or lock held 1
all mode Always 1, even after a successful run.
Internal modes Always 1.

Security

[!WARNING]
Every run appends all its arguments to /var/log/go/copy.log, so the remote root password is stored there in plain text. The password is also visible in ps output and in your shell history. The database root password is passed on the command line to mariadb and mariadb-dump in the same way.

After a migration, remove the line from /var/log/go/copy.log and your shell history, and change the remote server’s root password. SSH host key checking is turned off for these connections, so run the command only over a network you trust.

See the full reference at /go/copy and the GoAdmio command index.

GoAdmio is free and open source, with no license fees and no account limits. Read the GoAdmio docs, or see why it is a free cPanel alternative at goadmio.com.

By:

Posted in:


Leave a Reply

Your email address will not be published. Required fields are marked *