Backup IBM API Connect Database Portal Subsystem on demand
This article will guide you through the process of creating and managing IBM API Connect portal backups on an OpenShift cluster.
Decide which type of backup you want to take
all
: backs up the Developer Portal system and all its sites.system
: backs up the Developer Portal system only.site
: backs up a specific Developer Portal site.
Verify the Portal Cluster Status
First, check the status of your portal cluster to ensure it is running correctly:
[root@BASTION backup]# oc get portalcluster
NAME READY STATUS VERSION RECONCILED VERSION MESSAGE AGE
apiconnect-production-ptl 4/4 Running 10.0.8.0 10.0.8.0-258 Serving 1 site 16d
Create the Backup Configuration File
touch portalbackup_cr.yaml
apiVersion: portal.apiconnect.ibm.com/v1beta1
kind: PortalBackup
metadata:
generateName: portal-bup-
spec:
type: all
portalCluster: apiconnect-production-ptl
crType: create
siteName: installed
comment: "This is will backup all installed portal"
Where:
type
is the backup type that you decided in first step.portalCluster
is the cluster name that you identified in second step.siteName
is the name of the portal site that you want to backup. This property applies only when backup type ofsite
is specified. Valid settings are:- Site UUID or URL — back up the specified site only.
installed
- backups all installed sites.comment
is a text comment to help you identify the reason for the backup, for example: "pre-upgrade backup".
Identify the UUID or URL (Skip this if you used installed)
If you want to use the UUID or URL you can identify the information using this command
[root@BASTION backup]# oc get po | grep www
apiconnect-e7a4c765-e7a4c765-www-0 2/2 Running 0 3h37m
[root@BASTION backup]# oc exec -it apiconnect-e7a4c765-e7a4c765-www-0 -c admin bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
bash-5.1$
bash-5.1$ list_sites
4c84946b-f34f-4468-8eb1-e74071a3535a.80ffce4a-c13c-418e-b0b0-05981844cc89 => portalapim.bankabc.co.id/bank-abc/production (INSTALLED)
bash-5.1$
Create the Backup Resource
Apply the configuration file to create the backup resource:
kubectl -n <namespace> create -f portalbackup_cr.yaml
[root@BASTION backup]# kubectl -n cp4i create -f portalbackup_cr.yaml
portalbackup.portal.apiconnect.ibm.com/portal-bup-f4nqc created
Verify the Backup Status
kubectl -n cp4i get portalbackup --sort-by=.status.backupId
[root@BASTION backup]# kubectl -n cp4i get portalbackup --sort-by=.status.backupId
NAME ID TASK ID STATUS TYPE CR TYPE CLUSTER AGE COMMENT
portal-record-nlclf 20240731.082439 n/a Ready site record apiconnect-production-ptl 2m12s
portal-record-pfqcg 20240731.082446 n/a Ready system record apiconnect-production-ptl 2m12s
portal-bup-f4nqc n/a c7qk2ts5n8d28a2v Ready all create apiconnect-production-ptl 2m43s This is will backup all installed portal
Retrieve Detailed Backup Information
Make sure the backup file is successfully uploaded, on the status.conditions.message, find information that said file successfully uploaded.
_portal_system_backup-20240731.082446.tar.gz successfully uploaded
kubectl -n cp4i get portalbackup <backup-name> -o yaml
[root@BASTION backup]# kubectl -n cp4i get portalbackup portal-bup-f4nqc -o yaml
apiVersion: portal.apiconnect.ibm.com/v1beta1
kind: PortalBackup
metadata:
creationTimestamp: "2024-07-31T08:24:31Z"
generateName: portal-bup-
generation: 1
name: portal-bup-f4nqc
namespace: cp4i
ownerReferences:
- apiVersion: portal.apiconnect.ibm.com/v1beta1
blockOwnerDeletion: true
controller: true
kind: PortalCluster
name: apiconnect-production-ptl
uid: 59194b8d-7aac-4c5a-808f-2b403af8473d
resourceVersion: "140492560"
uid: 2f9dcbce-735a-45a2-90ea-6624a7ba5411
spec:
comment: This is will backup all installed portal
crType: create
portalCluster: apiconnect-production-ptl
siteName: installed
type: all
status:
backupId: n/a
commentLeft: This is will backup all installed portal
conditions:
- lastTransitionTime: "2024-07-31T08:24:32Z"
message: ""
reason: BackupStatusUnknown
status: "False"
type: Warning
- lastTransitionTime: "2024-07-31T08:24:32Z"
message: |
2024-07-31 08:24:32: CLI task (backup:all) starting.
2024-07-31 08:24:32: Testing authentiation to destination /apicbackup/DC2/ptlb on 192.168.192.168:22 sftp
2024-07-31 08:24:32: Uploading connection_test to 192.168.192.168:22:/apicbackup/DC2/ptlb/ using sftp
2024-07-31 08:24:33: Making a backup for site portalapim.bankabc.co.id/bank-abc/production
2024-07-31 08:24:45: A local backup was successfully created: /var/aegir/backups/portalapim.bankabc.co.id@bank-abc@production-20240731.082439.tar.gz
2024-07-31 08:24:45: Attempting to upload backup to remote backup server
2024-07-31 08:24:45: Uploading portalapim.bankabc.co.id@bank-abc@production-20240731.082439.tar.gz to 192.168.192.168:22:/apicbackup/DC2/ptlb/ using sftp
2024-07-31 08:24:45: portalapim.bankabc.co.id@bank-abc@production-20240731.082439.tar.gz successfully uploaded
2024-07-31 08:24:45: 1/1 installed sites have been successfully backed up
2024-07-31 08:24:45: Creating a portal system backup...
2024-07-31 08:24:45: backing up apim hostname details
2024-07-31 08:24:45: backing up hash of encryption key
2024-07-31 08:24:45: hash: 0781d4eab659273a9127eb213bd8730f71be8270d403394c205f306ba8a41b24
2024-07-31 08:24:45: backing up /web/config/
2024-07-31 08:24:45: backing up portal.service table
2024-07-31 08:24:46: saving a list of the 1 installed site(s):
portalapim.bankabc.co.id/bank-abc/production
2024-07-31 08:24:46: creating backup archive
2024-07-31 08:24:46: system backup created at: /var/aegir/backups/_portal_system_backup-20240731.082446.tar.gz
2024-07-31 08:24:46: Portal system backup created: _portal_system_backup-20240731.082446.tar.gz
2024-07-31 08:24:46: Attempting to upload backup to remote backup server
2024-07-31 08:24:46: Uploading _portal_system_backup-20240731.082446.tar.gz to 192.168.192.168:22:/apicbackup/DC2/ptlb/ using sftp
2024-07-31 08:24:46: _portal_system_backup-20240731.082446.tar.gz successfully uploaded
2024-07-31 08:24:46: CLI task (backup:all) completed successfully.
reason: Finished
status: "True"
type: Ready
- lastTransitionTime: "2024-07-31T08:24:32Z"
message: ""
reason: Running
status: "False"
type: Running
- lastTransitionTime: "2024-07-31T08:24:32Z"
message: ""
reason: BackupFailed
status: "False"
type: Error
fullBackupName: ""
id: c7qk2ts5n8d28a2v
message: ""
phase: Ready
state: ""
Case Upload Failed
You can also manually upload the backup file that already present on the inside of pod
[root@BASTION ~]# oc exec -it apiconnect-e7a4c765-e7a4c765-www-0 -c admin -- bash
bash-5.1$ ls -lart /var/aegir/backups/
total 12476
drwxr-xr-x. 1 root root 157 Jun 14 19:42 ..
drwxrws---. 2 root group2 16384 Jul 15 04:57 lost+found
-rw-rw-r--. 1 aegir group2 2750 Jul 22 05:20 _portal_system_backup-20240722.052010.tar.gz
-rw-r--r--. 1 aegir group2 12744108 Jul 31 08:24 portalapim.bankabc.co.id@bank-abc@production-20240731.082439.tar.gz
-rw-rw-r--. 1 aegir group2 3803 Jul 31 08:24 _portal_system_backup-20240731.082446.tar.gz
drwxrwsr-x. 3 root group2 4096 Jul 31 08:45 .
bash-5.1$
Transfer Backup File To SFTP
remote_transfer_backup -u /var/aegir/backups/<your-backup-file-name>.tar.gz
remote_transfer_backup -u /var/aegir/backups/_portal_system_backup-20240722.052010.tar.gz
bash-5.1$ remote_transfer_backup -u /var/aegir/backups/_portal_system_backup-20240722.052010.tar.gz
Uploading /var/aegir/backups/_portal_system_backup-20240722.052010.tar.gz to 192.168.135.192:22:/apicbackup/DC2/ptlb/_portal_system_backup-20240722.052010.tar.gz sftp
Authorizing sftp using username/password
1 item(s) uploaded
bash-5.1$
SFTP Condition
Before Transfer
[root@SFTP ptlb]# ll
total 12456
-rw-r--r--. 1 sftpuser sftpuser 45 Jul 31 15:24 apic_portal_connection_test
-rw-r--r--. 1 sftpuser sftpuser 12744108 Jul 31 15:24 portalapim.bankabc.co.id@bank-abc@production-20240731.082439.tar.gz
-rw-r--r--. 1 sftpuser sftpuser 3803 Jul 31 15:24 _portal_system_backup-20240731.082446.tar.gz
After Transfer
[root@SFTP ptlb]# ll
total 12460
-rw-r--r--. 1 sftpuser sftpuser 45 Jul 31 15:24 apic_portal_connection_test
-rw-r--r--. 1 sftpuser sftpuser 12744108 Jul 31 15:24 portalapim.bankabc.co.id@bank-abc@production-20240731.082439.tar.gz
-rw-r--r--. 1 sftpuser sftpuser 2750 Jul 31 15:47 _portal_system_backup-20240722.052010.tar.gz
-rw-r--r--. 1 sftpuser sftpuser 3803 Jul 31 15:24 _portal_system_backup-20240731.082446.tar.gz
You Can Read This : Backing up and restoring the developer portal