Data Backup and Restore
You can take regular backups of data stored in API Gateway Data Store to protect it against accidental data loss. You can take a backup of complete API Gateway data that includes analytics data and assets data or you can take a partial backup that includes the backup of assets data or backup of analytics data. When you take a backup, you copy the contents of the repository to a file or to a cloud storage. At a later stage, you can retrieve the contents of the backup and restore them to API Gateway.
Note:
API Gateway supports incremental backup. For example, if you have taken a backup of 50 GB and there is an increase in backup to 52 GB,
API Gateway takes a backup of the new 2 GB data added.
![*](chapterTOC_bullet.png)
While performing a backup, the database experiences additional load, therefore,
Software AG recommends taking a backup when the usage is low so as to avoid performance degradation.
![*](chapterTOC_bullet.png)
While restoring the backup from the repository,
API Gateway replaces the existing data in
API Gateway.
API Gateway is not accessible when database restore is in progress.
To take a complete or partial backup of the API Gateway data and restore it to API Gateway, you can use the API Gateway command line utility. To back up and restore the database in command line, use the apigatewayUtil.bat and the apigatewayUtil.sh files available in the Integration Server_directory/instances/instance_id/packages/WmAPIGateway/cli/bin folder for Windows and UNIX systems respectively.
API Gateway supports the following storage platforms:
![*](chapterTOC_bullet.png)
Network File System (NFS)
![*](chapterTOC_bullet.png)
Amazon Simple Storage Service (S3)
Note:
You must install the Amazon Web Services (AWS) cloud plugin if you want to use the Amazon S3 storage platform. To install the AWS cloud plugin, run the following command and restart Integration Server: Integration Server_directory/InternalDataStore/bin/plugin install cloud-aws
Using NFS Storage Platform
API Gateway uses NFS as the default repository in which the backup is stored. You can configure the repositories in which the backup is stored either in NFS or S3 cloud. However, you can create a single repository and place all the backup files in that repository.
![*](chapterTOC_bullet.png)
Taking a backup:
By default, API Gateway stores the backup in the Integration Server_directory/InternalDataStore/archives/ directory. For example, if you run the command, apigatewayUtil.bat create backup -name backup_file_name, to take a backup, the backup is saved in the Integration Server_directory/InternalDataStore/archives/default directory.
![*](chapterTOC_bullet.png)
Restoring a backup:
To restore the data taken as backup to API Gateway, run the following command: apigatewayUtil.bat restore backup -name backup_file_name
Note:
Once the backup is restored, you must restart the API Gateway instance.
![*](chapterTOC_bullet.png)
Restoring backup to a new instance:
1. Copy the data from Integration Server_directory/InternalDataStore/archives/ directory where the backup data is available.
2. Go to the Integration Server_directory/InternalDataStore/archives/ directory where the backup data is to be restored and ensure that you delete any existing data in this directory.
3. Paste the data in the Integration Server_directory/InternalDataStore/archives/ directory.
4. Run the following command to restore the data: apigatewayUtil.bat restore backup -name backup_file_name
Note:
Once the backup is restored, you must restart the API Gateway instance.
![*](chapterTOC_bullet.png)
Specifying NFS Directory path:
For API Gateways in a clustered environment, you must specify a NFS directory path. This directory path is a shared file location, which must be accessible to all the API Gateway nodes in the cluster, and not used by any other cluster.
1. Before creating the NFS repository in Elasticsearch run the following command in all nodes of the cluster to configure the NFS directory path:
apigatewayUtil.bat configure fs_path -path NFS_path
For example,
apigatewayUtil.bat configure fs_path -path c://sample//APIGATEWAY
2. Restart Elasticsearch.
3. Restart Integration Server to make the new NFS directory path available to store the backup, else the backup is stored in the default location.
![*](chapterTOC_bullet.png)
Specifying NFS Directory path if you are using external Elasticsearch
1. Open the elasticsearch.yml file from the location, Integration Server_directory/InternalDataStore/config/.
2. Provide the NFS directory location in the path.repo field.
3. Save the changes.
4. Restart Elasticsearch.
Using S3 Storage Platform
You can save your backups to S3 cloud.
![*](chapterTOC_bullet.png)
Creating a repository:
1. To create a repository using S3, run the following command:
apigatewayUtil.bat configure manageRepo -file file_path
where file_path is the path where the S3 cloud details are specified.
For example, apigatewayUtil.bat configure manageRepo -file Integration Server_directory/instances/instance_id/packages/WmAPIGateway/cli/bin/conf/gateway-s3-repo.cnf.
2. Go to Integration Server_directory/instances/instance_id/packages/WmAPIGateway/cli/bin/conf.
3. Open the gateway-s3-repo.cnf file. The following information appears:
type=s3
bucket=<s3-bucket-name>
region=<s3-region>
accesskey=<s3-access-key>
secretkey=<s3-secret-key>
basepath=<s3-base-path>
Note:
The supported regions are: US East (N. Virginia): us-east-1, US West (N. California): us-west-1, US West (Oregon): us-west-2, Asia Pacific (Seoul): ap-northeast-2, Asia Pacific (Singapore): ap-southeast-1, Asia Pacific (Sydney): ap-southeast-2, Asia Pacific (Tokyo): ap-northeast-1, EU (Frankfurt): eu-central-1, EU (Ireland): eu-west-1.
4. Configure the S3 details in the gateway-s3-repo.cnf file, for example,
bucket=apigateway-store
region=us-west-1
accesskey=123-test-123d-123
secretkey=tests1232sk12312t
After modifying the gateway-s3-repo.cnf file, run the following command: apigatewayUtil.bat configure manageRepo -file <file_path>
For example, apigatewayUtil.bat configure manageRepo -file Integration Server_directory/instances/instance_id/packages/WmAPIGateway/cli/bin/conf/gateway-s3-repo.cnf
![*](chapterTOC_bullet.png)
Taking a backup:
To take a backup of the data, run the following command: apigatewayUtil.bat create backup -name backup_file_name
Note:
The backup_file_name must be specified in lowercase.
![*](chapterTOC_bullet.png)
Restoring a backup:
To restore the data taken as backup to API Gateway, run the following command: apigatewayUtil.bat restore backup -name backup_file_name
Note:
Once the backup is restored, you must restart the API Gateway instance.
![*](chapterTOC_bullet.png)
Restoring backup to a new instance:
1. Create a repository using S3 if not already created.
Note:
The S3 details which we provide in the gateway-s3-repo.cnf should point to the location where we have backup files which was taken earlier.
2. In case of multiple backups, run the following command to retrieve a list of backups: apigatewayUtil.bat list backup
3. Run the following command to restore the data using the required backup file: apigatewayUtil.bat restore backup -name backup_file_name
Note:
Once the backup is restored, you must restart the API Gateway instance.