Skip to main content

px pxb create

Create px-backup resources

note

The following commands support a set of global flags that apply to all px pxb commands. For details, see the Global Flags section.

px pxb create backup

Create a backup of Kubernetes resources and persistent volumes.

This command creates a backup of specified namespaces, resources, or virtual machines to a configured backup location. The backup can include application resources, persistent volumes, and custom resources.

Examples:

# Create a simple namespace backup
pxb create backup --name my-backup --cluster my-cluster --namespaces default,kube-system --backup-location-name s3-backup

# Backup ALL namespaces using wildcard (note: wildcard must be quoted!)
pxb create backup --name all-ns-backup --cluster my-cluster --namespaces '*' --backup-location-name s3-backup

# Create a backup using cluster UID and backup location UID (optional)
pxb create backup --name uid-backup --cluster-uid cl-12345-abcde --backup-location-uid bl-67890-fghij

# Create a VM backup with specific resources
pxb create backup --name vm-backup --cluster my-cluster --backup-object-type VirtualMachine --include-resources "vm1:default:kubevirt.io:v1:VirtualMachine"

# Create a backup with label selectors and rules
pxb create backup --name app-backup --cluster my-cluster --namespaces production --label-selectors "app=nginx,tier=frontend" --pre-exec-rule-name pre-backup-rule

# Create a backup from JSON file with complex resource selection
pxb create backup --name complex-backup --cluster my-cluster --namespaces default --include-resources-file /path/to/resources.json

# Create a generic backup with CSI snapshots
pxb create backup --name csi-backup --cluster my-cluster --namespaces default --backup-type Generic --volume-snapshot-class-mapping "kubernetes.io/aws-ebs=ebs-snapshot-class"

Flags

FlagInput typeDescriptionDefaultRequired
--advanced-resource-label-selectorstringAdvanced label selector with operators for resource selection-Optional
--authtokenstringoidc auth token-Optional
--backup-location-namestringName of backup location to be used (required, optional with --file)-Optional
--backup-location-uidstringUID of backup location to be used-Optional
--backup-object-type, -bstringBackup object type: 'All' for namespace backup, 'VirtualMachine' for VM backup-Optional
--backup-type, -tstringBackup type: 'Normal' (default) or 'Generic'-Optional
--cluster, -cstringName of the cluster where backup should be run (required, optional with --file)-Optional
--cluster-uid, -ustringUID of the cluster-Optional
--direct-kdmpboolTake backup using direct KDMP (Kubernetes Data Management Platform)falseOptional
--dry-runboolSimulate the operation without making any changesfalseOptional
--endpoint, -estringThe endpoint of the server-Optional
--exclude-resource-typesstringSliceResource types to exclude from backup[]Optional
--exclude-resource-types-filestringPath to YAML/JSON file containing list of resource types to exclude-Optional
--file, -fstringYAML/JSON file containing complete backup configuration-Optional
--include-resourcesstringComma-separated list of specific resources (format: name:namespace:group:version:kind)-Optional
--include-resources-filestringPath to YAML/JSON file containing list of specific resources to include-Optional
--keep-cr-statusboolInclude custom resource status in backupfalseOptional
--label-selectorsstringToStringLabel selectors to choose specific resources (key=value,key2=value2)[]Optional
--label-selectors-filestringYAML/JSON file containing label selectors-Optional
--labels, -lstringComma separated list of labels as key-value pairs: 'k1=v1,k2=v2'-Optional
--name, -nstringName of the backup (required, optional with --file)-Optional
--namespacesstringSliceNamespaces to be backed up (comma-separated, or '*' for all - must be quoted)[]Optional
--namespaces-filestringYAML/JSON file containing namespaces array-Optional
--ns-label-selectorsstringLabel selectors to choose namespaces to be backed up-Optional
--orgIDstringThe org id for which to query the objectdefaultOptional
--output, -ostringOutput format. One of: table|json|yaml|nametableOptional
--post-exec-rule-namestringName of post-execution rule to run after backup-Optional
--post-exec-rule-uidstringUID of post-execution rule-Optional
--pre-exec-rule-namestringName of pre-execution rule to run before backup-Optional
--pre-exec-rule-uidstringUID of pre-execution rule-Optional
--resource-typesstringSliceSpecific resource types to backup (e.g., Pod,Service,ConfigMap)[]Optional
--resource-types-filestringPath to YAML/JSON file containing list of resource types to include-Optional
--skip-vm-auto-exec-rulesboolSkip automatic execution rules for VM backupsfalseOptional
--tls-certificatestringtls certificate-Optional
--uidstringUID of the backup (optional)-Optional
--volume-resource-only-policy-namestringName of volume resource only policy-Optional
--volume-resource-only-policy-uidstringUID of volume resource only policy-Optional
--volume-snapshot-class-mappingstringToStringCSI volume snapshot class mapping (provisioner=snapshotclass)[]Optional
--volume-snapshot-class-mapping-filestringPath to JSON file containing volume snapshot class mapping-Optional

px pxb create backuplocation

Create and validate a backup location for storing backups.

This command creates a backup location that can be used to store backups. Backup locations can be configured for various cloud providers (S3, Azure, GCP) or on-premises storage (NFS). The command validates the configuration and credentials before creating the backup location.

Supported storage types:

  • S3 (Amazon S3, MinIO, and S3-compatible storage)
  • NFS (Network File System)
  • Azure Blob Storage
  • Google Cloud Storage

Examples:

# Create S3 backup location
pxb create backuplocation --name s3-backup --provider s3 --path my-bucket/backups --cloud-credential-name aws-creds --s3-endpoint s3.amazonaws.com --s3-region us-west-2

# Create S3 backup location with encryption
pxb create backuplocation --name encrypted-s3 --provider s3 --path my-bucket/secure --cloud-credential-name aws-creds --encryption-key mySecretKey123 --object-lock-enabled

