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
| Flag | Short | Type | Description |
|---|---|---|---|
--name | -n | string | Name of the rule (required, optional with --file) |
Rule Content
| Flag | Short | Type | Description |
|---|---|---|---|
--file | -f | string | YAML/JSON file with complete rule specification |
--rules-info | string | Rules info as JSON string | |
--rules-info-file | string | YAML/JSON file with rules info | |
--pod-selector | string | Pod selector key=value pairs (comma-separated) | |
--actions | string | Comma-separated action commands | |
--actions-file | string | JSON file with action specifications |
Metadata
| Flag | Short | Type | Description |
|---|---|---|---|
--uid | string | UID for the rule (optional) | |
--labels | map | Labels to set (key=value,key2=value2) | |
--labels-file | string | YAML/JSON file containing labels |
Get Rule Flags
Resource Identification
| Flag | Short | Type | Description |
|---|---|---|---|
--name | -n | string | Name of the rule to inspect (required for inspect; omit to list all) |
--uid | string | UID of the rule (optional; used with --name) |
Filtering and Display
| Flag | Short | Type | Description |
|---|---|---|---|
--owners | []string | Filter rules by owners | |
--max-objects | uint64 | Maximum number of rules to return (0 for default) | |
--include-rules-info | bool | Include detailed rules info in output (default: true) |
Sorting
| Flag | Short | Type | Description |
|---|---|---|---|
--sort-by | string | Sort by: Name, CreationTimestamp, LastUpdateTimestamp | |
--sort-order | string | Ascending or Descending |
File Input
| Flag | Short | Type | Description |
|---|---|---|---|
--file | -f | string | YAML/JSON file containing inspect/enumerate configuration |
Update Rule Flags
Required Identification
| Flag | Short | Type | Description |
|---|---|---|---|
--name | -n | string | Name of the rule to update (optional with --file, required otherwise) |
--uid | string | UID of the rule to update (optional) |
Update Fields
| Flag | Short | Type | Description |
|---|---|---|---|
--rules-info | string | Updated rules info as JSON string | |
--rules-info-file | string | YAML/JSON file with updated rules info | |
--pod-selector | string | Updated pod selector key=value pairs | |
--actions | string | Updated comma-separated action commands | |
--actions-file | string | JSON file with updated action specifications | |
--labels | map | Labels to set/replace on the rule | |
--labels-file | string | YAML/JSON file with labels |
File Input
| Flag | Short | Type | Description |
|---|---|---|---|
--file | -f | string | YAML/JSON file with update configuration |
Update Ownership (Rule) Flags
Required Identification
| Flag | Short | Type | Description |
|---|---|---|---|
--name | -n | string | Name of the rule to update ownership (optional with --file, required otherwise) |
--uid | string | UID of the rule (optional) |
Access Management
| Flag | Short | Type | Description |
|---|---|---|---|
--add-groups | map | Add groups with access levels (e.g., dev=Read,admins=Admin) | |
--add-collaborators | map | Add collaborators with access levels (e.g., user@corp.com=Write) | |
--remove-groups | []string | Remove groups by ID (comma-separated) | |
--remove-collaborators | []string | Remove collaborators by ID (comma-separated) | |
--public-access-control | string | Public access level (Read/Write/Admin) |
File Input (ownership)
| Flag | Short | Type | Description |
|---|---|---|---|
--file | -f | string | JSON file with full ownership configuration |
--add-groups-file | string | JSON file with groups and access levels | |
--add-collaborators-file | string | JSON file with collaborators and access levels |
Delete Rule Flags
Required Identification
| Flag | Short | Type | Description |
|---|---|---|---|
--name | -n | string | Name of the rule to delete (optional with --file, required otherwise) |
--uid | string | UID of the rule to delete (optional) |
File Input
| Flag | Short | Type | Description |
|---|---|---|---|
--file | -f | string | YAML/JSON file with delete configuration |
Notes
- Get dual mode: without
--nameenumerates; with--nameinspects one (optionally add--uid). - Create/Update precedence: inline flags override per-type files, which override
--filebase. - 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