This is a cache of https://docs.okd.io/4.15/backup_and_restore/application_backup_and_restore/oadp-3scale/backing-up-3scale-api-management-by-using-oadp.html. It is a snapshot of the page at 2025-06-08T03:00:11.856+0000.
Backing up 3scale <strong>api</strong> Management by using OADP - OADP Application backup and restore | Backup and restore | OKD 4.15
×

You can back up Red Hat 3scale api Management components by backing up the 3scale operator, and databases such as MySQL and Redis.

Prerequisites

Creating the Data Protection Application

You can create a Data Protection Application (DPA) custom resource (CR) for Red Hat 3scale api Management.

Procedure
  1. Create a YAML file with the following configuration:

    Example dpa.yaml file
    apiVersion: oadp.openshift.io/v1alpha1
    kind: DataProtectionApplication
    metadata:
      name: dpa-sample
      namespace: openshift-adp
    spec:
      configuration:
        velero:
          defaultPlugins:
            - openshift
            - aws
            - csi
          resourceTimeout: 10m
        nodeAgent:
          enable: true
          uploaderType: kopia
      backupLocations:
        - name: default
          velero:
            provider: aws
            default: true
            objectStorage:
              bucket: <bucket_name> (1)
              prefix: <prefix> (2)
            config:
              region: <region> (3)
              profile: "default"
              s3ForcePathStyle: "true"
              s3Url: <s3_url> (4)
            credential:
              key: cloud
              name: cloud-credentials
    1 Specify a bucket as the backup storage location. If the bucket is not a dedicated bucket for Velero backups, you must specify a prefix.
    2 Specify a prefix for Velero backups, for example, velero, if the bucket is used for multiple purposes.
    3 Specify a region for backup storage location.
    4 Specify the URL of the object store that you are using to store backups.
  2. Create the DPA CR by running the following command:

    $ oc create -f dpa.yaml

Backing up the 3scale api Management operator, secret, and apiManager

You can back up the Red Hat 3scale api Management operator resources, and both the Secret and apiManager custom resource (CR).

Prerequisites
  • You created the Data Protection Application (DPA).

Procedure
  1. Back up your 3scale operator CRs, such as operatorgroup, namespaces, and subscriptions, by creating a YAML file with the following configuration:

    Example backup.yaml file
    apiVersion: velero.io/v1
    kind: Backup
    metadata:
      name: operator-install-backup (1)
      namespace: openshift-adp
    spec:
      csiSnapshotTimeout: 10m0s
      defaultVolumesToFsBackup: false
      includedNamespaces:
      - threescale   (2)
      includedResources:
      - operatorgroups
      - subscriptions
      - namespaces
      itemOperationTimeout: 1h0m0s
      snapshotMoveData: false
      ttl: 720h0m0s
    1 The value of the metadata.name parameter in the backup is the same value used in the metadata.backupName parameter used when restoring the 3scale operator.
    2 Namespace where the 3scale operator is installed.

    You can also back up and restore ReplicationControllers, Deployment, and Pod objects to ensure that all manually set environments are backed up and restored. This does not affect the flow of restoration.

  2. Create a backup CR by running the following command:

    $ oc create -f backup.yaml
    Example output
    backup.velero.io/operator-install-backup created
  3. Back up the Secret CR by creating a YAML file with the following configuration:

    Example backup-secret.yaml file
    apiVersion: velero.io/v1
    kind: Backup
    metadata:
      name: operator-resources-secrets (1)
      namespace: openshift-adp
    spec:
      csiSnapshotTimeout: 10m0s
      defaultVolumesToFsBackup: false
      includedNamespaces:
      - threescale
      includedResources:
      - secrets
      itemOperationTimeout: 1h0m0s
      labelSelector:
        matchLabels:
          app: 3scale-api-management
      snapshotMoveData: false
      snapshotVolumes: false
      ttl: 720h0m0s
    1 The value of the metadata.name parameter in the backup is the same value used in the metadata.backupName parameter used when restoring the Secret.
  4. Create the Secret backup CR by running the following command:

    $ oc create -f backup-secret.yaml
    Example output
    backup.velero.io/operator-resources-secrets created
  5. Back up the apiManager CR by creating a YAML file with the following configuration:

    Example backup-apimanager.yaml file
    apiVersion: velero.io/v1
    kind: Backup
    metadata:
      name: operator-resources-apim (1)
      namespace: openshift-adp
    spec:
      csiSnapshotTimeout: 10m0s
      defaultVolumesToFsBackup: false
      includedNamespaces:
      - threescale
      includedResources:
      - apimanagers
      itemOperationTimeout: 1h0m0s
      snapshotMoveData: false
      snapshotVolumes: false
      storageLocation: ts-dpa-1
      ttl: 720h0m0s
      volumeSnapshotLocations:
      - ts-dpa-1
    1 The value of the metadata.name parameter in the backup is the same value used in the metadata.backupName parameter used when restoring the apiManager.
  6. Create the apiManager CR by running the following command:

    $ oc create -f backup-apimanager.yaml
    Example output
    backup.velero.io/operator-resources-apim created
Additional resources

Backing up a MySQL database

You can back up a MySQL database by creating and attaching a persistent volume claim (PVC) to include the dumped data in the specified path.