# Create Azure backup location (global environment)
pxb create backuplocation --name azure-backup --provider azure --path my-container/backups --cloud-credential-name azure-creds --azure-environment AZURE_GLOBAL

# Create Azure backup location with resource group (China environment)
pxb create backuplocation --name azure-china --provider azure --path my-container/backups --cloud-credential-name azure-creds --azure-environment AZURE_CHINA --azure-resource-group my-resource-group

# Create NFS backup location
pxb create backuplocation --name nfs-backup --provider nfs --path /backups --nfs-server-addr 192.168.1.100 --nfs-mount-options "vers=4,rsize=1048576"

# Create backup location with validation disabled
pxb create backuplocation --name quick-s3 --provider s3 --path test-bucket --cloud-credential-name aws-creds --validate-cloud-credential=false

Flags

FlagInput typeDescriptionDefaultRequired
--authtokenstringoidc auth token-Optional
--azure-environmentstringAzure environment: AZURE_GLOBAL, AZURE_CHINA-Optional
--azure-resource-groupstringAzure resource group name (optional)-Optional
--cloud-credential-namestringName of cloud credential to use-Optional
--cloud-credential-uidstringUID of cloud credential to use-Optional
--dry-runboolSimulate the operation without making any changesfalseOptional
--encryption-keystringEncryption key for backup data-Optional
--endpoint, -estringThe endpoint of the server-Optional
--file, -fstringYAML/JSON file containing complete backup location configuration-Optional
--labels, -lstringComma separated list of labels as key-value pairs: 'k1=v1,k2=v2'-Optional
--name, -nstringName of the backup location (required, optional with --file)-Optional
--nfs-config-filestringYAML/JSON file containing NFS-specific configuration-Optional
--nfs-mount-optionsstringNFS mount options (e.g., 'vers=4,rsize=1048576')-Optional
--nfs-server-addrstringNFS server address (IP or hostname)-Optional
--nfs-sub-pathstringSubdirectory under NFS export path-Optional
--object-lock-enabledboolEnable object lock for immutable backups (S3 only)falseOptional
--orgIDstringThe org id for which to query the objectdefaultOptional
--output, -ostringOutput format. One of: table|json|yaml|nametableOptional
--pathstringStorage path (bucket name for cloud providers, directory for NFS) (required, optional with --file)-Optional
--provider, -pstringStorage provider: s3, azure, google, nfs (required, optional with --file)-Optional
--s3-config-filestringYAML/JSON file containing S3-specific configuration-Optional
--s3-disable-path-styleboolDisable path-style addressing for S3falseOptional
--s3-disable-sslboolDisable SSL for S3 connectionsfalseOptional
--s3-endpointstringS3 endpoint URL (e.g., s3.amazonaws.com)-Optional
--s3-regionstringS3 region (e.g., us-west-2)-Optional
--s3-ssestringS3 server-side encryption: SSE-S3, SSE-KMS-Optional
--tls-certificatestringtls certificate-Optional
--uidstringUID of the backup location (optional)-Optional
--validate-cloud-credentialboolValidate cloud credential before creating backup locationtrueOptional

px pxb create backupschedule

Create a backup schedule to automatically backup applications on a recurring basis.

A backup schedule defines when and how backups should be taken for specific namespaces or resources in a Kubernetes cluster. It combines a schedule policy (defining when backups occur) with a backup location (where backups are stored) and various filtering options to control what gets backed up.

Examples:

# Create basic backup schedule
pxb create backupschedule --name daily-backup --schedule-policy-name daily-policy --backup-location-name s3-location --cluster my-cluster --namespaces app-namespace

# Schedule backup of ALL namespaces using wildcard (note: wildcard must be quoted!)
pxb create backupschedule --name all-ns-schedule --schedule-policy-name daily-policy --backup-location-name s3-location --cluster my-cluster --namespaces '*'

# Create comprehensive backup schedule with all options
pxb create backupschedule --name comprehensive-backup \
--schedule-policy-name weekly-policy --schedule-policy-uid policy-123 \
--backup-location-name azure-location --backup-location-uid location-456 \
--cluster production-cluster --cluster-uid cluster-789 \
--namespaces app1,app2 --label-selectors "app=web,tier=frontend" \
--resource-types "deployments,services,configmaps" \
--exclude-resource-types "secrets" \
--pre-exec-rule-name pre-backup-rule --post-exec-rule-name post-backup-rule \
--volume-resource-only-policy-name skip-policy --parallel-backup --direct-kdmp

# Create backup schedule from JSON file
pxb create backupschedule --file /path/to/backup-schedule.json

# Create generic backup schedule
pxb create backupschedule --name generic-backup --schedule-policy-name daily-policy --backup-location-name s3-location --cluster my-cluster --namespaces app-namespace --backup-type Generic

# Create VM backup schedule with specific VMs
pxb create backupschedule --name vm-backup --schedule-policy-name vm-policy --backup-location-name vm-location --cluster vm-cluster --backup-object-type VirtualMachine --include-resources "vm1:default:kubevirt.io:v1:VirtualMachine,vm2:default:kubevirt.io:v1:VirtualMachine"

# Create VM backup schedule with include-resources from file
pxb create backupschedule --name vm-backup --schedule-policy-name vm-policy --backup-location-name vm-location --cluster vm-cluster --backup-object-type VirtualMachine --include-resources-file /path/to/vms.json --skip-vm-auto-exec-rules

Flags

