Backing up and restoring the user data on Ubuntu

To secure the user data in HCL OneTest Server that is installed on the Ubuntu server, you can back up the user data. At any point in time, after you install HCL OneTest Server, you can restore the backed-up user data.

Before you begin

You must have completed the following tasks:

  • Been granted with the same permissions that are required for installing and uninstalling the software.

  • Been granted with the sudo access.

  • Communicated to the users that HCL OneTest Server might be unavailable for some time until the process is complete.

About this task

You may need to back up and restore the user data in the following scenarios:

  • Move the existing environment to a new system.

  • Change the release name or the namespace.

  • Back up the user data at regular intervals and restore the backed-up data when required.

Backing up the user data

You can back up the user data in HCL OneTest Server and use the backed-up data to restore at any point in time.

Procedure

  1. Log in to the Ubuntu server and open a terminal.
  2. Add the software registry to Helm by running the following command:
    helm repo add hclsoftware https://hclcr.io/chartrepo/ot --username {okta-email-address} --password {harbor-cli-secret}
    Note: You must replace {okta-email-address} with the user name of the Harbor repository and replace {harbor-cli-secret} with the secret key that you copied from the Harbor repository.

    If the user name contains any special characters, such as $, you must enclose it within single quotes.

  3. Run the following command to extract the base:
    helm pull --untar hclsoftware/hcl-onetest-base --version 4.1013.0
  4. Change to the hcl-onetest-base directory.

    This directory contains the backup.sh script which is required to complete the backup operation.

  5. Create a directory that contains metadata related to the Persistent Volume Claims and their Persistent Volumes by running the following command:
    sudo ./backup.sh create-pvc-links

    You can use the following optional parameter along with the create-pvc-links command:

    --volumes or -v: Use this parameter to specify the directory path of the Volumes.

    For example, backup.sh create-pvc-links -v hcl-onetest-base/my-pvc-links creates a directory called my-pvc-links that stores the metadata required for backup.

    Remember:
    • If you did not provide the volume parameter, by default, the command creates a sub-directory in the same directory where you have the backup script.

    • You must ensure that the directory you create must be empty or not exist to avoid script failure.

    • If you specify a directory by using the -v parameter, then you must use the same parameter value when you restore the data.

  6. Run the following command to stop the cluster and HCL OneTest Server:
    k3s-killall.sh
  7. Run the following command to create a backup of the existing user data:
    sudo ./backup.sh create [options] <backup-file-name>

    After you run this command, a backup of the local Persistent Volumes is created. The backup is created as tar archives that is compressed by using gzip (.tar.gz). The create command archives the Persistent Volumes into the <backup-file-name>.

    You can use the following parameters along with the create command:

    • --namespace or -n: Use this parameter to back up the Persistent Volumes in the specified namespace. If you do not mention the namespace, then all the Volumes from all the namespaces are included in the backup. The syntax is:
      -namespace <name of the namespace>
    • --volumes or -v: Use this parameter to specify the directory path of the Volumes. The syntax is:
      -volumes <path-of-the-directory>
      Remember:
      • If you did not provide the volume parameter, by default, the command creates a sub-directory in the same directory where you have the backup script.

      • If you specify a directory by using the -v parameter, then you must use the same parameter value when you restore the data.

    For example,
    sudo ./backup.sh create --namespace test-system my-backup.tar.gz
    This command creates a backup file named my-backup.tar.gz that contains all of the Persistent Volumes associated with pods available in the test-system namespace.
  8. Run the following command to restart the cluster and HCL OneTest Server:
    sudo systemctl start k3s

Restoring the user data

You can restore the user data that is backed up in HCL OneTest Server at any point in time after you install latest version of server software.

About this task

The following procedure is for the restoration of the server data from the current release. If you are upgrading the server software, then you can restore the server data from the earlier version to the latest version during the installation of the server software. For more information, see the Related information section.

Procedure

  1. Log in to the Ubuntu server and open a terminal.
  2. Add the software registry to Helm by running the following command:
    helm repo add hclsoftware https://hclcr.io/chartrepo/ot --username {okta-email-address} --password {harbor-cli-secret}
    Note: You must replace {okta-email-address} with the user name of the Harbor repository and replace {harbor-cli-secret} with the secret key that you copied from the Harbor repository.

    If the user name contains any special characters, such as $, you must enclose it within single quotes.

  3. Run the following command to extract the base:
    helm pull --untar hclsoftware/hcl-onetest-base --version 4.1013.0
  4. Change to the hcl-onetest-base directory.
    This directory contains the backup.sh script which is required to complete the restore operation.
  5. If you have not already done so, create a directory that contains metadata related to the Persistent Volume Claims and their Persistent Volumes by running the following command:
    sudo ./backup.sh create-pvc-links

    You can use the following optional parameter along with the create-pvc-links command:

    --volumes or -v: Use this parameter to specify the directory path of the Volumes.

    For example, backup.sh create-pvc-links -v hcl-onetest-base/my-pvc-links creates a directory called my-pvc-links that stores the metadata required to restore your user data.

    Remember:
    • If you did not provide the volume parameter, by default, the command creates a sub-directory in the same directory where you have the backup script.

    • You must ensure that the directory you create must be empty or not exist to avoid script failure.

  6. Run the following command to stop the cluster and HCL OneTest Server:
    k3s-killall.sh
  7. Run the following command to restore the backed-up user data:
    sudo ./backup.sh restore [options] <backup-file-name>

    The restore command overwrites the existing Persistent Volumes with data from the <backup-file-name>.

    You can use the following parameters along with the restore command:

    • --namespace or -n: Use this parameter to restore a specific namespace from the backup file. If you do not mention the namespace, then volumes from all the namespaces in the backup file are restored. You can map one namespace to another namespace by using colon (:). The syntax is:
      --namespace <name of the namespace> [:<target-namespace>]
    • --release or -r: Use this parameter if the helm release name of the server to which the backup is being restored is different than the helm release name of the server where the backup was taken. The syntax is:
      --release <backup-release>:<target-release>
    • --volumes or -v: Use this parameter to specify the directory path of the Volumes. The syntax is:
      --volumes <path-of-the-directory>
    • -k or --confirm: Use this parameter to skip the confirmation step.

    For example,
    sudo ./backup.sh restore --namespace test-system:new-test-system -r rel-1:rel-2 -k my-backup.tar.gz

    This command restores the volumes that are backed up from the rel-1 release in the test-system namespace to the rel-2 release in the new-test-system namespace and skips the confirmation step.

  8. Run the following command to restart the cluster and HCL OneTest Server:
    sudo systemctl start k3s
    Note:
    • The cluster and HCL OneTest Server might take some time to restart and until that time, you cannot access the HCL OneTest Server URL.

    • You can run the kubectl get pods -A command to verify that the Kubernetes environment is working. After a while, the status of the pods must be Running state.

Results

You have backed up or restored the user data for HCL OneTest Server.

What to do next

After you migrate the server data from a previous version to a newer version, the Project Owner must log in to HCL OneTest Server so that other members of the project can access the test assets in that project.