This cheat sheet presents a list of command-line executables that are frequently used by OpenShift Administrators using OADP. The commands are organized by category.
You may also find OpenShift cheat here helpful.
List:
oc get dpa -n openshift-adp
Get the details:
oc get dpa dpaname -n openshift-adp -o yaml
Update the following backup.yaml CR
apiVersion: velero.io/v1
kind: Backup
metadata:
name: replace_me_backup_name
namespace: openshift-adp
spec:
includedNamespaces:
- replace_me_namespace_1
- replace_me_namespace_2
storageLocation: dpa_replace_me
ttl: 720h0m0s
Create the backup
oc create -f backup.yaml
Update the following restore.yaml CR
apiVersion: velero.io/v1
kind: Restore
metadata:
name: replace_me_restore_name
namespace: openshift-adp
spec:
backupName: replace_me_backup_name
restorePVs: true
Get OADP CRD's
oc get crd | grep oadp
Example with the dataprotectionapplications.oadp.openshift.io
CRD
oc explain dataprotectionapplications.oadp.openshift.io
oc explain dataprotectionapplications.oadp.openshift.io.spec.features.dataMover
alias velero='oc -n openshift-adp exec deployment/velero -c velero -it -- ./velero'
alias restic='oc -n openshift-adp exec deployment/velero -c velero -it -- /usr/bin/restic'
Linux:
velero completion bash > /etc/bash_completion.d/velero
MacOS:
velero completion bash > /usr/local/etc/bash_completion.d/velero
velero backup get
velero backup create backup $backup_name --include-namespaces $namespace
velero backup create backup $backup_name --include-namespaces $namespace --default-volumes-to-fs-backup
velero backup create $backup_name --exclude-namespaces velero,default
velero backup create --from-schedule daily-backup
velero backup create $backup_name --snapshot-volumes=false -o yaml
velero backup create $backup_name --wait
velero backup delete $backup_name
Two simple steps should provide the information required
velero backup logs $backup_name
velero backup describe $backup_name --details
Name: mssql-persistent
Namespace: openshift-adp
Labels: velero.io/storage-location=velero-sample-1
Annotations: velero.io/source-cluster-k8s-gitversion=v1.23.5+b0357ed
velero.io/source-cluster-k8s-major-version=1
velero.io/source-cluster-k8s-minor-version=23
Phase: (run `velero backup logs mssql-persistent` for more information)
Errors: 2
Warnings: 0
Namespaces:
Included: mssql-persistent
Excluded: <none>
Resources:
Included: *
Excluded: <none>
Cluster-scoped: auto
Label selector: <none>
Storage Location: velero-sample-1
Velero-Native Snapshot PVs: auto
TTL: 720h0m0s
Hooks: <none>
Backup Format Version: 1.1.0
Started: 2023-06-21 23:56:51 -0700 PDT
Completed: 2023-06-22 00:07:51 -0700 PDT
Expiration: 2023-07-21 23:56:50 -0700 PDT
Resource List:
apiextensions.k8s.io/v1/CustomResourceDefinition:
- clusterserviceversions.operators.coreos.com
<SNIP>
- mssql-persistent/mssql-app-service
- mssql-persistent/mssql-service
v1/ServiceAccount:
- mssql-persistent/builder
- mssql-persistent/default
- mssql-persistent/deployer
- mssql-persistent/mssql-persistent-sa
Velero-Native Snapshots: <none included>
WARNING Do not run this command on production systems. This is a remove ALL command.
oc delete vsb -A --all; oc delete vsr -A --all; oc delete vsc -A --all; oc delete vs -A --all; oc delete replicationsources.volsync.backube -A --all; oc delete replicationdestination.volsync.backube -A --all
Details:
--all=false:
Delete all resources, in the namespace of the specified resource types.
-A, --all-namespaces=false:
If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even
if specified with --namespace.
A safer to execute a cleanup is to limit the delete to a namespace or a specific object.
- namespaced objecs: VSB, VSR, VSC, VS
- protected namespace (openshift-adp): replicationsources.volsync.backube, replicationdestination.volsync.backube
oc delete vsb -n <namespace> --all
for i in `oc get vsc -A -o custom-columns=NAME:.metadata.name`; do echo $i; oc patch vsc $i -p '{"metadata":{"finalizers":null}}' --type=merge; done
curl -o ~/.local/bin/datamover_resources.sh https://raw.githubusercontent.com/openshift/oadp-operator/master/docs/examples/datamover_resources.sh
watch -n 5 datamover_resources.sh -b -d
watch -n 5 datamover_resources.sh -r -d
oc logs -f deployment.apps/volume-snapshot-mover -n openshift-adp