Skip to content

pranjalg1331/K8Backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

K8Backup - Kubernetes Backup & Restore CLI

Overview

K8Backup is a command-line tool built with Golang, Cobra, and the Kubernetes API to streamline backing up and restoring Kubernetes resources with a single command. It supports backups for Pods, Deployments, and Persistent Volumes (PVCs), ensuring quick recovery in case of failures.

Features

  • Backup & Restore Kubernetes resources (Pods, Deployments, PVCs)
  • List & Delete backup objects
  • Supports Minikube volume snapshots
  • Simple CLI commands for efficient usage

Prerequisites

1. Kubeconfig File

The .kube/config file is required to authenticate and interact with your Kubernetes cluster. It contains the cluster configuration, credentials, and context information.

To obtain and set up your kubeconfig file:

# Copy kubeconfig from remote cluster to local machine (if applicable)
scp user@remote-server:/path/to/kubeconfig ~/.kube/config

# Set environment variable (if using a custom kubeconfig path)
export KUBECONFIG=/custom/path/to/kubeconfig

2. Minikube (For Volume Snapshots)

If using Minikube for PVC snapshots, enable the required addons:

minikube addons enable csi-hostpath-driver
minikube addons enable volumesnapshots

Usage

General Syntax

K8Backup <resource> <action> --name "resource_name" --namespace "namespace" --path "kubeconfig_path"

Backup Commands

# Backup a Pod
K8Backup pod backup --name "pod_name" --namespace "namespace" --path "kubeconfig_path"

# Backup a Deployment
K8Backup deployment backup --name "deployment_name" --namespace "namespace" --path "kubeconfig_path"

# Backup a Persistent Volume Claim (PVC)
K8Backup volume backup --name "pvc_name" --namespace "namespace" --path "kubeconfig_path"

Restore Commands

# Restore a Pod
K8Backup pod restore --object "backup_object" --path "kubeconfig_path" --name "new_pod_name"

# Restore a Deployment
K8Backup deployment restore --object "backup_object" --path "kubeconfig_path" --name "new_deployment_name"

# Restore a Persistent Volume Claim (PVC)
K8Backup volume restore --object "snapshot_name" --path "kubeconfig_path" --name "new_pvc_name"

Utility Commands

# List all backup objects
K8Backup list

# Delete a backup object
K8Backup delete --file "backup_filename"

Resources

Contributing

Contributions are welcome! Feel free to submit issues or open pull requests.

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages