Purge Trail File manually from OGG OCI

As we all know, OGG does not delete the trail files when you delete your Extract or Replicat groups.

In OGG OCI which is managed by Oracle and users don’t necessarily have backend access, and if we delete the ER groups I would consider best practices to go ahead and delete those trails as well.

To do that you can use the curl “commands execute” call for that, here is an example I have used:

alexlima@alexlima-mac LABS % cat purge_migration_trails.sh
curl -K /Users/alexlima/Documents/LABS/access.cfg \
-X POST https://w5mi5ndrjtqasbr.deployment.goldengate.us-ashburn-1.oci.oraclecloud.com/services/v2/commands/execute \
-H 'Content-Type: application/json' \
-d \
'{
    "name": "purge",
    "purgeType": "trails",
    "trails": [
        {
            "name": "e1"
        }
    ],
    "useCheckpoints": false,
    "keep": [
        {
            "type": "min",
            "units": "files",
            "value": 0
        }
    ]
}' |  python -m json.tool

Here is the output:

    "messages": [
        {
            "$schema": "ogg:message",
            "code": "OGG-00957",
            "issued": "2021-11-22T01:59:51Z",
            "severity": "INFO",
            "title": "Purged old extract file '/u02/Deployment/var/lib/data/e1000000000'. Purge rule: Purging all files for trail '/u02/Deployment/var/lib/data/e1'.",
            "type": "http://docs.oracle.com/goldengate/c2140/gg-winux/GMESG/oggus.htm#OGG-00957"
        },
        {
            "$schema": "ogg:message",
            "code": "OGG-00957",
            "issued": "2021-11-22T01:59:51Z",
            "severity": "INFO",
            "title": "Purged old extract file '/u02/Deployment/var/lib/data/e1000000001'. Purge rule: Purging all files for trail '/u02/Deployment/var/lib/data/e1'.",
            "type": "http://docs.oracle.com/goldengate/c2140/gg-winux/GMESG/oggus.htm#OGG-00957"
        },
        {
            "$schema": "ogg:message",
            "code": "OGG-00957",
            "issued": "2021-11-22T01:59:51Z",
            "severity": "INFO",
            "title": "Purged old extract file '/u02/Deployment/var/lib/data/e1000000002'. Purge rule: Purging all files for trail '/u02/Deployment/var/lib/data/e1'.",
            "type": "http://docs.oracle.com/goldengate/c2140/gg-winux/GMESG/oggus.htm#OGG-00957"
        },
        {
            "$schema": "ogg:message",
            "code": "OGG-00957",
            "issued": "2021-11-22T01:59:51Z",
            "severity": "INFO",
            "title": "Purged old extract file '/u02/Deployment/var/lib/data/e1000000003'. Purge rule: Purging all files for trail '/u02/Deployment/var/lib/data/e1'.",
            "type": "http://docs.oracle.com/goldengate/c2140/gg-winux/GMESG/oggus.htm#OGG-00957"
        }
    ]

Reference:

https://docs.oracle.com/en/middleware/goldengate/core/21.3/oggra/api-administrative-server-commands.html

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.