Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add easy way to create an backup instance of a schedule #955

Open
toabi opened this issue Apr 9, 2024 · 2 comments
Open

Add easy way to create an backup instance of a schedule #955

toabi opened this issue Apr 9, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@toabi
Copy link

toabi commented Apr 9, 2024

Summary

As "cluster operator or developer"
I want "to quickly create a new backup off-schedule"
So that "I can run a upgrade or restore it somewhere else quickly"

Context

The Schedule objects are great to have backups in regular intervals.

But sometimes you want to have a backup now. E.g. before a cluster/app upgrade or when restoring the current state of a customer application in a local dev environment.

It would be cool to have something similar as with CronJob: kubectl create job test-job --from=cronjob/a-cronjob for Schedules.

Implementation Ideas

Maybe the Backup(https://k8up.io/k8up/2.8/how-tos/backup.html) could get a spec.backend.fromSchedule.name field where it then pulls all its info? That would be very minimal and save lots of copy-pasting that info.

@toabi toabi added the enhancement New feature or request label Apr 9, 2024
@johbo
Copy link
Contributor

johbo commented Jun 1, 2024

Just was looking for this feature. Think it would be very convenient to trigger a schedule in some form manually.

When experimenting with restore options for my setup I got cross the trigger concept of Volsync: https://volsync.readthedocs.io/en/stable/usage/triggers.html

Not too sure though if this would be a good fit. I still would like the idea to be able to annotate a Schedule in some form, so that the operator knows that I'd like it to trigger a backup from it now.

From Flux I know that they work with a different type of annotation which is based on a timestamp: https://fluxcd.io/flux/components/kustomize/kustomizations/#triggering-a-reconcile

My case behind is to ensure that I have fresh backups before re-creating my application or before making a 2nd environment for troubleshooting.

@johbo
Copy link
Contributor

johbo commented Jun 2, 2024

Did put a jq / yq script together to trigger backups of my schedules as an interim solution:

# Generate Backup instances from Schedule objects for k8up
#
# Use as follows:
# - kubectl get schedule/k8up-backup-schedule -o yaml | yq -f ./backup-from-schedule.jq -y
# - kubectl get -A schedule -o yaml | yq -f ./backup-from-schedule.jq -y | kubectl apply -f -
#
# Supports the followings args:
# - suffix: Appends the value as suffix to the resource name

# Allow to the results of "kubectl get" and "kubectl get -A" as input
if .items then .items[] else . end |

{
  apiVersion: "k8up.io/v1",
  kind: "Backup",
  metadata: {
    name: ["manual-from", .metadata.name, $ARGS.named.suffix] | map(select(.)) | join("-"),
    namespace: .metadata.namespace,
  },
  spec: (.spec.backup + {
    backend: .spec.backend,
    podSecurityContext: .spec.podSecurityContext,
  }),
} |
del(.spec.schedule)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants