Skip to main content

Rule

Description

The px pxb rule commands manage pre/post execution rules used by backups. A rule defines one or more actions to run in targeted pods before or after backup operations. You can create, update, list/inspect, delete rules, and update rule ownership/access.

Usage

Create Rule

px pxb create rule --name <rule-name> [flags]

Get Rule (Inspect)

px pxb get rule --name <rule-name> [--uid <uid>] [flags]

Get Rule (List All)

px pxb get rule [flags]

Update Rule

px pxb update rule --name <rule-name> [--uid <uid>] [flags]

Delete Rule

px pxb delete rule --name <rule-name> [--uid <uid>] [flags]

Update Ownership (Access) for Rule

px pxb update ownership rule --name <rule-name> [--uid <uid>] [flags]

Examples

Create a rule with pod selector and actions

px pxb create rule \
--name quiesce-db \
--pod-selector "app=postgres" \
--actions "echo 'preparing for backup',psql -c 'SELECT pg_start_backup()'"

Create a rule from file

px pxb create rule --name pre-backup --file /path/to/rule-create.json

Example /path/to/rule-create.json:

{
"name": "pre-backup",
"rulesInfo": {
"rules": [
{
"podSelector": { "app": "mysql" },
"actions": [ { "value": "echo start", "background": false, "runInSinglePod": true } ]
}
]
}
}

Update an existing rule

# Update actions inline
px pxb update rule --name quiesce-db --actions "psql -c 'SELECT pg_stop_backup()'"

# Update using per-type files
px pxb update rule --name quiesce-db --rules-info-file /path/to/rule-update.json

Inspect and list rules

# Inspect a specific rule
px pxb get rule --name quiesce-db

# List all rules (JSON output)
px pxb get rule --output json

Update rule ownership

# Add groups and collaborators with access levels
px pxb update ownership rule --name quiesce-db \
--add-groups "dev-team=Admin,ops=Read" \
--add-collaborators "alice@corp.com=Write"

# From file (CLI flags override file)
px pxb update ownership rule --name quiesce-db --file /path/to/rule-ownership.json

Example rule-ownership.json:

{
"name": "quiesce-db",
"ownership": {
"groups": [ { "id": "dev-team", "access": "Admin" } ],
"collaborators": [ { "id": "alice@corp.com", "access": "Write" } ],
"public": { "type": "Read" }
}
}

Delete a rule

px pxb delete rule --name quiesce-db

Flags for commands and sub-commands

Create Rule Flags

Required Flags

FlagShortTypeDescription
--name-nstringName of the rule (required, optional with --file)

Rule Content

FlagShortTypeDescription
--file-fstringYAML/JSON file with complete rule specification
--rules-infostringRules info as JSON string
--rules-info-filestringYAML/JSON file with rules info
--pod-selectorstringPod selector key=value pairs (comma-separated)
--actionsstringComma-separated action commands
--actions-filestringJSON file with action specifications

Metadata

FlagShortTypeDescription
--uidstringUID for the rule (optional)
--labelsmapLabels to set (key=value,key2=value2)
--labels-filestringYAML/JSON file containing labels

Get Rule Flags

Resource Identification

FlagShortTypeDescription
--name-nstringName of the rule to inspect (required for inspect; omit to list all)
--uidstringUID of the rule (optional; used with --name)

Filtering and Display

FlagShortTypeDescription
--owners[]stringFilter rules by owners
--max-objectsuint64Maximum number of rules to return (0 for default)
--include-rules-infoboolInclude detailed rules info in output (default: true)

Sorting

FlagShortTypeDescription
--sort-bystringSort by: Name, CreationTimestamp, LastUpdateTimestamp
--sort-orderstringAscending or Descending

File Input

FlagShortTypeDescription
--file-fstringYAML/JSON file containing inspect/enumerate configuration

Update Rule Flags

Required Identification

FlagShortTypeDescription
--name-nstringName of the rule to update (optional with --file, required otherwise)
--uidstringUID of the rule to update (optional)

Update Fields

FlagShortTypeDescription
--rules-infostringUpdated rules info as JSON string
--rules-info-filestringYAML/JSON file with updated rules info
--pod-selectorstringUpdated pod selector key=value pairs
--actionsstringUpdated comma-separated action commands
--actions-filestringJSON file with updated action specifications
--labelsmapLabels to set/replace on the rule
--labels-filestringYAML/JSON file with labels

File Input

FlagShortTypeDescription
--file-fstringYAML/JSON file with update configuration

Update Ownership (Rule) Flags

Required Identification

FlagShortTypeDescription
--name-nstringName of the rule to update ownership (optional with --file, required otherwise)
--uidstringUID of the rule (optional)

Access Management

FlagShortTypeDescription
--add-groupsmapAdd groups with access levels (e.g., dev=Read,admins=Admin)
--add-collaboratorsmapAdd collaborators with access levels (e.g., user@corp.com=Write)
--remove-groups[]stringRemove groups by ID (comma-separated)
--remove-collaborators[]stringRemove collaborators by ID (comma-separated)
--public-access-controlstringPublic access level (Read/Write/Admin)

File Input (ownership)

FlagShortTypeDescription
--file-fstringJSON file with full ownership configuration
--add-groups-filestringJSON file with groups and access levels
--add-collaborators-filestringJSON file with collaborators and access levels

Delete Rule Flags

Required Identification

FlagShortTypeDescription
--name-nstringName of the rule to delete (optional with --file, required otherwise)
--uidstringUID of the rule to delete (optional)

File Input

FlagShortTypeDescription
--file-fstringYAML/JSON file with delete configuration

Notes

  • Get dual mode: without --name enumerates; with --name inspects one (optionally add --uid).
  • Create/Update precedence: inline flags override per-type files, which override --file base.
  • Update requires --name. Delete requires --name. Ownership update requires --name. When using --file, identifiers may come from the file; CLI flags override file values.

Output Format Support

  • --output table (default)
  • --output json
  • --output yaml
  • --output name (for get)

Authentication and Context

  • Organization ID from context
  • Authentication token from context
  • Labels from context