FlagInput typeDescriptionDefaultRequired
--advanced-resource-label-selectorstringAdvanced resource label selector-Optional
--authtokenstringoidc auth token-Optional
--backup-location-namestringName of the backup location (required, optional with --file)-Optional
--backup-location-uidstringUID of the backup location-Optional
--backup-object-typestringBackup object type: All (default) or VM (VirtualMachine)-Optional
--backup-typestringBackup type: Normal (default) or Generic-Optional
--cluster, -cstringName of the cluster (required, optional with --file)-Optional
--cluster-uidstringUID of the cluster-Optional
--csi-snapshot-mappingstringToStringCSI snapshot class mapping (provisioner=volumesnapshotclass)[]Optional
--direct-kdmpboolUse direct KDMP backupfalseOptional
--dry-runboolSimulate the operation without making any changesfalseOptional
--endpoint, -estringThe endpoint of the server-Optional
--exclude-resource-typesstringSliceResource types to exclude from backup[]Optional
--exclude-resource-types-filestringYAML/JSON file containing exclude resource types array-Optional
--filestringPath to YAML/JSON file containing backup schedule configuration-Optional
--include-resourcesstringComma-separated list of specific resources (format: name:namespace:group:version:kind)-Optional
--include-resources-filestringPath to YAML/JSON file containing list of specific resources to include-Optional
--keep-cr-statusboolKeep custom resource statusfalseOptional
--label-selectorsstringToStringLabel selectors to filter resources (key=value,key2=value2)[]Optional
--label-selectors-filestringYAML/JSON file containing label selectors-Optional
--labels, -lstringComma separated list of labels as key-value pairs: 'k1=v1,k2=v2'-Optional
--name, -nstringName of the backup schedule (required, optional with --file)-Optional
--namespacesstringSliceNamespaces to backup (comma-separated, or '*' for all - must be quoted)[]Optional
--namespaces-filestringYAML/JSON file containing namespaces array-Optional
--ns-label-selectorsstringNamespace label selectors-Optional
--orgIDstringThe org id for which to query the objectdefaultOptional
--output, -ostringOutput format. One of: table|json|yaml|nametableOptional
--parallel-backupboolEnable parallel backupfalseOptional
--post-exec-rule-namestringPost-execution rule name-Optional
--post-exec-rule-uidstringPost-execution rule UID-Optional
--pre-exec-rule-namestringPre-execution rule name-Optional
--pre-exec-rule-uidstringPre-execution rule UID-Optional
--resource-typesstringSliceResource types to include in backup[]Optional
--resource-types-filestringYAML/JSON file containing resource types array-Optional
--schedule-policy-namestringName of the schedule policy (required, optional with --file)-Optional
--schedule-policy-uidstringUID of the schedule policy-Optional
--skip-vm-auto-exec-rulesboolSkip VM auto-execution rulesfalseOptional
--tls-certificatestringtls certificate-Optional
--uidstringUID of the backup schedule (optional)-Optional
--volume-resource-only-policy-namestringVolume resource only policy name-Optional
--volume-resource-only-policy-uidstringVolume resource only policy UID-Optional
--volume-snapshot-class-mapping-filestringYAML/JSON file containing volume snapshot class mapping-Optional

px pxb create cloudcredential

Create a cloud credential for accessing cloud storage services.

This command allows you to create credentials for different cloud providers:

  • AWS: Access key and secret key for S3 storage
  • Azure: Account name/key or service principal credentials for Azure Blob Storage
  • Google: Project ID and JSON key file for Google Cloud Storage
  • IBM: API key for IBM Cloud Object Storage
  • Rancher: Endpoint and token for Rancher platform

The command supports both CLI flags and JSON file input for complex configurations.

Examples:

# Create AWS cloud credential
pxb create cloudcredential --name aws-cred --provider aws --aws-access-key AKIAIOSFODNN7EXAMPLE --aws-secret-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

# Create Azure cloud credential with service principal
pxb create cloudcredential --name azure-cred --provider azure --azure-account-name mystorageaccount --azure-account-key mykey --azure-client-id client-id --azure-client-secret client-secret --azure-tenant-id tenant-id --azure-subscription-id subscription-id

# Create Google cloud credential
pxb create cloudcredential --name gcp-cred --provider google --google-project-id my-project --google-json-key /path/to/service-account.json

# Create IBM cloud credential
pxb create cloudcredential --name ibm-cred --provider ibm --ibm-api-key my-api-key

# Create Rancher platform credential
pxb create cloudcredential --name rancher-cred --provider rancher --rancher-endpoint https://rancher.example.com --rancher-token my-token

# Create from JSON configuration file
pxb create cloudcredential --file /path/to/cloud-credential-config.json

Flags

FlagInput typeDescriptionDefaultRequired
--authtokenstringoidc auth token-Optional
--aws-access-keystringAWS access key ID (required for AWS, optional with --file)-Optional
--aws-secret-keystringAWS secret access key (required for AWS, optional with --file)-Optional
--azure-account-keystringAzure storage account key (required for Azure, optional with --file)-Optional
--azure-account-namestringAzure storage account name (required for Azure, optional with --file)-Optional
--azure-client-idstringAzure service principal client ID (optional for Azure)-Optional
--azure-client-secretstringAzure service principal client secret (optional for Azure)-Optional
--azure-subscription-idstringAzure service principal subscription ID (optional for Azure)-Optional
--azure-tenant-idstringAzure service principal tenant ID (optional for Azure)-Optional
--dry-runboolSimulate the operation without making any changesfalseOptional
--endpoint, -estringThe endpoint of the server-Optional
--filestringPath to YAML/JSON file containing cloud credential configuration-Optional
--google-json-keystringPath to Google Cloud service account JSON key file (required for Google, optional with --file)-Optional
--google-project-idstringGoogle Cloud project ID (required for Google, optional with --file)-Optional
--ibm-api-keystringIBM Cloud API key (required for IBM, optional with --file)-Optional
--labels, -lstringComma separated list of labels as key-value pairs: 'k1=v1,k2=v2'-Optional
--name, -nstringName of the cloud credential (required, optional with --file)-Optional
--orgIDstringThe org id for which to query the objectdefaultOptional
--output, -ostringOutput format. One of: table|json|yaml|nametableOptional
--provider, -pstringCloud provider type [aws,azure,google,ibm,rancher] (required, optional with --file)-Optional
--rancher-endpointstringRancher server endpoint URL (required for Rancher, optional with --file)-Optional
--rancher-tokenstringRancher access token (required for Rancher, optional with --file)-Optional
--tls-certificatestringtls certificate-Optional
--uidstringUID of the cloud credential (optional)-Optional

