Skip to content

Commit 2ed6c21

Browse files
authored
Merge pull request #38552 from apinnick/oadp73-usage
OADP-73: Usage
2 parents 50adc7a + 7dc73ce commit 2ed6c21

12 files changed

+464
-20
lines changed

_topic_maps/_topic_map.yml

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,26 +2095,33 @@ Topics:
20952095
File: graceful-cluster-shutdown
20962096
- Name: Restarting a cluster gracefully
20972097
File: graceful-cluster-restart
2098-
# - Name: Application backup and restore
2099-
# Dir: application_backup_and_restore
2100-
# Topics:
2101-
# - Name: Installing OADP
2102-
# Dir: installing
2103-
# Topics:
2104-
# - Name: About installing OADP
2105-
# File: about-installing-oadp
2106-
# - Name: Installing OADP with AWS
2107-
# File: installing-oadp-aws
2108-
# - Name: Installing OADP with Azure
2109-
# File: installing-oadp-azure
2110-
# - Name: Installing OADP with GCP
2111-
# File: installing-oadp-gcp
2112-
# - Name: Installing OADP with MCG
2113-
# File: installing-oadp-mcg
2114-
# - Name: Installing OADP with OCS
2115-
# File: installing-oadp-ocs
2116-
# - Name: Configuring OADP
2117-
# File: configuring-oadp
2098+
- Name: Application backup and restore
2099+
Dir: application_backup_and_restore
2100+
Topics:
2101+
- Name: Installing OADP
2102+
Dir: installing
2103+
Topics:
2104+
- Name: About installing OADP
2105+
File: about-installing-oadp
2106+
- Name: Installing OADP with AWS
2107+
File: installing-oadp-aws
2108+
- Name: Installing OADP with Azure
2109+
File: installing-oadp-azure
2110+
- Name: Installing OADP with GCP
2111+
File: installing-oadp-gcp
2112+
- Name: Installing OADP with MCG
2113+
File: installing-oadp-mcg
2114+
- Name: Installing OADP with OCS
2115+
File: installing-oadp-ocs
2116+
- Name: Configuring OADP
2117+
File: configuring-oadp
2118+
- Name: Backing up and restoring
2119+
Dir: backing_up_and_restoring
2120+
Topics:
2121+
- Name: Backing up applications
2122+
File: backing-up-applications
2123+
- Name: Restoring applications
2124+
File: restoring-applications
21182125
- Name: Control plane backup and restore
21192126
Dir: control_plane_backup_and_restore
21202127
Topics:
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[id="backing-up-applications"]
2+
= Backing up applications
3+
include::modules/common-attributes.adoc[]
4+
:context: backing-up-applications
5+
6+
toc::[]
7+
8+
You back up applications by creating a xref:../../../backup_and_restore/application_backup_and_restore/backing_up_and_restoring/backing-up-applications.adoc#oadp-creating-backup-cr_backing-up-applications[`Backup` custom resource (CR)].
9+
10+
The `Backup` CR creates backup files for Kubernetes resources and internal images, on S3 object storage, and snapshots for persistent volumes (PVs), if the cloud provider uses a native snapshot API or the xref:../../../backup_and_restore/application_backup_and_restore/backing_up_and_restoring/backing-up-applications.adoc#oadp-backing-up-pvs-csi_backing-up-applications[Container Snapshot Interface (CSI)] to create snapshots, such as OpenShift Container Storage 4. For more information, see xref:../../../storage/container_storage_interface/persistent-storage-csi-snapshots.adoc#persistent-storage-csi-snapshots[CSI volume snapshots].
11+
12+
:FeatureName: The CloudStorage API for S3 storage
13+
include::modules/technology-preview.adoc[]
14+
15+
You can create xref:../../../backup_and_restore/application_backup_and_restore/backing_up_and_restoring/backing-up-applications.adoc#oadp-creating-backup-hooks_backing-up-applications[backup hooks] to run commands before or after the backup operation.
16+
17+
You can schedule backups by creating a xref:../../../backup_and_restore/application_backup_and_restore/backing_up_and_restoring/backing-up-applications.adoc#oadp-scheduling-backups_backing-up-applications[`Schedule` CR] instead of a `Backup` CR.
18+
19+
If your cloud provider does not support snapshots or if your applications run on NFS data volumes, you can back up applications by using xref:../../../backup_and_restore/application_backup_and_restore/backing_up_and_restoring/backing-up-applications.adoc#oadp-backing-up-applications-restic_backing-up-applications[Restic].
20+
21+
include::modules/oadp-creating-backup-cr.adoc[leveloffset=+1]
22+
include::modules/oadp-backing-up-pvs-csi.adoc[leveloffset=+1]
23+
include::modules/oadp-creating-backup-hooks.adoc[leveloffset=+1]
24+
include::modules/oadp-scheduling-backups.adoc[leveloffset=+1]
25+
include::modules/oadp-backing-up-applications-restic.adoc[leveloffset=+1]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../images
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../modules
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[id="restoring-applications"]
2+
= Restoring applications
3+
include::modules/common-attributes.adoc[]
4+
:context: restoring-applications
5+
6+
toc::[]
7+
8+
You restore application backups by creating a xref:../../../backup_and_restore/application_backup_and_restore/backing_up_and_restoring/restoring-applications.adoc#oadp-creating-restore-cr_restoring-applications[`Restore` custom resources (CRs)].
9+
10+
You can create xref:../../../backup_and_restore/application_backup_and_restore/backing_up_and_restoring/restoring-applications.adoc#oadp-creating-restore-hooks_restoring-applications[restore hooks] to run commands in init containers, before the application container starts, or in the application container itself.
11+
12+
include::modules/oadp-creating-restore-cr.adoc[leveloffset=+1]
13+
include::modules/oadp-creating-restore-hooks.adoc[leveloffset=+1]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * backup_and_restore/application_backup_and_restore/backing_up_and_restoring/backing-up-applications.adoc
4+
5+
[id="oadp-backing-up-applications-restic_{context}"]
6+
= Backing up applications with Restic
7+
8+
You can back up Kubernetes resources, internal images, and persistent volumes with Restic by editing the `Backup` custom resource (CR).
9+
10+
.Prerequisites
11+
12+
* You must install the OpenShift API for Data Protection (OADP) Operator.
13+
* You must not disable the default Restic installation by setting `spec.configuration.restic.enable` to `false` in the `DataProtectionApplication` CR.
14+
* The `DataProtectionApplication` CR must be in a `Ready` state.
15+
16+
.Procedure
17+
18+
* Edit the `Backup` CR, as in the following example:
19+
+
20+
[source,yaml]
21+
----
22+
apiVersion: velero.io/v1
23+
kind: Backup
24+
metadata:
25+
name: <backup>
26+
labels:
27+
velero.io/storage-location: default
28+
namespace: openshift-adp
29+
spec:
30+
defaultVolumesToRestic: true <1>
31+
...
32+
----
33+
<1> Add `defaultVolumesToRestic: true` to the `spec` block.

