Skip to main content

Restore

Description

The px pxb restore commands create and manage restores from backups. You can restore applications and persistent volumes to the same or a different cluster/namespace with powerful filtering and mapping options.

Usage

Create Restore

px pxb create restore --name <restore-name> --backup-name <backup-name> [flags]

Get Restore (Inspect)

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

Get Restore (List All)

px pxb get restore [flags]

Update Restore

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

Delete Restore

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

Examples

Basic Restore to Same Cluster

px pxb create restore \
--name app-restore \
--backup-name daily-app-backup \
--cluster prod

Restore to Different Cluster/Namespace

px pxb create restore \
--name cross-restore \
--backup-name daily-app-backup \
--cluster staging \
--namespace-mapping "app=app-restored"

Restore Specific Resources

px pxb create restore \
--name app-restore \
--backup-name daily-app-backup \
--include-resources "web:app:apps/v1:Deployment,svc:app:v1:Service"

Create from configuration file

px pxb create restore --file /path/to/restore-create.json

Example restore-create.json:

{
"createMetadata": { "name": "complex-restore" },
"backupRef": { "name": "daily-app-backup" },
"clusterRef": { "name": "staging" },
"namespaceMapping": { "app": "app-restored" },
"storageClassMapping": { "old-sc": "new-sc" },
"backupObjectType": { "type": "All" }
}

List and Inspect

# List all restores
px pxb get restore

# List restores with filtering
px pxb get restore --name-filter "prod-" --status Success,Failed
px pxb get restore --cluster-name-filter "production" --owners user1,user2
px pxb get restore --labels env=production,team=backend
px pxb get restore --start-time "2024-01-01T00:00:00Z" --end-time "2024-12-31T23:59:59Z"

# List with pagination and sorting
px pxb get restore --max-objects 50 --sort-by CreationTimestamp --sort-order Descending

# Inspect specific restore
px pxb get restore --name app-restore --output json

Advanced Filtering Examples

# Filter by name pattern
px pxb get restore --name-filter "prod-"

# Filter by cluster
px pxb get restore --cluster-name-filter "production" --cluster-uid-filter "abc-123"

# Filter by status (single or multiple)
px pxb get restore --status Success
px pxb get restore --status Success,Failed,PartialSuccess

# Filter by time range (last 30 days)
px pxb get restore --start-time "2024-01-01T00:00:00Z" --end-time "2024-01-31T23:59:59Z"

# Filter by labels
px pxb get restore --labels env=production,team=backend

# Filter by owners
px pxb get restore --owners user1,user2,admin

# Filter by backup object type
px pxb get restore --backup-object-type VirtualMachine

# Combine multiple filters
px pxb get restore \
--name-filter "app-" \
--status Success,PartialSuccess \
--cluster-name-filter "prod" \
--labels env=production \
--owners user1,user2 \
--max-objects 20

# Pagination with filtering
px pxb get restore --name-filter "prod-" --max-objects 50 --object-index 50

# Sorting with filtering
px pxb get restore --status Success --sort-by CreationTimestamp --sort-order Descending

Update and Delete

px pxb update restore --name app-restore --uid <uid> --labels env=prod,tier=frontend
px pxb delete restore --name app-restore

Flags for commands and sub-commands

Create Restore Flags

Required Flags (optional with --file)

FlagShortTypeDescription
--name-nstringName of the restore (required, optional with --file)
--backup-namestringName of the backup to restore from (required, optional with --file)
--clusterstringName of the target cluster (required, optional with --file)

Optional Identification

FlagShortTypeDescription
--uidstringUID for the restore (optional)
--backup-uidstringUID of the backup
--cluster-uidstringUID of the target cluster

Namespace and Project Mapping

FlagShortTypeDescription
--namespace-mappingmapMap of source to destination namespaces (e.g., source=target,app=new-app)
--namespace-mapping-filestringYAML/JSON file with namespace mapping
--rancher-project-mappingmapMap of Rancher project IDs (source=target)
--rancher-project-mapping-filestringYAML/JSON file with Rancher project mapping
--rancher-project-name-mappingmapMap of Rancher project names (source=target)
--rancher-project-name-mapping-filestringJSON file with Rancher project name mapping

Resource Selection

FlagShortTypeDescription
--include-resourcesstringSpecific resources to restore (name:namespace:group:version:kind list)
--include-resources-filestringJSON file with array of resource objects
--include-optional-resource-types[]stringOptional k8s resource types to include (e.g., Jobs,CronJobs)
--include-optional-resource-types-filestringJSON file with array of resource type strings

Policies and Types

FlagShortTypeDescription
--replace-policystringPolicy for existing resources: Retain (default) or Delete
--backup-object-typestringAll (default) or VirtualMachine

Storage and Metadata

FlagShortTypeDescription
--storage-class-mappingmapMap storage classes (source-sc=target-sc)
--storage-class-mapping-filestringJSON file with storage class mapping
--labelsmapLabels to set on the restore (key=value,key2=value2)
--labels-filestringYAML/JSON file with labels

File Input

FlagShortTypeDescription
--file-fstringYAML/JSON file with complete restore specification

Get Restore Flags

Resource Identification

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

Filtering Options

FlagShortTypeDescription
--name-filterstringFilter restores by name pattern (substring match)
--cluster-name-filterstringFilter restores by cluster name pattern (substring match)
--cluster-uid-filterstringFilter restores by cluster UID
--status[]stringFilter by restore status: Success, Failed, PartialSuccess, Aborted, InProgress, Invalid
--start-timestringFilter restores created after this time (RFC3339 format: 2024-01-01T00:00:00Z)
--end-timestringFilter restores created before this time (RFC3339 format: 2024-01-07T23:59:59Z)
--labelsmapFilter restores by labels (key=value,key2=value2)
--owners[]stringFilter by restore owners (comma-separated usernames)
--backup-object-typestringFilter by backup object type: 'All' or 'VirtualMachine'

Content Options

FlagShortTypeDescription
--include-detailed-resourcesboolInclude detailed resources in output (default: true)

Enumeration Control

FlagShortTypeDescription
--max-objectsuint64Maximum number of restores to return per page (default 100)
--object-indexuint64Starting index for pagination (0-based)

Sorting Options

FlagShortTypeDescription
--sort-bystringName, CreationTimestamp
--sort-orderstringAscending or Descending

File Input

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

Update Restore Flags

Required Identification (optional with --file)

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

File Input

FlagShortTypeDescription
--file-fstringYAML/JSON file with update configuration
--labels-filestringYAML/JSON file with labels to apply

Metadata

FlagShortTypeDescription
--labelsmapLabels to set on the restore (key=value,key2=value2)

Delete Restore Flags

Required Identification (optional with --file)

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

Optional Identification

FlagShortTypeDescription
--uidstringUID of the restore to delete (optional)

File Input

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

Notes

Dual Mode Operations

  • px pxb get restore without --name/--uid lists restores; with --name and/or --uid inspects one.

Required Flag Validation

  • Create requires: --name, --backup-name, --cluster.
  • Update requires: --name.
  • Delete requires: --name.
  • Get enumerations require --max-objects >= 1 (default 100).

File vs CLI Flag Precedence

  • When both --file and CLI flags are provided, CLI flags override file values.
  • File parsing supports YAML and JSON.

Resource Format Specifications

  • Include Resources format: name:namespace:group:version:kind.
  • Namespace/Storage mappings use source=target pairs, comma-separated.

Output Format Support

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

Authentication and Context

  • Organization ID, auth token, and labels are taken from the current context.