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)
| Flag | Short | Type | Description |
|---|---|---|---|
--name | -n | string | Name of the restore (required, optional with --file) |
--backup-name | string | Name of the backup to restore from (required, optional with --file) | |
--cluster | string | Name of the target cluster (required, optional with --file) |
Optional Identification
| Flag | Short | Type | Description |
|---|---|---|---|
--uid | string | UID for the restore (optional) | |
--backup-uid | string | UID of the backup | |
--cluster-uid | string | UID of the target cluster |
Namespace and Project Mapping
| Flag | Short | Type | Description |
|---|---|---|---|
--namespace-mapping | map | Map of source to destination namespaces (e.g., source=target,app=new-app) | |
--namespace-mapping-file | string | YAML/JSON file with namespace mapping | |
--rancher-project-mapping | map | Map of Rancher project IDs (source=target) | |
--rancher-project-mapping-file | string | YAML/JSON file with Rancher project mapping | |
--rancher-project-name-mapping | map | Map of Rancher project names (source=target) | |
--rancher-project-name-mapping-file | string | JSON file with Rancher project name mapping |
Resource Selection
| Flag | Short | Type | Description |
|---|---|---|---|
--include-resources | string | Specific resources to restore (name:namespace:group:version:kind list) | |
--include-resources-file | string | JSON file with array of resource objects | |
--include-optional-resource-types | []string | Optional k8s resource types to include (e.g., Jobs,CronJobs) | |
--include-optional-resource-types-file | string | JSON file with array of resource type strings |
Policies and Types
| Flag | Short | Type | Description |
|---|---|---|---|
--replace-policy | string | Policy for existing resources: Retain (default) or Delete | |
--backup-object-type | string | All (default) or VirtualMachine |
Storage and Metadata
| Flag | Short | Type | Description |
|---|---|---|---|
--storage-class-mapping | map | Map storage classes (source-sc=target-sc) | |
--storage-class-mapping-file | string | JSON file with storage class mapping | |
--labels | map | Labels to set on the restore (key=value,key2=value2) | |
--labels-file | string | YAML/JSON file with labels |
File Input
| Flag | Short | Type | Description |
|---|---|---|---|
--file | -f | string | YAML/JSON file with complete restore specification |
Get Restore Flags
Resource Identification
| Flag | Short | Type | Description |
|---|---|---|---|
--name | -n | string | Name of the restore to inspect (required for inspect; omit to list) |
--uid | string | UID of the restore to inspect (optional; used with --name) |
Filtering Options
| Flag | Short | Type | Description |
|---|---|---|---|
--name-filter | string | Filter restores by name pattern (substring match) | |
--cluster-name-filter | string | Filter restores by cluster name pattern (substring match) | |
--cluster-uid-filter | string | Filter restores by cluster UID | |
--status | []string | Filter by restore status: Success, Failed, PartialSuccess, Aborted, InProgress, Invalid | |
--start-time | string | Filter restores created after this time (RFC3339 format: 2024-01-01T00:00:00Z) | |
--end-time | string | Filter restores created before this time (RFC3339 format: 2024-01-07T23:59:59Z) | |
--labels | map | Filter restores by labels (key=value,key2=value2) | |
--owners | []string | Filter by restore owners (comma-separated usernames) | |
--backup-object-type | string | Filter by backup object type: 'All' or 'VirtualMachine' |
Content Options
| Flag | Short | Type | Description |
|---|---|---|---|
--include-detailed-resources | bool | Include detailed resources in output (default: true) |
Enumeration Control
| Flag | Short | Type | Description |
|---|---|---|---|
--max-objects | uint64 | Maximum number of restores to return per page (default 100) | |
--object-index | uint64 | Starting index for pagination (0-based) |