Prerequisites
  • You have backed up the Red Hat 3scale api Management operator.

Procedure
  1. Create a YAML file with the following configuration for adding an additional PVC:

    Example ts_pvc.yaml file
    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: example-claim
      namespace: threescale
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 1Gi
      storageClassName: gp3-csi
      volumeMode: Filesystem
  2. Create the additional PVC by running the following command:

    $ oc create -f ts_pvc.yml
  3. Attach the PVC to the system database pod by editing the system-mysql deployment to use the MySQL dump:

    $ oc edit deployment system-mysql -n threescale
      volumeMounts:
        - name: example-claim
          mountPath: /var/lib/mysqldump/data
        - name: mysql-storage
          mountPath: /var/lib/mysql/data
        - name: mysql-extra-conf
          mountPath: /etc/my-extra.d
        - name: mysql-main-conf
          mountPath: /etc/my-extra
        ...
          serviceAccount: amp
      volumes:
            - name: example-claim
              persistentVolumeClaim:
                claimName: example-claim (1)
        ...
    1 The PVC that contains the dumped data.
  4. Create a YAML file with following configuration to back up the MySQL database:

    Example mysql.yaml file
    apiVersion: velero.io/v1
    kind: Backup
    metadata:
      name: mysql-backup (1)
      namespace: openshift-adp
    spec:
      csiSnapshotTimeout: 10m0s
      defaultVolumesToFsBackup: true
      hooks:
        resources:
        - name: dumpdb
          pre:
          - exec:
              command:
              - /bin/sh
              - -c
              - mysqldump -u $MYSQL_USER --password=$MYSQL_PASSWORD system --no-tablespaces
                > /var/lib/mysqldump/data/dump.sql (2)
              container: system-mysql
              onError: Fail
              timeout: 5m
      includedNamespaces:
      - threescale
      includedResources: (3)
      - deployment
      - pods
      - replicationControllers
      - persistentvolumeclaims
      - persistentvolumes
      itemOperationTimeout: 1h0m0s
      labelSelector:
        matchLabels:
          app: 3scale-api-management
          threescale_component_element: mysql
      snapshotMoveData: false
      ttl: 720h0m0s
    1 The value of the metadata.name parameter in the backup is the same value used in the metadata.backupName parameter used when restoring the MySQL database.
    2 A directory where the data is backed up.
    3 Resources to back up.
  5. Back up the MySQL database by running the following command:

    $ oc create -f mysql.yaml
    Example output
    backup.velero.io/mysql-backup created
Verification
  • Verify that the MySQL backup is completed by running the following command:

    $ oc get backups.velero.io mysql-backup -o yaml
    Example output
    status:
    completionTimestamp: "2025-04-17T13:25:19Z"
    errors: 1
    expiration: "2025-05-17T13:25:16Z"
    formatVersion: 1.1.0
    hookStatus: {}
    phase: Completed
    progress: {}
    startTimestamp: "2025-04-17T13:25:16Z"
    version: 1

Backing up the back-end Redis database

You can back up the Redis database by adding the required annotations and by listing which resources to back up using the includedResources parameter.

Prerequisites
  • You backed up the Red Hat 3scale api Management operator.

  • You backed up your MySQL database.

  • The Redis queues have been drained before performing the backup.

Procedure
  1. Edit the annotations on the backend-redis deployment by running the following command:

    $ oc edit deployment backend-redis -n threescale
    annotations:
    post.hook.backup.velero.io/command: >-
             ["/bin/bash", "-c", "redis-cli CONFIG SET auto-aof-rewrite-percentage
             100"]
           pre.hook.backup.velero.io/command: >-
             ["/bin/bash", "-c", "redis-cli CONFIG SET auto-aof-rewrite-percentage
             0"]
  2. Create a YAML file with the following configuration to back up the Redis database:

    Example redis-backup.yaml file
    apiVersion: velero.io/v1
    kind: Backup
    metadata:
      name: redis-backup (1)
      namespace: openshift-adp
    spec:
      csiSnapshotTimeout: 10m0s
      defaultVolumesToFsBackup: true
      includedNamespaces:
      - threescale
      includedResources:
      - deployment
      - pods
      - replicationcontrollers
      - persistentvolumes
      - persistentvolumeclaims
      itemOperationTimeout: 1h0m0s
      labelSelector:
        matchLabels:
          app: 3scale-api-management
          threescale_component: backend
          threescale_component_element: redis
      snapshotMoveData: false
      snapshotVolumes: false
      ttl: 720h0m0s
    1 The value of the metadata.name parameter in the backup is the same value used in the metadata.backupName parameter used when restoring the restoring the Redis database.
  3. Back up the Redis database by running the following command:

    $ oc create -f redis-backup.yaml
    Example output:
    backup.velero.io/redis-backup created
Verification
  • Verify that the Redis backup is completed by running the following command:

    $ oc get backups.velero.io redis-backup -o yaml
    Example output:
    status:
    completionTimestamp: "2025-04-17T13:25:19Z"
    errors: 1
    expiration: "2025-05-17T13:25:16Z"
    formatVersion: 1.1.0
    hookStatus: {}
    phase: Completed
    progress: {}
    startTimestamp: "2025-04-17T13:25:16Z"
    version: 1