Chapter 10. 3scale backup and restore using custom resources


This chapter includes details about the backup and restore functionality for a Red Hat 3scale API Management installation deployed using the APIManager custom resource (CR). In this context, the CRD is provided by the 3scale operator.

Custom resources from operator capabilities are not part of the 3scale installation. For this reason, the custom resources are not included as part of the 3scale installation backup and restore functionality.

Prerequisites

  • A 3scale installation

The following sections contain the procedures to perform 3scale backup and restore using the operator.

10.1. Backing up 3scale using the operator

The following section provides the information and procedure you require to backup a 3scale installation that was deployed by an APIManager custom resource (CR).

10.1.1. Backup compatible scenarios

To see the 3scale installation configurations that can be backed up, see the following sections:

Prerequisites

  • Backup the 3scale external databases:

    • backend-redis
    • system-redis
    • system-database
    • zync (optional)
  • Provision enough space for the PVC to contain the data backed up.
Note

If you deploy 3scale with the APIManager, you cannot use Amazon S3 as system’s FileStorage.

For more information on external databases, see External databases installation.

10.1.2. Backup scenarios scope

Backup functionality is available when the following databases are configured externally:

  • Backend Redis database
  • System Redis database
  • System database - MySQL or PostgreSQL
  • Zync database (optional)

10.1.3. Backed up data

The following table shows a list of the data that is backed up.

Table 10.1. Data that is backed up
ObjectObject-type data

Secrets

  • system-smtp
  • system-seed
  • backend-internal-api
  • backend-listener
  • system-events-hook
  • system-app
  • system-recaptcha
  • zync
  • system-master-apicast
  • system-memcache
  • system-database
  • backend-redis
  • system-redis

ConfigMaps

  • system-environment
  • apicast-environment

APIManager

APIManager CR Kubernetes object definition - json schema definition

System FileStorage

When the location of System FileStorage is in a PersistentVolumeClaim (PVC)

10.1.4. Backing up 3scale

To backup a 3scale installation deployed with an existing APIManager, use the following steps:

Procedure

  1. Backup the following Kubernetes secrets:

    • backend-redis
    • system-redis
    • system-database
    • zync (optional)
  2. Create the APIManagerBackup CR in the same namespace where the 3scale installation managed by the APIManager object is deployed, as in example one:

    Example 1

      apiVersion: apps.3scale.net/v1alpha1
      kind: APIManagerBackup
      metadata:
       name: example-apimanagerbackup-pvc
      spec:
        backupDestination:
          persistentVolumeClaim:
            resources:
              requests: "10Gi"

    Example 2 provides a pre-existing PersistentVolume name:

      apiVersion: apps.3scale.net/v1alpha1
      kind: APIManagerBackup
      metadata:
       name: example-apimanagerbackup-pvc
      spec:
        backupDestination:
          persistentVolumeClaim:
            # resources specification is required but ignored when providing a volumeName as per K8s PVCs requirements behavior
            resources:
              requests: "10Gi"
            volumeName: "my-preexisting-persistent-volume"

  3. Wait until APIManagerBackup finishes. Check this by obtaining the content of APIManagerBackup and waiting until the .status.completed field is set to true.

The backup contents is detailed in Backed up data.

Other fields in the status section of the APIManagerBackup show details of the backup, such as the name of the PVC where the data has been backed up when the configured backup destination has been a PVC.

For future references, take note of the value of status.backupPersistentVolumeClaimName field. When restoring an APIManager installation with APIManagerRestore, one of the fields it requires is the PersistentVolumeClaimName backup source.

10.1.5. Backing up 3scale custom resources

If you do not have copies of your CRs outside of the OpenShift administrator account, create a backup of the 3scale project CRs using the following commands:

  • Type the following command to export the ActiveDocs CR from your 3scale project:

    oc get activedocs.capabilities.3scale.net -o yaml > activedocs.yaml
  • Type the following command to export the backend CR from your 3scale project:

    oc get backend.capabilities.3scale.net -o yaml > backend.yaml
  • Type the following command to export the CustomPolicyDefinition CR from your 3scale project:

    oc get custompolicydefinition.capabilities.3scale.net -o yaml > custompolicydefinition.yaml
  • Type the following command to export the DeveloperAccount CR from your 3scale project:

    oc get developeraccount.capabilities.3scale.net -o yaml > developeraccount.yaml
  • Type the following command to export the DeveloperUser CR from your 3scale project:

    oc get developeruser.capabilities.3scale.net -o yaml > developeruser.yaml
  • Type the following command to export OpenAPI CR from your 3scale project:

    oc get openapi.capabilities.3scale.net -o yaml > openapi.yaml
  • Type the following command to export the product CR from your 3scale project:

    oc get product.capabilities.3scale.net -o yaml > product.yaml
  • Type the following command to export the tenant CR from your 3scale project:

    oc get tenant.capabilities.3scale.net -o yaml > tenant.yaml

10.2. Restoring 3scale using the operator

The following section provides the information and procedure you require to restore a 3scale installation that was previously deployed by an APIManager custom resource and backed up by APIManagerBackup.

10.2.1. Restore compatible scenarios

To see the 3scale installation configurations that can be restored, see the following sections:

Prerequisites

  • Restore the 3scale external databases:

    • backend-redis
    • system-redis
    • system-database - MySQL or PostgreSQL
    • zync (optional)

10.2.2. Restore scenarios scope

The restore functionality of the 3scale operator is available using a backup generated from an APIManagerBackup custom resource.

For a list of the 3scale solution scenarios you can backup, see Backed up data for reference.

The following are not in the scope of the restore functionality of the operator:

  • Restoring backup data that was not performed using an APIManagerBackup custom resource.
  • Restoring backup data provided through an APIManagerBackup from different 3scale versions.

10.2.3. Restored data

The following table shows a list of the data that is restored.

Table 10.2. Data that is restored
ObjectObject-type data

Secrets

  • system-smtp
  • system-seed
  • backend-internal-api
  • system-events-hook
  • system-app
  • system-recaptcha
  • zync
  • system-master-apicast

ConfigMaps

  • system-environment
  • apicast-environment

APIManager

APIManager custom resource Kubernetes object definition - json schema definition

System FileStorage

When the location of System FileStorage is in a PersistentVolumeClaim (PVC)

Routes

3scale-related OpenShift routes, for example master and tenants

10.2.4. Restoring 3scale

To restore a 3scale installation previously deployed with an APIManager that was backed up using an APIManagerBackup custom resource, follow these steps:

  1. Ensure that the project where you are performing the restoration does not contain an APIManager custom resource and its corresponding 3scale installation.
  2. Restore the following Kubernetes secrets:

    • backend-redis
    • system-redis
    • system-database
    • zync secret if zync was an external database
  3. Create the APIManagerRestore custom resource and specify the backup data of the installation that was previously backed up by an APIManagerBackup custom resource.

    For details, see Backup scenarios scope.

    The following is an example of an APIManagerRestore custom resource:

      apiVersion: apps.3scale.net/v1alpha1
      kind: APIManagerRestore
      metadata:
        name: example-apimanagerrestore-pvc
      spec:
       restoreSource:
         persistentVolumeClaim:
           claimSource:
             claimName: example-apimanagerbackup-pvc # Name of the PVC produced as the backup result of an `APIManagerBackup`
             readOnly: true
  4. Wait until APIManagerRestore finishes. Check this by obtaining the content of APIManagerRestore and waiting until the .status.completed field is set to true.

    You should see a new APIManager custom resource has been created and a 3scale installation deployed.

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.