5.17.5. Creating backup hooks


Create backup hooks to run commands in a container in a pod by editing the Backup custom resource (CR). This helps you to run pre-backup and post-backup actions such as quiescing a database or flushing data to disk.

The commands can be configured to performed before any custom action processing (Pre hooks), or after all custom actions have been completed and any additional items specified by the custom action have been backed up (Post hooks).

Procedure

  • Add a hook to the spec.hooks block of the Backup CR, as in the following example:

    apiVersion: velero.io/v1
    kind: Backup
    metadata:
      name: <backup>
      namespace: openshift-adp
    spec:
      hooks:
        resources:
          - name: <hook_name>
            includedNamespaces:
            - <namespace>
            excludedNamespaces:
            - <namespace>
            includedResources: []
            - pods
            excludedResources: []
            labelSelector:
              matchLabels:
                app: velero
                component: server
            pre:
              - exec:
                  container: <container>
                  command:
                  - /bin/uname
                  - -a
                  onError: Fail
                  timeout: 30s
            post:
    ...

    where:

    <namespace>
    Optional: Specifies the namespaces to which the hook applies. If this value is not specified, the hook applies to all namespaces.
    excludedNamespaces
    Optional: Specifies the namespaces to which the hook does not apply.
    pods
    Currently, pods are the only supported resource that hooks can apply to.
    excludedResources
    Optional: Specifies the resources to which the hook does not apply.
    labelSelector
    Optional: This hook only applies to objects matching the label. If this value is not specified, the hook applies to all objects.
    pre
    Specifies an array of hooks to run before the backup.
    <container>
    Optional: Specifies the container in which the command runs. If the container is not specified, the command runs in the first container in the pod.
    /bin/uname
    Specifies the entry point for the init container being added.
    onError: Fail
    Specifies the error handling behavior. Allowed values are Fail and Continue. The default is Fail.
    timeout: 30s
    Optional: Specifies how long to wait for the commands to run. The default is 30s.
    post
    Specifies an array of hooks to run after the backup, with the same parameters as the pre-backup hooks.
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 문서 정보

Legal Notice

Theme

© 2026 Red Hat
맨 위로 이동