#!/bin/bash
#
# Create policy database backup.
#
# Need files:
#   api-token (api auth token)
#
E=central-rhacs.apps.ocp4.example.com
T=$(cat roxctl-token)

# Get a list of policy IDs
IDS="$(curl -ks -H "Authorization: Bearer ${T}" https://${E}/v1/policies | jq -r '[ .policies[].id ]')"

# Create a dump
curl -ks -H "Authorization: Bearer ${T}" -XPOST -d "{ \"policyIds\": ${IDS} }" https://central-rhacs.apps.ocp4.example.com/v1/policies/export