

# Install a backup agent

You install a backup agent on each host that runs an agent-based resource. The agent is the same for every agent-based resource type. You download the agent package and your appliance's agent certificate from the AWS Backup console, or with the `GetAgentDownload` operation from the AWS CLI or an SDK. Both give you the correct agent version for your appliance.

The installer doesn't install the agent without the agent certificate. The certificate ties the agent to one appliance: the agent works only with the appliance whose certificate you installed it with. For more information, see [About the agent certificate](#backup-agents-certificate).

## Before you install
<a name="backup-agents-install-prereqs"></a>
+ The host runs a supported operating system. See [Supported operating systems and versions](backup-onprem-agents.md#backup-agents-os-support).
+ The host has 56 MB of free disk space on Windows, or 360 MB on Linux.
+ On Linux, the packages that the agent needs are installed. See [Linux package dependencies](prepare-linux-windows-servers.md#servers-linux-dependencies).
+ The host and the appliance can reach each other on the agent ports. See [Network requirements and ports](appliance-network.md).
+ No other backup agent is installed on the host. A host can have only one backup agent at a time.
+ For a clustered resource, plan to install the agent on every node of the cluster. See [Install the agent on clustered resources](#backup-agents-install-clustered).

## Installation steps
<a name="backup-agents-install-steps"></a>

1. Download the agent package and the agent certificate for the appliance that will protect the host. See [Download the agent package and certificate](#backup-agents-install-download).

1. Verify the agent package. See [Verify the agent package](#backup-agents-verify-installer).

1. Copy the installer and the agent certificate to the host, and run the installer with the certificate. See [Run the installer](#backup-agents-certificate-install).

1. Confirm that the agent service is running, and delete your copy of the certificate from the host. See [After installation](#backup-agents-certificate-after).

1. Register the resource with the same appliance. See [Register resources](register-resources.md).

## Download the agent package and certificate
<a name="backup-agents-install-download"></a>

Download the agent for the appliance that will protect the host, so that AWS Backup gives you the agent version for that appliance. The following table lists the agent platforms.


| Agent platform in the console | `--platform` value | Operating systems | 
| --- | --- | --- | 
| Windows installer | WINDOWS | Windows | 
| Linux (RPM) | LINUX\_RPM | RHEL and its derivatives, including Amazon Linux | 
| Linux (SUSE RPM) | LINUX\_SUSE\_RPM | SUSE | 
| Linux (Debian) | LINUX\_DEB | Debian and Ubuntu | 
| Linux (script installer) | LINUX\_SCRIPT | Any supported Linux operating system | 

**To download the agent from the console**

1. In the AWS Backup console, open the details page of your appliance.

1. In the **Agents** panel, choose **Manage agents**. The **Download and manage agents** page opens.

1. Under **Agents**, find the row for the host's agent platform and choose **Download**.

1. In the **Download agent** dialog, check the agent version, and then download the files that the dialog lists:
   + **Agent package** (required). A .zip file that holds the installer.
   + **Signing certificate** (Linux platforms only). You use it to verify the installer. Windows installers carry their signature inside the .exe file, so the dialog doesn't offer a signing certificate for Windows.
   + **AgentCertificateBundle** (required). The agent certificate for this appliance. Installation fails without it. You can use the same file for every agent that you install for this appliance.

### Download with the AWS CLI or an SDK
<a name="backup-agents-certificate-get"></a>

Call `GetAgentDownload` with the ARN of the appliance that will protect the host and the agent platform for the host. For example, with the AWS CLI:

```sh
aws backup-external get-agent-download \
    --appliance-arn arn:aws:backup-external:{{region}}:{{account-id}}:appliance:{{appliance-id}} \
    --platform LINUX_RPM
```

The response contains the following values:


| Value | Description | 
| --- | --- | 
| AgentDownloadUrl | Presigned URL for the agent package, a .zip file. For Linux platforms, it holds the installer and its signature file ({{installer}}.sig). For Windows, it holds only the signed installer. | 
| AgentVersion | The version of the agent. | 
| SigningCertificateDownloadUrl | URL for the signing certificate that verifies a Linux installer. Not used for Windows. | 
| AgentCertificateBundleDownloadUrl | Presigned URL for this appliance's agent certificate. | 

The presigned URLs are valid for 15 minutes, so download the files right away. Don't store the URLs or paste them into logs, tickets, or chats. If a URL expires, call `GetAgentDownload` again.

## Verify the agent package
<a name="backup-agents-verify-installer"></a>

Before you install the agent, verify that AWS signed it. Don't install an agent whose signature doesn't verify. How you verify depends on the platform.

**Linux.** The agent package holds the installer and its signature file. Extract them, and verify the installer with the signing certificate:

```sh
unzip {{agent-package}}.zip    # extracts {{installer}} and {{installer}}.sig
openssl x509 -in {{signing-certificate}}.pem -pubkey -noout > signing_pub.pem
openssl dgst -sha256 -verify signing_pub.pem -signature {{installer}}.sig {{installer}}
```

The last command must print `Verified OK`.

**Windows.** The agent package holds only the installer. The signature is built into the installer, so there is no separate signing certificate. Extract the installer, and then in PowerShell run:

```powershell
Get-AuthenticodeSignature .\{{installer}}.exe | Format-List Status, SignerCertificate
```

Confirm that `Status` is `Valid` and that the signer is Amazon Web Services, Inc. You can also check the **Digital Signatures** tab in the installer's **Properties**.

## Run the installer
<a name="backup-agents-certificate-install"></a>

Copy the installer and the agent certificate to the host. Make sure that the installer can read the certificate file. Then run the installer as root or as an administrator, and pass it the path to the certificate file.

**Linux.** Set `AGENT_CERT_FILE` to the absolute path of the certificate file.


| Installer | Command | 
| --- | --- | 
| RPM and SUSE RPM | sudo AGENT\_CERT\_FILE={{/path/agent\_cert\_bundle}} rpm -ivh {{installer}}.rpm | 
| Debian and Ubuntu | sudo AGENT\_CERT\_FILE={{/path/agent\_cert\_bundle}} dpkg -i {{installer}}.deb | 
| Script installer | sudo AGENT\_CERT\_FILE={{/path/agent\_cert\_bundle}} ./{{installer}} -- --install --yes-all. Run chmod \+x on the installer first. | 

For Oracle, install the agent on each database host. To run the agent service as a dedicated account instead of the default account, use the script installer with the `-c`, `-S`, and `-G` options:

```sh
sudo AGENT_CERT_FILE={{/path/agent_cert_bundle}} ./{{installer}} -- --install -c 0 -S {{oracle-user}} -G {{oracle-group}} --yes-all
```
+ `-c 0` runs the agent service as an existing user. Use `-S` for the user and `-G` for its group.
+ `-c 1` creates a new user to run the agent service. Use `-S` and `-G` to name the user and group. If you leave them out, the installer creates a user and group named `awsbackupexternal`.

**Windows.** In an elevated command prompt or PowerShell session, run the installer with the path to the certificate file. SQL Server hosts use the Windows agent.

```
"{{installer}}.exe" /VERYSILENT /NORESTART /SUPPRESSMSGBOXES /customcertstype=cohesitycustomcerts /cohesitycustomcertpath={{C:\path\agent_cert_bundle}}
```

If the installer can't read the certificate file, the install fails. If it can read the file but the file isn't a valid agent certificate, the agent is installed but doesn't start. In either case, download the certificate again and reinstall the agent.

## After installation
<a name="backup-agents-certificate-after"></a>

Confirm that the agent service is running. On Linux, the service is `aws-backup-external`. On Windows, it is `AwsBackupExternal`. Then delete your copy of the certificate file from the host.

The installer stores its own copy of the certificate, which only the agent can read. This copy persists across agent restarts and agent upgrades, so you don't pass the certificate again for those operations.


| Installer | Stored certificate | Owner and permissions | 
| --- | --- | --- | 
| RPM, SUSE RPM, and Debian | /etc/aws-backup-external/server\_cert | root:root, mode 0400 | 
| Script installer | /home/awsbackupexternal/aws-backup-external/data/config/server\_cert | The account that the agent runs as (awsbackupexternal by default), mode 0400 | 
| Windows | C:\\ProgramData\\Amazon\\AwsBackupExternal\\Cert\\server\_cert | Administrators and SYSTEM, read and delete | 

After you register the resource, the appliance replaces this certificate with a per-host certificate during the first synchronization. You take no action.

## Install the agent on clustered resources
<a name="backup-agents-install-clustered"></a>

For a clustered resource, such as an Oracle Real Application Clusters (Oracle RAC) deployment, install the agent on *all* nodes of the cluster before you register the resource. Registration fails if any node is missing the agent.

AWS Backup shows a single, aggregated agent status for a clustered resource rather than one status per node. If the agent on any node is out of date, the combined status reflects that. Upgrade the agent on every node so that the whole cluster stays within the supported versions. For more information, see [Agent version compliance](backup-agents-upgrade.md#backup-agents-compliance).

## About the agent certificate
<a name="backup-agents-certificate"></a>

Each appliance issues its own *agent certificate* when you create the appliance. The AWS Backup console calls this file the **AgentCertificateBundle**. An agent installed with the certificate works only with the appliance that issued it. If you register the resource with a different appliance, its first synchronization fails.

The agent certificate is per appliance, not per host. For example, if you have one appliance and twenty hosts, you download one certificate and use it for all twenty installations. If you have more than one appliance, use the certificate of the appliance that will protect the host.

The agent certificate is distinct from the *signing certificate*. The signing certificate verifies that a Linux installer is authentic. The agent certificate establishes which appliance the agent works with.

### Handle the certificate file securely
<a name="backup-agents-certificate-secure"></a>

The certificate file contains your appliance's agent certificate and an encrypted private key. Treat it as sensitive: store it with the same care as other credentials, don't attach it to support cases or chats, and don't share it outside the account that owns the appliance. Delete copies that you no longer need, including your copy on each host after the agent is installed.

### If you lose or delete the certificate
<a name="backup-agents-certificate-lost"></a>

If you lose the certificate file before you install an agent, download it again from the AWS Backup console or with `GetAgentDownload`. You get the same certificate each time.

Don't delete the agent's stored certificate or its configuration from the host. If either is deleted after you register the resource, the appliance can't recognize the agent, and synchronization, agent upgrades, backups, and restores of the resource fail.

## Move a host to a different appliance
<a name="backup-agents-certificate-move"></a>

An agent works only with the appliance whose certificate it holds. To protect a host with a different appliance, for example a new appliance, a replacement appliance, or the destination of a resource migration, replace the agent's certificate with that appliance's certificate. You don't need to reinstall the agent. Unregistering the resource doesn't remove the old certificate.

1. Download the agent certificate of the new appliance. See [Download the agent package and certificate](#backup-agents-install-download).

1. On the host, rename the stored certificate. For its location, see [After installation](#backup-agents-certificate-after).

1. Copy the new appliance's certificate to the same path, with the same file name, owner, and permissions as the original. For example:
   + Linux (RPM, SUSE RPM, and Debian):

     ```sh
     sudo chown root:root {{cert-path}}
     sudo chmod 0400 {{cert-path}}
     sudo ls -l {{cert-path}}    # expect -r-------- root root
     ```

     For the script installer, set the owner to the account that the agent runs as, for example `sudo chown awsbackupexternal:awsbackupexternal {{cert-path}}`.
   + Windows:

     ```
     icacls "{{cert-path}}" /inheritance:r
     icacls "{{cert-path}}" /grant:r "BUILTIN\Administrators:(R,D)"
     icacls "{{cert-path}}" /grant:r "NT AUTHORITY\SYSTEM:(R,D)"
     icacls "{{cert-path}}"
     ```

1. Restart the agent.
   + Linux (RPM, SUSE RPM, and Debian):

     ```sh
     cd /opt/aws-backup-external/agent/software/crux/bin
     sudo ./aws_linux_agent.sh stop && sudo ./aws_linux_agent.sh start
     ```

     For the script installer, run the same commands from `/home/awsbackupexternal/aws-backup-external/software/crux/bin`.
   + Windows: `Restart-Service AwsBackupExternal`

1. Register the resource with the new appliance, or migrate it to the new appliance. On the first synchronization, the new appliance replaces the certificate with a per-host certificate.

1. After the resource is registered with the new appliance, delete the renamed certificate.

For a clustered resource such as Oracle RAC, replace the certificate on every node.

## Uninstall the agent
<a name="backup-agents-uninstall"></a>

Run the uninstall command for the host's installer as root or as an administrator. The agent's configuration is how the appliance recognizes a registered agent. To reinstall the agent and keep using it with the same appliance, keep the configuration, and copy the stored certificate (see [After installation](#backup-agents-certificate-after)) before you uninstall.


| Installer | Command | Agent configuration | 
| --- | --- | --- | 
| RPM and SUSE RPM | sudo rpm -e aws-backup-external | Kept as agent.cfg.rpmsave. | 
| Debian and Ubuntu | sudo dpkg --purge aws-backup-external | Deleted. To keep it, use --remove instead of --purge. | 
| Script installer | sudo /home/awsbackupexternal/aws-backup-external/software/crux/bin/setup.sh -U -y | Deleted. To keep it, leave out -y, and decline when the uninstaller asks to delete the configuration. | 
| Windows | "C:\\Program Files\\Amazon\\AwsBackupExternal\\Installer\\unins000.exe" /VERYSILENT /NORESTART /SUPPRESSMSGBOXES | Deleted. To keep it, add /preservesettings. | 