Skip to content

Instantly share code, notes, and snippets.

@cwilkers
Created April 10, 2019 20:58
Show Gist options
  • Save cwilkers/502cd0f3525fdb525f6e0f842d94e4da to your computer and use it in GitHub Desktop.
Save cwilkers/502cd0f3525fdb525f6e0f842d94e4da to your computer and use it in GitHub Desktop.
Script to annotate a pod with a Velero Restic volume list
#!/bin/bash
# This script adds Velero/Restic labels to a pod according to the pod's
# current volume set (filtering to only persistentVolumeClaims)
# According to https://heptio.github.io/velero/v0.11.0/restic
# TODO: Make this script produce help if options are not given
# Currently it just assumes you mean to annotate a NooBaa server pod
# Usage:
# annotate-pod.sh namespace pod
#
NS=${1:-noobaa}
POD=${2:-noobaa-server-0}
JQUERY="-o=jsonpath={.spec.volumes[?(@.persistentVolumeClaim)].name}"
PVS=$(oc -n ${NS} get pod ${POD} ${JQUERY} | tr ' ' ,)
oc -n ${NS} annotate pod/${POD} backup.velero.io/backup-volumes=${PVS}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment