/go/copydatabase pushes one whole database from this server to a remote server. It: The copy goes one way, from the server you run the command on to the remote server. To copy a single table instead, use copytable. Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.
Quick start
# Copy the database shop_db to a remote server, keeping the same name
/go/copydatabase shop_db 203.0.113.10 'RemoteRootPassword'
Arguments
| # | Argument | Required | Default | Notes |
|---|---|---|---|---|
| 1 | database |
Yes | — | The local database to copy. |
| 2 | remote-server |
Yes | — | IP address or hostname of the remote server. |
| 3 | remote-password |
Yes | — | The remote server’s root SSH password. See Security. |
| 4 | target-database |
No | Same as database |
Database to import into on the remote server. It is created if it doesn’t exist. |
| 5 | ssh-port |
No | 22 |
SSH port of the remote server. |
The command does not validate its arguments. Use plain names (letters, numbers, and underscores) for the databases, because they are inserted into shell and SQL commands without quoting.
Examples
# Same database name on the remote server
/go/copydatabase shop_db 203.0.113.10 'RemoteRootPassword'
# Import into a different database name on the remote server
/go/copydatabase shop_db 203.0.113.10 'RemoteRootPassword' shop_copy
# Custom SSH port, same database name (note the empty fourth argument)
/go/copydatabase shop_db 203.0.113.10 'RemoteRootPassword' "" 2222
# Different database name and custom SSH port
/go/copydatabase shop_db 203.0.113.10 'RemoteRootPassword' shop_copy 2222
# Verify the result on the remote server
ssh -p 22 root@203.0.113.10 "mariadb -e 'SHOW TABLES FROM shop_copy;'"
# Delete the dump file afterwards (run on both servers)
rm -f /root/shop_db.sql
Output
The command prints a single progress line that updates in place:
Copying shop_db Database to 203.0.113.10 | Importing...
When you use a target database, the last step reads Importing to <target-database>....
The stages shown are Dumping..., Copying..., and Importing.... Unlike some other commands, the start line with your arguments is written to the log only and isn’t printed.
| Outcome | What you get |
|---|---|
| Copy attempted | The progress line, then exit status 0. |
| Any failure after the start | Usually an error message from the failing tool, and still exit status 0. |
[!WARNING]
The command does not check whether the dump, upload, or import worked. Exit status0and a finished progress line do not prove the database arrived. A wrong database name is not caught: the dump fails, but the command carries on and creates an empty database on the remote server. Check the result on the remote server (see Examples).
Security
[!WARNING]
The remote password is passed as a command-line argument and used withsshpass -p, so it can be visible in the process list and saved in your shell history. The log hides it, but nothing else does. SSH host key checking is also turned off, so the remote server’s identity is not verified.
See the full reference at /go/copydatabase 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.