px pxb create organization

Create a new organization in PX-Backup.

Aliases: org, o

Examples:

pxb create organization --name my-org

# With custom UID
pxb create organization --name my-org --uid org-custom-uid

Flags

FlagInput typeDescriptionDefaultRequired
--authtokenstringoidc auth token-Optional
--dry-runboolSimulate the operation without making any changesfalseOptional
--endpoint, -estringThe endpoint of the server-Optional
--labels, -lstringComma separated list of labels as key-value pairs: 'k1=v1,k2=v2'-Optional
--name, -nstringName of the organization (required)-Optional
--orgIDstringThe org id for which to query the objectdefaultOptional
--output, -ostringOutput format. One of: table|json|yaml|nametableOptional
--tls-certificatestringtls certificate-Optional
--uidstringUID of the organization (optional)-Optional

px pxb create receiver

Create a receiver for alert notifications.

This command creates a receiver that can send alert notifications via various channels. Currently supports SMTP/Email receivers with comprehensive configuration options including TLS settings, authentication, and custom certificates.

The command supports both CLI flags and YAML/JSON file input for complex configurations.

Examples:

# Create a basic SMTP receiver
pxb create receiver --name smtp-alerts --type email --from "alerts@company.com" --host "smtp.company.com" --port "587"

# Create SMTP receiver with authentication and StartTLS
pxb create receiver --name secure-smtp --type email --from "noreply@company.com" --host "smtp.gmail.com" --port "587" --authentication --auth-username "alerts@company.com" --auth-password "password" --encryption-starttls

# Create SMTP receiver with custom TLS certificates
pxb create receiver --name custom-tls-smtp --type email --from "alerts@company.com" --host "internal-smtp.company.com" --allow-custom-certificate --ca-cert-file "/path/to/ca.crt" --cert-file "/path/to/client.crt" --key-file "/path/to/client.key"

# Create receiver with TLS config from YAML/JSON file
pxb create receiver --name advanced-smtp --type email --from "alerts@company.com" --host "smtp.company.com" --tls-config-file /path/to/tls-config.yaml

# Create receiver with labels
pxb create receiver --name production-alerts --type email --from "prod-alerts@company.com" --host "smtp.company.com" --label-selectors "env=production,team=platform"

# Create receiver from complete JSON configuration file
pxb create receiver --file /path/to/receiver-config.json

Flags

FlagInput typeDescriptionDefaultRequired
--allow-custom-certificateboolAllow custom TLS certificatesfalseOptional
--auth-passwordstringSMTP authentication password-Optional
--auth-usernamestringSMTP authentication username-Optional
--authenticationboolEnable SMTP authenticationfalseOptional
--authtokenstringoidc auth token-Optional
--ca-cert-filestringPath to CA certificate file-Optional
--cert-filestringPath to client certificate file-Optional
--dry-runboolSimulate the operation without making any changesfalseOptional
--encryption-sslboolEnable SSL encryptionfalseOptional
--encryption-starttlsboolEnable StartTLS encryptionfalseOptional
--endpoint, -estringThe endpoint of the server-Optional
--filestringYAML/JSON file containing complete receiver specification-Optional
--from, -fstringSender email address (required for email type, optional with --file)-Optional
--hoststringSMTP server host address (required for email type, optional with --file)-Optional
--key-filestringPath to client private key file-Optional
--label-selectorsstringToStringLabel selectors for the receiver (key=value,key2=value2)[]Optional
--labels, -lstringComma separated list of labels as key-value pairs: 'k1=v1,k2=v2'-Optional
--labels-filestringYAML/JSON file containing labels configuration-Optional
--name, -nstringName of the receiver (required, optional with --file)-Optional
--orgIDstringThe org id for which to query the objectdefaultOptional
--output, -ostringOutput format. One of: table|json|yaml|nametableOptional
--portstringSMTP server port25Optional
--tls-certificatestringtls certificate-Optional
--tls-config-filestringPath to JSON file containing TLS configuration-Optional
--type, -tstringType of receiver (email/smtp)emailOptional
--uidstringUID of the receiver (optional, auto-generated if not provided)-Optional

px pxb create recipient

Create a recipient for alert notifications.

This command creates a recipient that can receive alert notifications from a configured receiver. Recipients define who should receive alerts and at what severity level. The recipient must be associated with an existing receiver.

The command supports both CLI flags and YAML/JSON file input for complex configurations.

Examples:

# Create an email recipient with critical alerts only
pxb create recipient --name critical-alerts --receiver-name smtp-receiver --type email --recipient-ids "admin@company.com,ops@company.com" --severity CRITICAL

# Create a recipient from JSON file
pxb create recipient --name team-alerts --receiver-name slack-receiver --recipient-ids-file /path/to/recipients.json --severity WARNING

# Create a recipient from complete JSON configuration file
pxb create recipient --file /path/to/recipient-config.json

# Create a recipient with labels and all severity levels
pxb create recipient --name all-alerts --receiver-name email-receiver --type email --recipient-ids "alerts@company.com" --label-selectors "team=platform,env=prod"

Flags

