Coder Social home page Coder Social logo

Comments (4)

johbo avatar johbo commented on September 23, 2024 1

Found out that for my case (initial restore on a re-deployment of the whole cluster) I can work around this by creating a plain Job and calling restic directly for the restore. The results are then just fine.

I am using the following small script which I inject via a ConfigMap:

apiVersion: v1
kind: ConfigMap
metadata:
  name: restore-scripts
  annotations:
    kustomize.toolkit.fluxcd.io/substitute: disabled
data:
  restore-command.sh: |
    #!/bin/bash

    set -eux -o pipefail

    : ${SNAPSHOT:=latest}

    restic restore \
      --host ${VOLUME_NAMESPACE} \
      --path /data/${VOLUME_NAME} \
      --tag ${CLUSTER_REVISION} \
      --target / \
      ${SNAPSHOT}

Note that I am also using --tag which I use to separate cluster revisions so that I can say "restore from revision 1 and backup into revision 2" within the same repository.

I've then used the k8up image in the Job itself to run everything. I think the image should be kept in sync with the k8up deployment.

apiVersion: batch/v1
kind: Job
metadata:
  name: restore
  annotations:
    kustomize.toolkit.fluxcd.io/force: enabled
spec:
  completions: 1
  parallelism: 1
  # The Job must stay, otherwise Flux will re-create it regularly
  # ttlSecondsAfterFinished:
  template:
    spec:
      containers:
        - command:
            - /scripts/restore-command.sh
          image: ghcr.io/k8up-io/k8up:v2.7.1@sha256:77114c20de9c33661fd088670465714d58a1e3df4ffc5968b446704363fb369c
          imagePullPolicy: IfNotPresent
          name: restore
          securityContext:
            runAsUser: 0
          env:
            - name: VOLUME_NAMESPACE
              value: PATCH_VOLUME_NAMESPACE
            - name: VOLUME_NAME
              value: PATCH_VOLUME_NAME
            - name: CLUSTER_REVISION
              value: "rev${cluster_bootstrap_revision}"
            - name: SNAPSHOT
              value: latest
          envFrom:
            - secretRef:
                name: k8up-restic-restore
          volumeMounts:
            - name: scripts
              mountPath: "/scripts"
            - name: data
              mountPath: "/data/PATCH_VOLUME_NAME"
      volumes:
        - name: scripts
          configMap:
            name: restore-scripts
            defaultMode: 0555
        - name: data
          persistentVolumeClaim:
            claimName: PATCH_VOLUME_NAME
      restartPolicy: OnFailure

All the things which start with PATCH have to be replaced and also the ${...} things are to be replaced with reasonable values. In my setup Flux is taking care of this for me.

The secret provides the following variables to make restic happy:

AWS_ACCESS_KEY_ID:   
AWS_SECRET_ACCESS_KEY:  
RESTIC_PASSWORD:        
RESTIC_REPOSITORY:      

Maybe this can help to work around the missing feature for others too.

from k8up.

RomanRomanenkov avatar RomanRomanenkov commented on September 23, 2024

I have the same problem. I backed up multiple PVCs in a namespace.
And when I want to restore only one particular PVC it restores the latest wrong one

from k8up.

nikolai5slo avatar nikolai5slo commented on September 23, 2024

While setting up and testing recovery pipelines I have encountered the same issue. Is there any other workaround besides manually specifying snapshot ID?

from k8up.

johbo avatar johbo commented on September 23, 2024

Did bump into this as well, think the code is here: https://github.com/k8up-io/k8up/blob/master/restic/cli/restore.go#L121

Looks to me as if there is currently no other way than specifying the snapshot ID to ensure that the right thing will be restored.

from k8up.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.