Follow the steps to back up IBM Cloud Pak® for Watson AIOps(CP4WAIOPS).
- Install Velero on your cluster, including the configuration of backup storage location. See ../install/Readme.md
- Workstation machine must have Linux base operating system and access to the internet.
- To run and monitor the backup from a workstation, ensure the workstation has access to the cluster
- Install
velero
,oc
,jq
,git
andHelm
CLIs on your workstation
git clone https://github.ibm.com/katamari/bcdr.git
oc login --token=<TOKEN> --server=<URL>
Where:
<TOKEN>
is the token that you use to log in to the OpenShift cluster.<URL>
is the OpenShift server URL.
-
Go to the directory
<Path of cp4waiops-bcdr>/bcdr
by running the following command:cd <Path of cp4waiops-bcdr>/bcdr
-
Build the
cp4waiops-bcdr
docker image by running following command:docker build -t cp4waiops-bcdr:latest -f backup/Dockerfile .
docker tag cp4waiops-bcdr:latest <Image Registry Server URL>/<Repository>/cp4waiops-bcdr:latest
docker login <Image Registry Server URL> -u <USERNAME>
docker push <Image Registry Server URL>/<Repository>/cp4waiops-bcdr:latest
Where:
<Image Registry Server URL>
is the image registry server URL.<Repository>
is the repository where you put the image.<USERNAME>
is the username to log in to the image registry server.
oc create secret docker-registry backup-secret -n velero --docker-server=<Image Registry Server URL> --docker-username=<USERNAME> --docker-password=<PASSWORD> --docker-email=<EMAIL>
Where:
<Image Registry Server URL>
is the image registry server URL.<USERNAME>
is the username to log in to the image registry server.<PASSWORD>
is the password to log in to the image registry server.<EMAIL>
is the email for image registry server.
-
Go to the directory
<Path of cp4waiops-bcdr>/bcdr/backup
by running the following command:cd <Path of cp4waiops-bcdr>/bcdr/backup
-
Update the following parameters in
values.yaml
,values.yaml
is located in./helm
:-
repository
: Name of the image for examplexy.abc.io/cp4waiops/cp4waiops-bcdr
. Herexy.abc.io
is the image registry server URL,cp4waiops
is the name of the repository andcp4waiops-bcdr
is the name of the Docker image. -
pullPolicy
: Policy to determine when to pull the image from the image registry server. For example, To force pull the image, use theAlways
policy. -
tag
: Tag of the Docker image for examplelatest
. -
pullSecret
: Name of the image pull secret. Refer to the value from step 6. -
schedule
: Cron expression for automated backup. For example, To take backup once a day, use the0 0 * * *
Cron expression. -
backupStorageLocation
: This isvelero
storage location where backed up data are stored. For examplebcdr-s3-location
. Use theoc get backupstoragelocation -n <velero-namespace>
command to get the backupStorageLocation on the OpenShift cluster. -
backupNameSuffix
: This is the prefix for the backup name when backup is created using job. Generally, it can be name of source cluster itself. For exampleaiops-cluster-backup-106
. -
aiopsNamespace
: Name of the namespace/project whereCP4WAIOPS
is installed in OpenShift source cluster. For examplecp4waiops
. -
csNamespace
: Name of the namespace/project whereIBM Common Services
is installed in OpenShift source cluster. For exampleibm-common-services
-
veleroNamespace
: Name of the namespace/project whereVelero
is installed in OpenShift source cluster. For examplevelero
-
ttl
: Time to live for backup. It means backup data will be retained until TTL expires. For example720h0m0s
-
enabledNamespaces
: Lists the namespaces that are associated for installed components. For example, theibm-common-services
namespace represents theIBM Common Services
component. You can delete the unused namespaces from the list to reduce the time taken for back up. You can update the list as shown if you have installed only two components, i.e.IBM Common Services
andCP4WAIOPS
enabledNamespaces: - '"ibm-common-services"' - '"cp4waiops"'
The following table lists the components and namespaces as an example:
Components Namespaces IBM Common Services ibm-common-services IBM Cloud Pak® for Watson AIOps cp4waiops -
enabledComponents
: Backup & Restore of AIOPs now supports backing and restoring of AIOPs as well as IA (Infrastructure Automation) components. Since IA is optional component and it can be installed indepenently of AIOPs and vice versa. A newenabledComponents
parameter is intorduced, this is passed as the List of the component to be backed up. Currently following two values are supportedIA
andAIOPS
. This is mandatory parameter and expects one of the two or both are expected, any other values will be ignored and corresponding error message will generated.enabledComponents: - '"IA"' - '"AIOPS"'
-
-
Package the Helm Chart.
helm package ./helm
-
Go to the directory
<Path of cp4waiops-bcdr>/bcdr/backup
by running the following command:cd <Path of cp4waiops-bcdr>/bcdr/backup
-
Deploy the backup job by running the following command:
helm install backup-job clusterbackup-0.1.0.tgz
-
Check the backup pods status by running the following command:
oc get pods -n velero
-
Check the backup job logs by running the following command:
oc logs -f <backup-job-***>
-
Check the backup status by running the following command:
velero get backup <BACKUP_NAME>
Where:
-
<BACKUP_NAME>
is the name of the Backup. You can see the backup name after the backup job is complete. For example, you might see the backup nameaiops-cluster-backup-106-1622193915
in the backup job log as follows:Waiting for backup aiops-cluster-backup-106-1622193915 to complete
-
-
Deploy the on-demand backup job by running the following command:
oc create job --from=cronjob/backup-job on-demand-backup-job -n velero
- This step is optional. Use only when you don't want to wait till the execution of the next scheduled backup job.
- Deployment of an automated backup job is a prerequisite for the on-demand job. Only after you initiate an automated backup job, then you can trigger an on-demand backup.
-
Check the on-demand backup pods status by running the following command:
oc get pods -n velero
-
Check the on-demand backup job logs by running the following command:
oc logs -f <on-demand-backup-job-***>
-
Check the backup status by running the following command:
velero get backup <BACKUP_NAME>
Where:
-
<BACKUP_NAME>
is the name of the Backup. You can see the backup name after the on-demand backup job is complete. For example, you might see the backup nameaiops-cluster-backup-106-1622193915
in the on-demand backup job log as follows:Waiting for backup aiops-cluster-backup-106-1622193915 to complete
-
Perform following steps to terminate the backup process :
-
Delete the velero pod.
oc delete pod <velero pod name> -n <velero installed namespace>
-
Delete the backup which got stucked in
In progress
state.velero delete backup <backup name>
-
Wait till backup script execution completion.
Error: admission webhook "trust.hooks.securityenforcement.admission.cloud.ibm.com" denied the request:
Deny "<Image Registry Server URL>/<Repository>/cp4waiops-bcdr:latest", no matching repositories in ClusterImagePolicy and no ImagePolicies in the "velero" namespace
Where:
<Image Registry Server URL>
is the image registry server URL.<Repository>
is the repository where you put the image.
As a fix perform the following steps:
-
Uninstall
backup-job
by running the following command:helm uninstall backup-job -n velero
-
Create a file
backup-image-policy.yaml
and add the following content to it:apiVersion: securityenforcement.admission.cloud.ibm.com/v1beta1 kind: ClusterImagePolicy metadata: name: backup-image-policy spec: repositories: - name: "<Image Registry Server URL>/<Repository>/cp4mcm-bcdr:latest" policy:
-
Apply the policy by running the following command:
oc apply -f backup-image-policy.yaml
-
Deploy the backup job by running the following command:
helm install backup-job clusterbackup-0.1.0.tgz