FlagInput typeDescriptionDefaultRequired
--activeboolWhether the recipient is active for receiving alertstrueOptional
--authtokenstringoidc auth token-Optional
--dry-runboolSimulate the operation without making any changesfalseOptional
--endpoint, -estringThe endpoint of the server-Optional
--file, -fstringYAML/JSON file containing complete recipient specification-Optional
--label-selectorsstringToStringLabel selectors for the recipient (key=value,key2=value2)[]Optional
--labels, -lstringComma separated list of labels as key-value pairs: 'k1=v1,k2=v2'-Optional
--labels-filestringYAML/JSON file containing labels configuration-Optional
--name, -nstringName of the recipient (required, optional with --file)-Optional
--orgIDstringThe org id for which to query the objectdefaultOptional
--output, -ostringOutput format. One of: table|json|yaml|nametableOptional
--receiver-namestringName of the receiver to associate with this recipient (required, optional with --file)-Optional
--receiver-uidstringUID of the receiver to associate with this recipient-Optional
--recipient-idsstringComma-separated list of recipient IDs (e.g., email addresses)-Optional
--recipient-ids-filestringPath to YAML/JSON file containing array of recipient IDs-Optional
--severitystringSeverity level filter for alerts (UNKNOWN, CRITICAL, WARNING)UNKNOWNOptional
--tls-certificatestringtls certificate-Optional
--type, -tstringType of recipient notification (email)emailOptional
--uidstringUID of the recipient (optional, auto-generated if not provided)-Optional

px pxb create restore

Create a restore from a backup.

This command creates a restore operation that restores Kubernetes resources and persistent volumes from a previously created backup. The restore can be performed to the same cluster or a different cluster, with optional namespace mapping and resource filtering.

The command supports both CLI flags and JSON file input for complex configurations.

Examples:

# Create a simple restore from backup
pxb create restore --name my-restore --backup-name my-backup --cluster target-cluster

# Create a restore with namespace mapping
pxb create restore --name my-restore --backup-name my-backup --cluster target-cluster --namespace-mapping "source-ns=target-ns,app-ns=new-app-ns"

# Create a restore with resource replacement
pxb create restore --name my-restore --backup-name my-backup --cluster target-cluster --replace-policy Delete

# Create a restore from JSON file
pxb create restore --name my-restore --file /path/to/restore.json

# Create a VM restore with specific resources
pxb create restore --name vm-restore --backup-name vm-backup --cluster target-cluster --backup-object-type VirtualMachine

# Create a restore with storage class mapping
pxb create restore --name my-restore --backup-name my-backup --cluster target-cluster --storage-class-mapping "old-sc=new-sc"

# GRANULAR RESTORE - Namespace filtering
# Restore only specific namespaces
pxb create restore --name filtered-restore --backup-name my-backup --cluster target-cluster --include-namespaces prod-app,prod-db

# Restore namespaces matching a pattern, excluding some
pxb create restore --name pattern-restore --backup-name my-backup --cluster target-cluster --namespace-name-pattern "^prod-.*" --exclude-namespaces prod-test

# Restore with namespace prefix (requires dynamic filter criteria, not just include-namespaces)
pxb create restore --name prefix-restore --backup-name my-backup --cluster target-cluster --namespace-name-pattern "^app.*" --target-namespace-prefix "restored-"

# Restore specific resource types from namespaces
pxb create restore --name gvk-restore --backup-name my-backup --cluster target-cluster --include-namespaces prod-app --ns-resources apps/v1/Deployment,/v1/Pod

# Restore specific resources by name
pxb create restore --name resource-restore --backup-name my-backup --cluster target-cluster --ns-include-resources "web-deploy:prod:apps:v1:Deployment,api-svc:prod::v1:Service"

# GRANULAR RESTORE - VM filtering
# Restore VMs matching a name pattern
pxb create restore --name vm-pattern-restore --backup-name vm-backup --cluster target-cluster --vm-name-pattern "^web-.*"

# Restore VMs by OS type
pxb create restore --name vm-os-restore --backup-name vm-backup --cluster target-cluster --vm-os-names ubuntu,centos

# Restore specific VMs (include only)
pxb create restore --name vm-include-restore --backup-name vm-backup --cluster target-cluster --include-vms "prod/web-vm-1,prod/web-vm-2"

# Restore VMs excluding specific ones
pxb create restore --name vm-exclude-restore --backup-name vm-backup --cluster target-cluster --exclude-vms "prod/web-vm-test,prod/web-vm-dev"

# Create with granular file inputs
pxb create restore --name my-restore --backup-name my-backup --cluster target-cluster --include-resources-file /path/to/resources.json --namespace-mapping-file /path/to/namespace-mapping.json

# Mix CLI flags with granular file inputs
pxb create restore --name my-restore --backup-name my-backup --cluster target-cluster --labels-file /path/to/labels.json --storage-class-mapping-file /path/to/storage-mapping.json

# SINGLE FILE RESTORE (SFR) - Restore individual files from VM backup
pxb create restore --name sfr-restore --backup-name vm-backup --cluster target-cluster --is-sfr --sfr-vm-name web-vm-1 --sfr-volume-name data-pvc --sfr-restore-file-info-path examples/restore/create/sfr-restore-file-info.json

Flags

