GoAdmio

cb

Copy a GoAdmio backup file, or all backups, from the local /backup folder to a remote server over SCP

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


Overview

/go/cb ("copy backup") sends a backup made by backup to the /backup folder of another server. It can:

Once the file is on the remote server, you can restore it there with restore.


Quick start

# Copy the newest backup of a domain to another server
/go/cb example.com 203.0.113.10 'RemoteRootPassword'

Syntax

/go/cb <file|domain|all> <remote-server> <remote-password>
Argument Description
<file|domain|all> A backup file name, a domain name, or all.
<remote-server> The IP address or host name of the remote server. It must contain a dot.
<remote-password> The root password of the remote server.

Any argument you leave out is asked for with a prompt: File Name:, Remote Server:, and Remote Password:. The password is shown on screen as you type it.


Options

Value of the first argument What it does
A domain, such as example.com Copies the newest file in /backup whose name contains it.
A file name, such as example.com.tar.gz Copies that backup file. Give the name only, with no path.
all Copies every .tar.gz file in /backup, one after another.

Rules

Item Rule
File or domain Must contain a dot, and must not contain /.
Remote server Must contain a dot.
File type The file must end in .tar.gz.
Remote folder Always /backup, as root, on SSH port 22.

Output

On success the command prints one line, and nothing else:

Copying /backup/<file>.tar.gz To 203.0.113.10:/backup
Message Meaning
Invalid file name or domain name The first argument has no dot.
Do not enter file path <file>, Just file name or domain name. The first argument contains /.
Invalid Remote Server <server>. The server name has no dot.
File <file> not exists. No matching .tar.gz file was found.

The copy runs in quiet mode, so errors from the copy itself are not shown, and the command ends without a success or failure message. See Checking the result.

Each run adds a line to /var/log/go/cb.log, with the password replaced by ********.


Examples

# Newest backup of a domain
/go/cb example.com 203.0.113.10 'RemoteRootPassword'
# One backup file (use the real file name from /backup)
/go/cb example.com.tar.gz backup.example.net 'RemoteRootPassword'
# Every backup in /backup
/go/cb all 203.0.113.10 'RemoteRootPassword'
# Ask for everything
/go/cb
# Check that the file arrived
ssh root@203.0.113.10 'ls -lh /backup'

Troubleshooting

Symptom Likely cause Fix
File <file> not exists. No file in /backup contains that name, or the match is not a .tar.gz file. Check the name with ls /backup.
Nothing is copied and no error appears Wrong password, root login is off on the remote server, the server is unreachable, or sshpass is missing. Test with ssh root@<server>, and see permitrootlogin.
The file does not appear in /backup on the remote server The remote server has no /backup folder, so the file is saved under the name /backup. Create the folder on the remote server, then copy again.
The wrong domain's backup was copied The domain name also appears inside another backup name. Give the full file name.
all asks for the server and password for every file They were not given as arguments. Pass them: /go/cb all <server> '<password>'.
Connection fails on a custom SSH port The command always uses port 22. Use another copy method, or see port.

Details

How the file is found

  1. If the first argument is all, the command goes through /backup and runs itself for each file that ends in .tar.gz, then stops.
  2. Otherwise it takes the newest file in /backup whose name contains the first argument. The match is by part of the name, not the whole name.
  3. If that file does not end in .tar.gz, it looks for the given file name in /home and then in /root.
  4. If it still has no .tar.gz file, it stops with File <file> not exists.

What it does, in order

  1. Logs the run, hiding the password.
  2. Asks for any missing argument.
  3. Checks the file, folder, and server names.
  4. Finds the local file.
  5. Prints the Copying ... line.
  6. Copies the file with sshpass and scp to /backup on the remote server as root. A file with the same name there is replaced.

Checking the result

The command ends with status 0 after the copy step, even when the copy failed. Check the remote server instead:

ssh root@<remote-server> 'ls -lh /backup'

Security

[!WARNING]

  • The password on the command line can be seen in the process list and is saved in your shell history. The command's own history -c does not clear the history of your login shell.
  • The password is shown on screen when typed at the prompt.
  • SSH host key checking is turned off and known hosts are not saved, so the identity of the remote server is not verified.

Known issues


See also

Command Description
backup Create a backup for all GoAdmio accounts (local and remote)
restore Restore a GoAdmio backup from the command line
copy Copy a GoAdmio site from one server to another
fsync Copy a directory from your local server to a remote server
serversync Back up and migrate a GoAdmio server with all configurations
permitrootlogin Allow root SSH login from a specific IP