This is a cache of https://docs.openshift.com/acs/4.0/backup_and_restore/restore-acs.html. It is a snapshot of the page at 2024-11-24T17:44:40.274+0000.
Restoring from a backup | Backup and restore | Red Hat Advanced Cluster Security for Kubernetes 4.0
×

You can restore Red Hat Advanced Cluster Security for Kubernetes from an existing backup by using the roxctl command-line interface (cli).

Depending upon your requirements and the data you have backed up, you can restore from the following types of backups:

  1. Restore Central database from the Central database backup: Use this to recover from a database failure or data corruption event. It allows you to restore and recover the Central database to its earlier functional state.

  2. Restore Central from the Central deployment backup: Use this if you are migrating Central to another cluster or namespace. This option restores the configurations of your Central installation.

Restoring Central database by using the roxctl cli

You can use the roxctl cli to restore Red Hat Advanced Cluster Security for Kubernetes by using the restore command. You require an API token or your administrator password to run this command.

Restoring by using an API token

You can restore the entire database of Red Hat Advanced Cluster Security for Kubernetes by using an API token.

Prerequisites
  • You must have a Red Hat Advanced Cluster Security for Kubernetes backup file.

  • You must have an API token with the administrator role.

  • You must have installed the roxctl cli.

Procedure
  1. Set the ROX_API_TOKEN and the ROX_CENTRAL_ADDRESS environment variables:

    $ export ROX_API_TOKEN=<api_token>
    $ export ROX_CENTRAL_ADDRESS=<address>:<port_number>
  2. Run the restore command:

    $ roxctl -e "$ROX_CENTRAL_ADDRESS" central db restore <backup_file>

Restoring by using the administrator password

You can restore the entire database of Red Hat Advanced Cluster Security for Kubernetes by using your administrator password.

Prerequisites
  • You must have a Red Hat Advanced Cluster Security for Kubernetes backup file.

  • You must have the administrator password.

  • You must have installed the roxctl cli.

Procedure
  1. Set the ROX_CENTRAL_ADDRESS environment variable:

    $ export ROX_CENTRAL_ADDRESS=<address>:<port_number>
  2. Run the restore command:

    $ roxctl -p <admin_password> -e "$ROX_CENTRAL_ADDRESS" central db restore <backup_file>

Resuming the restore operation

During a restore operation, if your connection is interrupted or you need to go offline, you can resume the restore operation.

  • If you do not have access to the machine running the resume operation, use the roxctl central db restore status command to check the status of an ongoing restore operation.

  • In case of connection interruptions, the roxctl cli automatically tries to restore a task when the connection becomes available. The automatic connection retries depend on the duration specified by the timeout option.

  • Use the --timeout option to specify the time in seconds, minutes, or hours, after which the roxctl cli stops trying to resume a restore operation. If not specified, the default timeout is 10 minutes (10m).

  • If a restore operation is stuck or if you want to cancel it, use the roxctl central db restore cancel command to cancel an ongoing restore operation.

  • If a restore operation is stuck, or you have canceled it, or it timed out, you can resume the previous restore by re-running the original command.

  • During interruptions, Red Hat Advanced Cluster Security for Kubernetes caches an ongoing restore operation for 24 hours. You can resume this operation by re-running the original restore command.

  • The --timeout option only governs client-side connection retries and does not affect the 24 hours server-side restore cache.

  • You cannot resume restore operations across restarts of the Central pod.

  • If a restore operation is interrupted, you must restart it within 24 hours and before Central restarts, otherwise Red Hat Advanced Cluster Security for Kubernetes cancels the restore operation.

Restoring Central deployment using the roxctl cli

You can restore your Central deployment to its original configuration by using the backups you made.

You must first restore certificates by using the roxctl cli, and then restore the Central deployment by running the Central installation scripts.

Restore certificates using the roxctl cli

Use the roxctl cli to generate Kubernetes manifests to install the RHACS Central component to your cluster. Doing this allows you to ensure that authentication certificates for Secured clusters and the API tokens remain valid for the restored version. If you backed up another instance of RHACS Central, you can use the certificate files from that backup.