FlagInput typeDescriptionDefaultRequired
--authtokenstringoidc auth token-Optional
--backup-namestringName of the backup to restore from (required, optional with --file)-Optional
--backup-object-typestringType of backup objects to restore (All, VirtualMachine)-Optional
--backup-uidstringUID of the backup to restore from-Optional
--clusterstringName of the target cluster for restore (required, optional with --file)-Optional
--cluster-uidstringUID of the target cluster-Optional
--dry-runboolSimulate the operation without making any changesfalseOptional
--endpoint, -estringThe endpoint of the server-Optional
--exclude-namespacesstringSliceList of namespaces to exclude from restore (comma-separated)[]Optional
--exclude-resourcesstringComma-separated list of specific resources to exclude from restore (format: name:namespace:group:version:kind)-Optional
--exclude-resources-filestringYAML/JSON file containing resource specifications to exclude-Optional
--exclude-vmsstringList of VMs to exclude (format: namespace/name,namespace/name). Mutually exclusive with --include-vms-Optional
--file, -fstringYAML/JSON file containing complete restore specification-Optional
--filter-filestringYAML/JSON file containing complete filter specification-Optional
--include-namespacesstringSliceList of namespaces to include in restore (comma-separated)[]Optional
--include-optional-resource-typesstringSliceOptional resource types to include (e.g., Jobs, CronJobs)[]Optional
--include-optional-resource-types-filestringYAML/JSON file containing optional resource types configuration-Optional
--include-resourcesstringComma-separated list of specific resources to restore (format: name:namespace:group:version:kind)-Optional
--include-resources-filestringYAML/JSON file containing resource specifications-Optional
--include-vmsstringList of VMs to include (format: namespace/name,namespace/name). Mutually exclusive with --exclude-vms-Optional
--is-sfrboolSet to true for single file restore (VirtualMachine file-level restore)falseOptional
--labelsstringToStringLabels for the restore (format: key1=value1,key2=value2)[]Optional
--labels-filestringYAML/JSON file containing labels configuration-Optional
--name, -nstringName of the restore (required, optional with --file)-Optional
--namespace-mappingstringToStringMapping of source to destination namespaces (format: source-ns=target-ns,app-ns=new-app-ns)[]Optional
--namespace-mapping-filestringYAML/JSON file containing namespace mapping configuration-Optional
--namespace-name-patternstringRegex pattern to match namespace names (e.g., '^prod-.*')-Optional
--ns-exclude-resourcesstringList of specific resources to exclude from namespace filter (format: name:namespace:group:version:kind, comma-separated). Can be combined with --ns-resource-name-pattern for sequential filtering. Mutually exclusive with --ns-include-resources-Optional
--ns-include-resourcesstringList of specific resources to include in namespace filter (format: name:namespace:group:version:kind, comma-separated). Can be combined with --ns-resource-name-pattern for sequential filtering. Mutually exclusive with --ns-exclude-resources-Optional
--ns-resource-name-patternstringRegex pattern to match resource names within namespaces-Optional
--ns-resourcesstringSliceList of resource types (GVKs) to filter (format: group/version/kind, e.g., apps/v1/Deployment,/v1/Pod)[]Optional
--orgIDstringThe org id for which to query the objectdefaultOptional
--output, -ostringOutput format. One of: table|json|yaml|nametableOptional
--rancher-project-mappingstringMapping of rancher projects (format: source-project=target-project)-Optional
--rancher-project-mapping-filestringYAML/JSON file containing rancher project mapping configuration-Optional
--rancher-project-name-mappingstringMapping of rancher project names (format: source-name=target-name)-Optional
--rancher-project-name-mapping-filestringYAML/JSON file containing rancher project name mapping configuration-Optional
--replace-policystringPolicy for replacing existing resources (Retain, Delete)-Optional
--sfr-restore-file-info-pathstringYAML/JSON file containing array of RestoreFileInfo objects (required when --is-sfr is true)-Optional
--sfr-vm-namestringName of the VM for file level restore (required when --is-sfr is true)-Optional
--sfr-volume-namestringPVC name - source volume from which files need to be restored (required when --is-sfr is true)-Optional
--skip-mac-maskingboolSkip MAC address masking while restoring VirtualMachinesfalseOptional
--skip-vm-restartboolSkip VM restart during VirtualMachine restorefalseOptional
--storage-class-mappingstringMapping of storage classes (format: source-sc=target-sc)-Optional
--storage-class-mapping-filestringYAML/JSON file containing storage class mapping configuration-Optional
--target-namespace-prefixstringPrefix to add to all target namespaces (mutually exclusive with --namespace-mapping, not supported for static restores with only --include-namespaces)-Optional
--tls-certificatestringtls certificate-Optional
--uidstringUID for the restore (optional, auto-generated if not provided)-Optional
--vm-filter-filestringYAML/JSON file containing VM filter specification-Optional
--vm-name-patternstringRegex pattern to match VM names (for VirtualMachine backups)-Optional
--vm-os-namesstringSliceList of OS names to filter VMs (comma-separated, e.g., ubuntu,centos)[]Optional

px pxb create role

Create a role for access control in px-backup.

This command creates a role that defines permissions for accessing px-backup services and APIs. Roles can specify which services users can access and what operations they can perform on those services.

Examples:

# Create a role from JSON file
pxb create role --name my-role --file /path/to/role.json

# Create a role with inline service and API permissions
pxb create role --name backup-admin --services "backup,restore" --apis "create,delete,inspect"

# Create a role with complex configuration from JSON
pxb create role --name custom-role --rules-file /path/to/rules.json

# Create a role with Keycloak integration
pxb create role --name keycloak-role --role-id "keycloak-uuid" --services "backup" --apis "*"

Flags

FlagInput typeDescriptionDefaultRequired
--apisstringComma-separated list of API operations-Optional
--authtokenstringoidc auth token-Optional
--dry-runboolSimulate the operation without making any changesfalseOptional
--endpoint, -estringThe endpoint of the server-Optional
--file, -fstringJSON file containing complete role specification-Optional
--labelsstringToStringLabels for the role (key1=value1,key2=value2)[]Optional
--labels-filestringJSON file containing labels configuration-Optional
--name, -nstringName of the role (required, optional with --file)-Optional
--orgIDstringThe org id for which to query the objectdefaultOptional
--output, -ostringOutput format. One of: table|json|yaml|nametableOptional
--role-idstringKeycloak role ID for external identity integration-Optional
--rulesstringColon-separated service rules (service1=api1,api2:service2=*)-Optional
--rules-filestringPath to JSON file containing role rules-Optional
--servicesstringComma-separated list of px-backup services-Optional
--tls-certificatestringtls certificate-Optional
--uidstringUID for the role (optional, auto-generated if not provided)-Optional

