mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-06 15:46:57 +01:00
79 lines
2.9 KiB
Plaintext
79 lines
2.9 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * backup_and_restore/application_backup_and_restore/backing_up_and_restoring/restoring-applications.adoc
|
|
|
|
:_mod-docs-content-type: PROCEDURE
|
|
[id="oadp-creating-restore-hooks_{context}"]
|
|
= Creating restore hooks
|
|
|
|
[role="_abstract"]
|
|
You create restore hooks to run commands in a container in a pod by editing the `Restore` custom resource (CR).
|
|
|
|
You can create two types of restore hooks:
|
|
|
|
* An `init` hook adds an init container to a pod to perform setup tasks before the application container starts.
|
|
+
|
|
If you restore a Restic backup, the `restic-wait` init container is added before the restore hook init container.
|
|
|
|
* An `exec` hook runs commands or scripts in a container of a restored pod.
|
|
|
|
.Procedure
|
|
|
|
* Add a hook to the `spec.hooks` block of the `Restore` CR, as in the following example:
|
|
+
|
|
[source,yaml]
|
|
----
|
|
apiVersion: velero.io/v1
|
|
kind: Restore
|
|
metadata:
|
|
name: <restore>
|
|
namespace: openshift-adp
|
|
spec:
|
|
hooks:
|
|
resources:
|
|
- name: <hook_name>
|
|
includedNamespaces:
|
|
- <namespace> <1>
|
|
excludedNamespaces:
|
|
- <namespace>
|
|
includedResources:
|
|
- pods <2>
|
|
excludedResources: []
|
|
labelSelector: <3>
|
|
matchLabels:
|
|
app: velero
|
|
component: server
|
|
postHooks:
|
|
- init:
|
|
initContainers:
|
|
- name: restore-hook-init
|
|
image: alpine:latest
|
|
volumeMounts:
|
|
- mountPath: /restores/pvc1-vm
|
|
name: pvc1-vm
|
|
command:
|
|
- /bin/ash
|
|
- -c
|
|
timeout: <4>
|
|
- exec:
|
|
container: <container> <5>
|
|
command:
|
|
- /bin/bash <6>
|
|
- -c
|
|
- "psql < /backup/backup.sql"
|
|
waitTimeout: 5m <7>
|
|
execTimeout: 1m <8>
|
|
onError: Continue <9>
|
|
----
|
|
<1> Optional: Array of namespaces to which the hook applies. If this value is not specified, the hook applies to all namespaces.
|
|
<2> Currently, pods are the only supported resource that hooks can apply to.
|
|
<3> Optional: This hook only applies to objects matching the label selector.
|
|
<4> Optional: Timeout specifies the maximum length of time Velero waits for `initContainers` to complete.
|
|
<5> Optional: If the container is not specified, the command runs in the first container in the pod.
|
|
<6> This is the entrypoint for the init container being added.
|
|
<7> Optional: How long to wait for a container to become ready. This should be long enough for the container to start and for any preceding hooks in the same container to complete. If not set, the restore process waits indefinitely.
|
|
<8> Optional: How long to wait for the commands to run. The default is `30s`.
|
|
<9> Allowed values for error handling are `Fail` and `Continue`:
|
|
** `Continue`: Only command failures are logged.
|
|
** `Fail`: No more restore hooks run in any container in any pod. The status of the `Restore` CR will be `PartiallyFailed`.
|