With the roxctl cli, you can not restore the entire Central deployment. Instead, first you use the roxctl cli to generate new manifests using the certificates in your central data backup. Afterwards, you use those manifests to install Central.

Prerequisites
  • You must have the Red Hat Advanced Cluster Security for Kubernetes backup file.

  • You must have installed the roxctl cli.

Procedure
  1. Run the interactive install command:

    $ roxctl central generate interactive
  2. For the following prompt, enter the path of the Red Hat Advanced Cluster Security for Kubernetes backup file:

    Enter path to the backup bundle from which to restore keys and certificates (optional): _<backup-file-path>_
  3. For other following prompts, press Enter to accept the default value or enter custom values as required.

On completion, the interactive install command creates a folder named central-bundle, which has the necessary YAML manifests and scripts to deploy Central.

Running the Central installation scripts

After you run the interactive installer, you can run the setup.sh script to install Central.

Procedure
  1. Run the setup.sh script to configure image registry access:

    $ ./central-bundle/central/scripts/setup.sh
  2. Create the necessary resources:

    $ oc create -R -f central-bundle/central
  3. Check the deployment progress:

    $ oc get pod -n stackrox -w
  4. After Central is running, find the RHACS portal IP address and open it in your browser. Depending on the exposure method you selected when answering the prompts, use one of the following methods to get the IP address.

    Exposure method Command Address Example

    Route

    oc -n stackrox get route central

    The address under the HOST/PORT column in the output

    https://central-stackrox.example.route

    Node Port

    oc get node -owide && oc -n stackrox get svc central-loadbalancer

    IP or hostname of any node, on the port shown for the service

    https://198.51.100.0:31489

    Load Balancer

    oc -n stackrox get svc central-loadbalancer

    EXTERNAL-IP or hostname shown for the service, on port 443

    https://192.0.2.0

    None

    central-bundle/central/scripts/port-forward.sh 8443

    https://localhost:8443

    https://localhost:8443

If you have selected autogenerated password during the interactive install, you can run the following command to see it for logging into Central:

$ cat central-bundle/password

Restore Central deployment using the RHACS Operator

You can restore your Central deployment to its original configuration by using the RHACS Operator. To successfully restore, you need the backup of your Central custom resource, central-tls, and the administrator password.

Prerequisites
  • You must have the central-tls backup file.

  • You must have the Central custom resource backup file.

  • You must have the administrator password backup file.

Procedure
  1. Use the central-tls backup file to create resources:

    $ oc apply -f central-tls.json
  2. Use the central-htpasswd backup file to create secrets:

    $ oc apply -f central-htpasswd.json
  3. Use the central-cr.yaml file to create the Central deployment:

    $ oc apply -f central-cr.yaml

Restore Central deployment using Helm

You can restore your Central deployment to its original configuration by using Helm. To successfully restore, you need the backup of your Central custom resource, the central-tls secret, and the administrator password.

Prerequisites
  • You must have the Helm values backup file.

  • You must have a Red Hat Advanced Cluster Security for Kubernetes backup file.

  • You must have installed the roxctl cli.

Procedure
  1. Generate values-private.yaml from the RHACS database backup file:

    $ roxctl central generate k8s pvc --backup-bundle _<path-to-backup-file>_ --output-format "helm-values"
  2. Run the helm install command and specify your backup files:

    $ helm install -n stackrox --create-namespace stackrox-central-services rhacs/central-services -f central-values-backup.yaml -f central-bundle/values-private.yaml

Restoring central to another cluster or namespace

You can use the backups of the RHACS Central database and the deployment to restore Central to another cluster or namespace.

The following list provides a high-level overview of installation steps:

  1. Depending upon your installation method, you must first restore Central deployment by following the instructions in the following topics:

    • Make sure to use the backed-up Central certificates so that secured clusters and API tokens issued by the old Central instance remain valid.

    • If you are deploying to another namespace, you must change the namespace in backed-up resources or commands.

  2. Restore Central database by following the instruction in the Restoring Central database by using the roxctl cli topic.

  3. If you have an external DNS entry pointing to your old RHACS Central instance, you must reconfigure it to point to the new RHACS Central instance that you create.