px pxb create rule

Create a rule for pre/post backup execution.

This command creates a rule that defines actions to be executed before or after backup operations. Rules can specify pod selectors to target specific pods and define commands to run in those pods.

Examples:

# Create a rule from JSON file
pxb create rule --name my-rule --file /path/to/rule.json

# Create a rule with inline pod selector and actions
pxb create rule --name my-rule --pod-selector "app=mysql" --actions "echo 'backup starting'"

# Create a rule with complex configuration from JSON
pxb create rule --name my-rule --rules-info-file /path/to/rules.json

# Create a rule with multiple actions
pxb create rule --name my-rule --pod-selector "app=postgres" --actions-file /path/to/actions.json

Flags

FlagInput typeDescriptionDefaultRequired
--actionsstringComma-separated list of action commands-Optional
--actions-filestringPath to JSON file containing action specifications-Optional
--authtokenstringoidc auth token-Optional
--dry-runboolSimulate the operation without making any changesfalseOptional
--endpoint, -estringThe endpoint of the server-Optional
--file, -fstringYAML/JSON file containing complete rule specification-Optional
--labels, -lstringComma separated list of labels as key-value pairs: 'k1=v1,k2=v2'-Optional
--labels-filestringYAML/JSON file containing labels configuration-Optional
--name, -nstringName of the rule (required, optional with --file)-Optional
--orgIDstringThe org id for which to query the objectdefaultOptional
--output, -ostringOutput format. One of: table|json|yaml|nametableOptional
--pod-selectorstringPod selector as key=value pairs (comma-separated)-Optional
--rules-infostringJSON string containing rules information-Optional
--rules-info-filestringPath to YAML/JSON file containing rules information-Optional
--tls-certificatestringtls certificate-Optional
--uidstringUID for the rule (optional, auto-generated if not provided)-Optional

px pxb create schedulepolicy

Create a schedule policy that defines when and how often backups should be taken.

Schedule policies can include interval, daily, weekly, and monthly backup schedules. Each schedule type supports retention policies and incremental backup counts.

The command supports both CLI flags and JSON file input for complex configurations.

Examples:

# Create a simple daily backup policy
pxb create schedulepolicy --name daily-policy --daily-time "2:00AM" --daily-retain 7

# Create a comprehensive policy with multiple schedules
pxb create schedulepolicy --name comprehensive-policy \
--interval-minutes 60 --interval-retain 5 --interval-incremental-count 3 \
--daily-time "01:00AM" --daily-retain 7 --daily-incremental-count 6 \
--weekly-day Monday --weekly-time "03:00AM" --weekly-retain 4 \
--monthly-date 1 --monthly-time "04:00AM" --monthly-retain 12

# Create weekly backup with multiple days
pxb create schedulepolicy --name multi-day-weekly \
--weekly-day "Monday,Wednesday,Friday" \
--weekly-time "11:00PM" \
--weekly-retain 4

# Create bi-weekly backup (every alternate week)
pxb create schedulepolicy --name biweekly-policy \
--weekly-day Monday \
--weekly-time "11:00PM" \
--weekly-retain 8 \
--weekly-bi-weekly

# Create bi-weekly with multiple days
pxb create schedulepolicy --name biweekly-multi \
--weekly-day "Monday,Friday" \
--weekly-time "10:00PM" \
--weekly-retain 8 \
--weekly-bi-weekly

# Create selective monthly backup (specific date, all months)
pxb create schedulepolicy --name selective-monthly \
--monthly-selective-date 15 \
--monthly-selective-time "02:00AM" \
--monthly-selective-retain 12

# Create selective monthly backup (specific date, specific months)
pxb create schedulepolicy --name selective-quarterly \
--monthly-selective-date 1 \
--monthly-selective-time "03:00AM" \
--monthly-selective-retain 4 \
--monthly-selective-months "jan,apr,jul,oct"

# Create relative monthly backup (first Monday of every month)
pxb create schedulepolicy --name relative-monthly \
--monthly-relative-day Monday \
--monthly-relative-weekly-index first \
--monthly-relative-time "04:00AM" \
--monthly-relative-retain 12

# Create relative monthly backup (last Friday of every month)
pxb create schedulepolicy --name last-friday \
--monthly-relative-day Friday \
--monthly-relative-weekly-index last \
--monthly-relative-time "11:00PM" \
--monthly-relative-retain 12

# Create an object-lock enabled policy
pxb create schedulepolicy --name object-lock-policy --for-object-lock --auto-delete \
--daily-time "02:00AM" --interval-minutes 30

# Create from JSON configuration file
pxb create schedulepolicy --file /path/to/policy.json

# Create with labels from file
pxb create schedulepolicy --name production-policy --daily-time "02:00AM" --labels-file /path/to/labels.json

# Mix CLI flags with granular file inputs
pxb create schedulepolicy --name comprehensive-policy --daily-time "01:00AM" --labels-file /path/to/labels.json

Flags

FlagInput typeDescriptionDefaultRequired
--authtokenstringoidc auth token-Optional
--auto-deleteboolAuto deletion will be enabled for scheduled backup in case of object-locked bucketfalseOptional
--daily-incremental-countint64Incremental count value for daily backup (minimum: 0, default: 6)6Optional
--daily-retainint64Retain value for daily backup (default: 7)0Optional
--daily-timestringTime value for daily backup (format: 11:20AM or 11:20PM)-Optional
--dry-runboolSimulate the operation without making any changesfalseOptional
--endpoint, -estringThe endpoint of the server-Optional
--file, -fstringJSON file containing complete schedule policy configuration-Optional
--for-object-lockboolEnable object-lock for this schedule policyfalseOptional
--interval-incremental-countint64Incremental count value for interval backup (minimum: 0, default: 6)6Optional
--interval-minutesint64Minutes value for interval backup (minimum 15)0Optional
--interval-retainint64Retain value for interval backup (default: 5)0Optional
--labelsstringToStringLabels to apply to the schedule policy (format: key1=value1,key2=value2)[]Optional
--labels-filestringJSON file containing labels configuration-Optional
--monthly-relative-daystringDay for relative monthly backup (e.g., Monday, Sun)-Optional
--monthly-relative-incremental-countint64Incremental count for relative monthly backup (minimum: 0, default: 6)6Optional
--monthly-relative-retainint64Retain value for relative monthly backup (default: 12)0Optional
--monthly-relative-timestringTime for relative monthly backup (format: 11:20AM or 11:20PM)-Optional
--monthly-relative-weekly-indexstringWeekly index for relative monthly backup (first, second, third, fourth, last)-Optional
--monthly-selective-dateint64Date for selective monthly backup (1 to 31)0Optional
--monthly-selective-incremental-countint64Incremental count for selective monthly backup (minimum: 0, default: 6)6Optional
--monthly-selective-monthsstringMonths for selective monthly backup. Comma-separated (e.g., jan,feb or January,February). Empty = all months-Optional
--monthly-selective-retainint64Retain value for selective monthly backup (default: 12)0Optional
--monthly-selective-timestringTime for selective monthly backup (format: 11:20AM or 11:20PM)-Optional
--name, -nstringName of the schedule policy (required, optional with --file)-Optional
--orgIDstringThe org id for which to query the objectdefaultOptional
--output, -ostringOutput format. One of: table|json|yaml|nametableOptional
--supports-advanced-featuresboolEnable advanced features support (multi-day weekly, bi-weekly, selective monthly, relative monthly)falseOptional
--tls-certificatestringtls certificate-Optional
--uidstringUID of the schedule policy (optional)-Optional
--weekly-bi-weeklyboolEnable bi-weekly scheduling (runs every other week instead of every week)falseOptional
--weekly-daystringDay(s) for weekly backup. Single day (e.g., Monday) or comma-separated multiple days (e.g., Monday,Wednesday,Friday)-Optional
--weekly-incremental-countint64Incremental count value for weekly backup (minimum: 0, default: 6)6Optional
--weekly-retainint64Retain value for weekly backup (default: 5)0Optional
--weekly-timestringTime value for weekly backup (format: 11:20AM or 11:20PM)-Optional

px pxb create volumeresourceonlypolicy

Create a volume resource only policy to specify which volume types should have their data skipped during backup operations.

This policy allows you to backup only the volume metadata/resources without the actual data content for specific volume types, CSI drivers, or NFS servers. This is useful for performance optimization, cost reduction, or when data is replicated elsewhere.

The command supports both CLI flags and YAML/JSON file input for complex configurations.

Examples:

# Create policy to skip Portworx volume data
pxb create volumeresourceonlypolicy --name skip-pxd --volume-types pxd

# Create policy to skip specific CSI drivers
pxb create volumeresourceonlypolicy --name skip-csi --volume-types csi --csi-drivers ebs.csi.aws.com,disk.csi.azure.com

# Create policy to skip specific NFS servers
pxb create volumeresourceonlypolicy --name skip-nfs --volume-types nfs --nfs-servers 192.168.1.100,nfs.example.com

# Create policy from YAML/JSON file
pxb create volumeresourceonlypolicy --file /path/to/policy.yaml

# Create comprehensive policy with multiple types
pxb create volumeresourceonlypolicy --name comprehensive-skip --volume-types pxd,csi,nfs --csi-drivers ebs.csi.aws.com --nfs-servers 192.168.1.100

# Create with granular file inputs
pxb create volumeresourceonlypolicy --name production-policy --volume-types-file /path/to/volume-types.json --csi-drivers-file /path/to/csi-drivers.json --labels-file /path/to/labels.json

# Mix CLI flags with granular file inputs
pxb create volumeresourceonlypolicy --name mixed-policy --volume-types pxd --csi-drivers-file /path/to/csi-drivers.json --labels-file /path/to/labels.json

Flags

FlagInput typeDescriptionDefaultRequired
--authtokenstringoidc auth token-Optional
--csi-driversstringSliceCSI drivers to skip data for (requires 'csi' in volume-types)[]Optional
--csi-drivers-filestringYAML/JSON file containing CSI drivers configuration-Optional
--dry-runboolSimulate the operation without making any changesfalseOptional
--endpoint, -estringThe endpoint of the server-Optional
--file, -fstringYAML/JSON file containing complete policy configuration-Optional
--labelsstringToStringLabels for the policy (format: key1=value1,key2=value2)[]Optional
--labels-filestringYAML/JSON file containing labels configuration-Optional
--name, -nstringName of the volume resource only policy (required, optional with --file)-Optional
--nfs-serversstringSliceNFS servers to skip data for (requires 'nfs' in volume-types)[]Optional
--nfs-servers-filestringYAML/JSON file containing NFS servers configuration-Optional
--orgIDstringThe org id for which to query the objectdefaultOptional
--output, -ostringOutput format. One of: table|json|yaml|nametableOptional
--tls-certificatestringtls certificate-Optional
--uidstringUID of the volume resource only policy-Optional
--volume-typesstringSliceVolume types to skip data for: pxd, csi, nfs[]Optional
--volume-types-filestringYAML/JSON file containing volume types configuration-Optional