1. Home
  2. Knowledge Base
  3. GoldenGate
  4. Oracle GoldenGate Cloud Service – Purge Trail Files using REST API
  1. Home
  2. Knowledge Base
  3. Oracle Cloud
  4. Oracle GoldenGate Cloud Service – Purge Trail Files using REST API

Oracle GoldenGate Cloud Service – Purge Trail Files using REST API

GoldenGate Cloud Service Trail Files can be purged either using the browser based OCI console as well as via the command line using REST API calls as shown below.

Purging trail files via the OCI GoldenGate Deployment Console is very straight forward and simple!

From the Configuration/Tasks menu, we can create a Purge Trails task

Let us see how we can do the accomplish the same Purge Trails task using the REST API command line method.

To enable us to run the curl command without having to specify a password, we can create a .netrc file and enter the GoldenGate Deployment private IP address along with the GoldenGate administrator user name and password.

 $ touch ~/.netrc
 $ chmod go= ~/.netrc
 $ vi .netrc

machine 10.43.x.xx  login GGADMIN  password xxxxxxxxxxx

We run the curl command from a Compute Node VM which has network access to the GoldenGate deployment.

In this case we specify also the sub-directory name where the trail files are located and best practices is to set the option to use Checkpoints to ensure Extracts or Replicats have finished processing for the relevant trail files.

In the example below, Checkpoints are being used and 3 days of trail files are being retained with the remaining being purged.

curl -k -n -X POST https://10.43.2.19/services/v2/commands/execute -H 'Content-Type: application/json' -d \
 '{
 "name": "purge",
 "purgeType": "trails",
 "trails": [
 {
 "name": "aa",
 "path":"LISPROD"
 }
 ],
 "useCheckpoints": true,
 "keep": [
 {
 "type": "min",
 "units": "days",
 "value": 3
 }
 ]
 }'
{"$schema":"api:standardResponse","links":[{"rel":"canonical","href":"https://10.43.2.19/services/v2/commands/execute","mediaType":"application/json"},
{"rel":"self","href":"https://10.43.2.19/services/v2/commands/execute","mediaType":"application/json"}],
"messages":[{"$schema":"ogg:message","title":"Purged old extract file '/u02/Deployment/var/lib/data/LISPROD/aa000001854'. Purge rule: Applying MinKeepHours purge rule: 1001 >= 72.","code":"OGG-00957","severity":"INFO","issued":"2023-01-18T01:33:45Z","type":"http://docs.oracle.com/goldengate/c2170/gg-winux/GMESG/oggus.htm#OGG-00957"},
{"$schema":"ogg:message","title":"Purged old extract file '/u02/Deployment/var/lib/data/LISPROD/aa000001855'. Purge rule: Applying MinKeepHours purge rule: 999 >= 72.","code":"OGG-00957","severity":"INFO","issued":"2023-01-18T01:33:45Z","type":"http://docs.oracle.com/goldengate/c2170/gg-winux/GMESG/oggus.htm#OGG-00957"},
{"$schema":"ogg:message","title":"Purged old extract file '/u02/Deployment/var/lib/data/LISPROD/aa000001856'. Purge rule: Applying MinKeepHours purge rule: 996 >= 72.","code":"OGG-00957","severity":"INFO","issued":"2023-01-18T01:33:45Z","type":"http://docs.oracle.com/goldengate/c2170/gg-winux/GMESG/oggus.htm#OGG-00957"},
{"$schema":"ogg:message","title":"Purged old extract file '/u02/Deployment/var/lib/data/LISPROD/aa000001857'. Purge rule: Applying MinKeepHours purge rule: 991 >= 72.","code":"OGG-00957","severity":"INFO","issued":"2023-01-18T01:33:45Z","type":"http://docs.oracle.com/goldengate/c2170/gg-winux/GMESG/oggus.htm#OGG-00957"},
{"$schema":"ogg:message","title":"Purged old extract file '/u02/Deployment/var/lib/data/LISPROD/aa000001858'. Purge rule: Applying MinKeepHours purge rule: 990 >= 72.","code":"OGG-00957","severity":"INFO","issued":"2023-01-18T01:33:45Z","type":"http://docs.oracle.com/goldengate/c2170/gg-winux/GMESG/oggus.htm#OGG-00957"},
{"$schema":"ogg:message","title":"Purged old extract file '/u02/Deployment/var/lib/data/LISPROD/aa000001859'. Purge rule: Applying MinKeepHours purge rule: 986 >= 72.","code":"OGG-00957","severity":"INFO","issued":"2023-01-18T01:33:45Z","type":"http://docs.oracle.com/goldengate/c2170/gg-winux/GMESG/oggus.htm#OGG-00957"}
....
....

When an initial load is performed using the File to Replicat method, we can purge the trail files as well as we do not need to retain them once the initial load is completed.

Instead of “days” for the units parameter, we use the value “files” and we do not need to retain any files – so we use ‘0’ for the value parameter.

curl -k -n -X POST https://10.43.2.19/services/v2/commands/execute -H 'Content-Type: application/json' -d \
 '{
 "name": "purge",
 "purgeType": "trails",
 "trails": [
 {
 "name": "i1",
 "path":"PPORBSHSSADW001"
 }
 ],
 "useCheckpoints": false,
 "keep": [
 {
 "type": "min",
 "units": "files",
 "value": 0
 }
 ]
 }'

When we delete the Extract or Replicat process (without purging the trail files before hand), we are left with these ‘orphan’ trail files.

To purge these trail files in this case we can specify similar values as what we had used for purging the initial load trail files, but we can also use a ‘*’ in this case as we are purging all trail files in a sub-directory that the Extract or Replicat was writing to.

curl -k -n -X POST https://10.43.2.19/services/v2/commands/execute -H 'Content-Type: application/json' -d \
 '{
 "name": "purge",
 "purgeType": "trails",
 "trails": [
 {
 "name": "*",
 "path":"/u02/Deployment/var/lib/data/LISPROD"
 }
 ],
 "useCheckpoints": true,
 "keep": [
 {
 "type": "min",
 "units": "files",
 "value": 0
 }
 ]
 }'

Updated on May 1, 2023

Was this article helpful?

Related Articles

Leave a Comment