modules/oadp-backing-up-pvs-csi.adoc

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * backup_and_restore/application_backup_and_restore/backing_up_and_restoring/backing-up-applications.adoc
4+
5+
[id="oadp-backing-up-pvs-csi_{context}"]
6+
= Backing up persistent volumes with Container Snapshot Interface snapshots
7+
8+
You back up persistent volumes with Container Snapshot Interface (CSI) snapshots by editing the `DataProtectionApplication` custom resource (CR) and creating a `VolumeSnapshotClass` CR before you create a `Backup` CR.
9+
10+
.Prerequisites
11+
12+
* The cloud provider must support CSI snapshots.
13+
* You must install the OpenShift API for Data Protection (OADP) Operator.
14+
15+
.Procedure
16+
17+
. Edit the `DataProtectionApplication` CR, as in the following example:
18+
+
19+
[source,yaml]
20+
----
21+
apiVersion: oadp.openshift.io/v1alpha1
22+
kind: DataProtectionApplication
23+
...
24+
spec:
25+
configuration:
26+
velero:
27+
defaultPlugins:
28+
- openshift
29+
- csi <1>
30+
featureFlags:
31+
- EnableCSI <2>
32+
----
33+
<1> Add the `csi` default plug-in.
34+
<2> Add the `EnableCSI` feature flag.
35+
36+
. Create a `VolumeSnapshotClass` CR for your cloud provider, as in the following example:
37+
+
38+
[source,yaml]
39+
----
40+
apiVersion: snapshot.storage.k8s.io/v1
41+
kind: VolumeSnapshotClass
42+
metadata:
43+
name: <volume_snapshot_class>
44+
labels:
45+
velero.io/csi-volumesnapshot-class: "true"
46+
driver: <csi_driver> <1>
47+
deletionPolicy: Retain
48+
----
49+
<1> Specify the CSI driver, for example, `ebs.csi.aws.com`.
50+
51+
You can now create a `Backup` CR.

modules/oadp-creating-backup-cr.adoc

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * backup_and_restore/application_backup_and_restore/backing_up_and_restoring/backing-up-applications.adoc
4+
5+
[id="oadp-creating-backup-cr_{context}"]
6+
= Creating a Backup CR
7+
8+
You back up Kubernetes images, internal images, and persistent volumes (PVs) by creating a `Backup` custom resource (CR).
9+
10+
.Prerequisites
11+
12+
* You must install the OpenShift API for Data Protection (OADP) Operator.
13+
* The `DataProtectionApplication` CR must be in a `Ready` state.
14+
* Backup prerequisites:
15+
** You must have object storage configured for Velero.
16+
** You must have a backup location configured in the `DataProtectionApplication` CR.
17+
* Snapshot prerequisites:
18+
** You must have a cloud provider that uses a native snapshot API or the Container Snapshot Interface (CSI) to create snapshots, such as OpenShift Container Storage 4.
19+
** You must have a volume location configured in the `DataProtectionApplication` CR.
20+
21+
.Procedure
22+
23+
. Retrieve the `backupStorageLocations` CRs:
24+
+
25+
[source,terminal]
26+
----
27+
$ oc get backupStorageLocations
28+
----
29+
+
30+
.Example output
31+
+
32+
[source,terminal]
33+
----
34+
NAME PHASE LAST VALIDATED AGE DEFAULT
35+
velero-sample-1 Available 11s 31m
36+
----
37+
38+
. Create a `Backup` CR, as in the following example:
39+
+
40+
[source,yaml]
41+
----
42+
apiVersion: velero.io/v1
43+
kind: Backup
44+
metadata:
45+
name: <backup>
46+
labels:
47+
velero.io/storage-location: default
48+
namespace: openshift-adp
49+
spec:
50+
hooks: {}
51+
includedNamespaces:
52+
- <namespace> <1>
53+
includeClusterResources: true
54+
storageLocation: <velero-sample-1> <2>
55+
ttl: 720h0m0s
56+
----
57+
<1> Specify an array of namespaces to back up.
58+
<2> Specify the name of the `backupStorageLocations` CR.
59+
60+
. Verify that the status of the `Backup` CR is `Completed`:
61+
+
62+
[source,terminal]
63+
----
64+
$ oc get backup -n openshift-adp <backup> -o jsonpath='{.status.phase}'
65+
----
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * backup_and_restore/application_backup_and_restore/backing-up-applications.adoc
4+
5+
[id="oadp-creating-backup-hooks_{context}"]
6+
= Creating backup hooks
7+
8+
You create backup hooks to run commands in a container in a pod by editing the `Backup` custom resource (CR).
9+
10+
_Pre_ hooks run before the pod is backed up. _Post_ hooks run after the backup.
11+
12+
.Procedure
13+
14+
* Add a hook to the `spec.hooks` block of the `Backup` CR, as in the following example:
15+
+
16+
[source,yaml]
17+
----
18+
apiVersion: velero.io/v1
19+
kind: Backup
20+
metadata:
21+
name: <backup>
22+
namespace: openshift-adp
23+
spec:
24+
hooks:
25+
resources:
26+
- name: <hook_name>
27+
includedNamespaces:
28+
- <namespace> <1>
29+
excludedNamespaces:
30+
- <namespace>
31+
includedResources:
32+
- pods <2>
33+
excludedResources: []
34+
labelSelector: <3>
35+
matchLabels:
36+
app: velero
37+
component: server
38+
pre: <4>
39+
- exec:
40+
container: <container> <5>
41+
command:
42+
- /bin/uname <6>
43+
- -a
44+
onError: Fail <7>
45+
timeout: 30s <8>
46+
post: <9>
47+
...
48+
----
49+
<1> Array of namespaces to which the hook applies. If this value is not specified, the hook applies to all namespaces.
50+
<2> Currently, pods are the only supported resource.
51+
<3> Optional: This hook only applies to objects matching the label selector.
52+
<4> Array of hooks to run before the backup.
53+
<5> Optional: If the container is not specified, the command runs in the first container in the pod.
54+
<6> Array of commands that the hook runs.
55+
<7> Allowed values for error handling are `Fail` and `Continue`. The default is `Fail`.
56+
<8> Optional: How long to wait for the commands to run. The default is `30s`.
57+
<9> This block defines an array of hooks to run after the backup, with the same parameters as the pre-backup hooks.

modules/oadp-creating-restore-cr.adoc

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * backup_and_restore/application_backup_and_restore/backing_up_and_restoring/restoring-applications.adoc
4+
5+
[id="oadp-creating-restore-cr_{context}"]
6+
= Creating a Restore CR
7+
8+
You restore a `Backup` custom resource (CR) by creating a `Restore` CR.
9+
10+
.Prerequisites
11+
12+
* You must install the OpenShift API for Data Protection (OADP) Operator.
13+
* The `DataProtectionApplication` CR must be in a `Ready` state.
14+
* You must have a Velero `Backup` CR.
15+
16+
.Procedure
17+
18+
. Create a `Restore` CR, as in the following example:
19+
+
20+
[source,yaml]
21+
----
22+
apiVersion: oadp.openshift.io/v1alpha1
23+
kind: Restore
24+
metadata:
25+
name: <restore>
26+
namespace: openshift-adp
27+
spec:
28+
backupName: <backup> <1>
29+
excludedResources:
30+
- nodes
31+
- events
32+
- events.events.k8s.io
33+
- backups.velero.io
34+
- restores.velero.io
35+
- resticrepositories.velero.io
36+
restorePVs: true
37+
----
38+
<1> Name of the `Backup` CR.
39+
40+
. Verify that the status of the `Restore` CR is `Completed`:
41+
+
42+
[source,terminal]
43+
----
44+
$ oc get restore -n openshift-adp <restore> -o jsonpath='{.status.phase}'
45+
----
46+
47+
. Verify that the backup resources have been restored:
48+
+
49+
[source,terminal]
50+
----
51+
$ oc get all -n <namespace> <1>
52+
----
53+
<1> Namespace that you backed up.

0 commit comments

Comments
 (0)