Code Monkey home page Code Monkey logo

borg-k8s-volume-backup's Introduction

borg-k8s-volume-backup

Backing up kubernetes volumes on a node using borg backup

This repo will soon contain a docker image and kubernetes resource YAMLs for backing up kubernetes volumes in a cluster

Basic concept

  • Kubelet mounts pod volumes as /var/lib/kubelet/pods/<pod_uuid>/volumes/<volume_type>/<volume_name>
    • NOTE! volume_name here refers to the "VOLUME" attribute listed in kubectl get pvc output, NOT the "NAME" attribute
  • By iterating over /var/lib/kubelet/pods/*/volumes/*/*, we can run operations on each mounted volume on a k8s node
    • For example, by iterating over /var/lib/kubelet/pods/*/volumes/kubernetes.io~iscsi/*, we can back up each mounted iSCSI volume.

Short-term Goals

  • Done, see k8s-volume-backup.py - requires python3
    • Generic script that uses env variables for volume type, borg repo location, and borg passphrase
    • Uses kubectl get pvc in backup script to get all PVCs, and build a volume name to PVC name dictionary
    • Uses this dictionary to save backups using the PVC name rather than the volume name
      • The PVC name is typically specified by the user in a PVC resource YAML
      • The volume name may be automatically generated by a dynamic volume provisioner
      • Goal is to have archives in borg repo named something like sonarr-2020-03-01 rather than pvc-b1397318-8fa4-4216-aa6b-6568d1394e89-2020-03-01
      • Archive contents will be a 1:1 reproduction of the PVC storage contents at time of archive creation
  • TBD:
    • Generic script to restore a borg backup to a k8s volume

End goals

  • Create a docker image that can do backup/restory operations
    • Mount /var/lib/kubelet/pods/ using hostPath
    • Run backup script in container to back up all mounted PVCs on the kubernetes node
  • Create a DaemonSet, so that one can easily back up all PVCs in a cluster by running the container on each node
    • Maybe even a DaemonJob, if that gets merged.
  • Create a docker container that can do restore operations
  • Create a Job template file that can be used to easily restore a borg backup archive to a PVC

borg-k8s-volume-backup's People

Contributors

hubbeking avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

heartshare

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.