/go/copywww copies the website files in /home/<from>/www/ into /home/<to>/www/. The destination can be another domain on this server, or a domain on a remote server reached over SSH. After the copy, it sets the destination files' owner to the destination account. Use it to clone a site, set up a staging copy, or move a site's files to a new server. Only files are copied. Databases, mail, DNS, and SSL certificates are not. Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.
Quick start
# Copy example.com's website files to staging.example.com on this server
/go/copywww example.com staging.example.com
[!WARNING]
Files with the same name in the destination are overwritten, and the copy never deletes anything. For a local copy, the command refuses to run if the destination already has anindex.php,index.html, orindex.htm, unless you add--force. That safety check doesn’t exist for copies to a remote server.
Arguments
| Position | Argument | Required | Notes |
|---|---|---|---|
| 1 | <from domain> |
Yes | The source. /home/<from>/www/ must exist on this server. |
| 2 | <to domain> |
Yes | The destination. The account must already exist, locally or on the remote server. |
| 3 | --force |
No | Local copies only. Skips the check for an existing index file. |
| 3 | <remote server> |
Remote copies | An IP address or hostname that contains a dot. |
| 4 | <remote root password> |
Remote copies | The root SSH password of the remote server. Use single quotes if it contains special characters. |
A custom SSH port can’t be used. The script reads a fifth argument as a port, but a fifth argument makes the command print Invalid Parameters, so remote copies always use port 22.
Examples
# Create a staging copy on the same server
/go/copywww example.com staging.example.com
# Overwrite a destination that already has an index file
/go/copywww example.com staging.example.com --force
# Copy to the same domain on a remote server
/go/copywww example.com example.com 203.0.113.20 'RemoteRootPassword'
# Copy to a different domain name on a remote server, without saving the password in your shell history
read -rs RemotePass
/go/copywww example.com newexample.com 203.0.113.20 "$RemotePass"
# Compare folder sizes after copying
du -sh /home/example.com/www /home/staging.example.com/www
Output
| Situation | What you see |
|---|---|
| Local copy | Transferring files from <from> to <to>... is printed after the copy has finished. |
| Remote copy | Transferring files from <from> to <to>... is printed before the copy starts. |
| Destination already has an index file | Unable to copy files, The directory /home/<to>/www is not empty. The command exits with status 1. |
| Remote server name has no dot | Invalid Remote Server <server> and exit status 1. |
| Wrong number of arguments | Invalid Parameters |
The copy itself prints nothing, apart from errors. The status line is printed even if the copy failed, so don’t treat it as a sign of success.
Every run is logged with a timestamp, for example [Nov 20 09:15:02]# copywww example.com staging.example.com 203.0.113.20 ********. The log shows the first three arguments and then asterisks, so the remote password is not saved in it.
See the full reference at /go/copywww 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.
