:whale: :package: :rocket: - Simple tool to dump and restore kubernetes resources
Kubedump - Simple tool to dump and restore kubernetes resources

Introduction
Kubedump is a simple tool to make easy backups and workloads migrations between clusters.
Installation
Docker
docker pull fidelissauro/kubedump:latest
docker run --network -v ~/.kubeconfig:/home/root/.kubeconfig host -it fidelissauro/kubedump:latest dump chip
MacOS amd64
wget https://github.com/msfidelis/kubedump/releases/download/v0.1.8/kubedump0.1.8darwin_arm64 -O kubedump
mv kubedump /usr/local/bin
chmod +x /usr/local/bin/kubedump
MacOS arm64
wget https://github.com/msfidelis/kubedump/releases/download/v0.1.8/kubedump0.1.8darwin_amd64 -O kubedump
mv kubedump /usr/local/bin
chmod +x /usr/local/bin/kubedump
Linux amd64
wget https://github.com/msfidelis/kubedump/releases/download/v0.1.8/kubedump0.1.8linux_amd64 -O kubedump
mv kubedump /usr/local/bin
chmod +x /usr/local/bin/kubedump
Linux arm64
wget https://github.com/msfidelis/kubedump/releases/download/v0.1.8/kubedump0.1.8linux_arm64 -O kubedump
mv kubedump /usr/local/bin
chmod +x /usr/local/bin/kubedump
Freebsd amd64
wget https://github.com/msfidelis/kubedump/releases/download/v0.1.8/kubedump0.1.8freebsd_amd64 -O kubedump
mv kubedump /usr/local/bin
chmod +x /usr/local/bin/kubedump
Freebsd arm64
wget https://github.com/msfidelis/kubedump/releases/download/v0.1.8/kubedump0.1.8freebsd_arm64 -O kubedump
mv kubedump /usr/local/bin
chmod +x /usr/local/bin/kubedump
Usage
kubedump --help
Usage: kubedump [command]
Available Commands: completion Generate the autocompletion script for the specified shell dump dump all resources of a Kubernetes namespace dump-file dump all resources of with file custom configs help Help about any command restore restore all resources dumped using kubedump of a Kubernetes namespace restore-file restore all resources of with custom configs from configuration files
Flags: -h, --help help for kubedump
Use "kubedump [command] --help" for more information about a command.
## Usage - Dumpbash kubedump dump --help
dump all resources of a Kubernetes namespace
Usage: kubedump dump [namespace] [flags]
Flags: -d, --dry-run Perform a dry-run backup (no actual backup will be performed) --format string Dump output format (default "yaml") -h, --help help for dump --kubectl-location string Custom kubectl binary or alias (default "kubectl") --project string Project name (default "kubedump") --resources string Kubernetes resources separated by comma (default "deployment,service,hpa,ingress,serviceaccount,daemonset,statefulset,job,cronjob")
### Dump namespace resourcesbash โฏ kubedump dump chip --project cluster_x
2023/08/02 21:48:08 INFO Starting dump namespace=chip 2023/08/02 21:48:08 INFO Dumping resources namespace=chip resource=namespace 2023/08/02 21:48:08 INFO Dumping resources namespace=chip resource=deployment 2023/08/02 21:48:08 INFO Dumping resources namespace=chip resource=service 2023/08/02 21:48:08 INFO Dumping resources namespace=chip resource=hpa 2023/08/02 21:48:08 INFO Dumping resources namespace=chip resource=ingress 2023/08/02 21:48:08 INFO Dumping resources namespace=chip resource=serviceaccount 2023/08/02 21:48:08 INFO Dumping resources namespace=chip resource=daemonset 2023/08/02 21:48:08 INFO Dumping resources namespace=chip resource=statefulset 2023/08/02 21:48:08 INFO Dumping resources namespace=chip resource=job 2023/08/02 21:48:08 INFO Dumping resources namespace=chip resource=cronjob 2023/08/02 21:48:08 INFO Success namespace=chip outputfiles=./clusterx/chip
An folder will be created with project name, with output structure like โฏ tree cluster_x cluster_x โโโ chip โโโ 00-namespace.yaml โโโ cronjob.yaml โโโ daemonset.yaml โโโ deployment.yaml โโโ hpa.yaml โโโ ingress.yaml โโโ job.yaml โโโ service.yaml โโโ serviceaccount.yaml โโโ statefulset.yaml ### Dump custom resourcesbash kubedump dump chip --project cluster_x --resources deployment,service,hpa,ingress,serviceaccount,daemonset,statefulset,job,cronjob,virtualservice,gateway,destinationrules
2023/08/02 21:49:19 INFO Starting dump namespace=chip 2023/08/02 21:49:19 INFO Dumping resources namespace=chip resource=namespace 2023/08/02 21:49:19 INFO Dumping resources namespace=chip resource=deployment 2023/08/02 21:49:19 INFO Dumping resources namespace=chip resource=service 2023/08/02 21:49:19 INFO Dumping resources namespace=chip resource=hpa 2023/08/02 21:49:19 INFO Dumping resources namespace=chip resource=ingress 2023/08/02 21:49:19 INFO Dumping resources namespace=chip resource=serviceaccount 2023/08/02 21:49:19 WARN No resource found in namespace namespace=chip resource=serviceaccount 2023/08/02 21:49:19 INFO Dumping resources namespace=chip resource=daemonset 2023/08/02 21:49:19 WARN No resource found in namespace namespace=chip resource=daemonset 2023/08/02 21:49:19 INFO Dumping resources namespace=chip resource=statefulset 2023/08/02 21:49:19 WARN No resource found in namespace namespace=chip resource=statefulset 2023/08/02 21:49:19 INFO Dumping resources namespace=chip resource=job 2023/08/02 21:49:19 WARN No resource found in namespace namespace=chip resource=job 2023/08/02 21:49:19 INFO Dumping resources namespace=chip resource=cronjob 2023/08/02 21:49:19 WARN No resource found in namespace namespace=chip resource=cronjob 2023/08/02 21:49:19 INFO Dumping resources namespace=chip resource=virtualservice 2023/08/02 21:49:19 ERRO Error to Dump resource namespace=chip resource=virtualservice file=error exit status 1="missing value" 2023/08/02 21:49:19 INFO Dumping resources namespace=chip resource=gateway 2023/08/02 21:49:19 ERRO Error to Dump resource namespace=chip resource=gateway file=error exit status 1="missing value" 2023/08/02 21:49:19 INFO Dumping resources namespace=chip resource=destinationrules 2023/08/02 21:49:20 ERRO Error to Dump resource namespace=chip resource=destinationrules file=error exit status 1="missing value" 2023/08/02 21:49:20 INFO Success namespace=chip outputfiles=./clusterx/chip
### Dump format option kubedump dump chip --project cluster_x --format yaml kubedump dump chip --project cluster_y --format json โฏ tree cluster_x cluster_x โโโ chip โโโ 00-namespace.yaml โโโ cronjob.yaml โโโ daemonset.yaml โโโ deployment.yaml โโโ hpa.yaml โโโ ingress.yaml โโโ job.yaml โโโ service.yaml โโโ serviceaccount.yaml โโโ statefulset.yaml
1 directory, 10 files โฏ tree cluster_y cluster_y โโโ chip โโโ 00-namespace.json โโโ cronjob.json โโโ daemonset.json โโโ deployment.json โโโ hpa.json โโโ ingress.json โโโ job.json โโโ service.json โโโ serviceaccount.json โโโ statefulset.json
1 directory, 10 files
## Usage - Restorebash โฏ kubedump restore --help restore all resources dumped using kubedump of a Kubernetes namespace
Usage: kubedump restore [namespace] [flags]
Flags: --config-file string kubedump config file location -h, --help help for restore --kubectl-location string Custom kubectl binary or alias (default "/usr/local/bin/kubectl") --project string Project name (default "kubedump")
bash kubedump restore chip
2023/08/02 21:50:13 INFO Restoring resources namespace=chip resource=namespace 2023/08/02 21:50:13 INFO Resources restored: namespace=chip resources=kubedump/chip/00-namespace.yaml 2023/08/02 21:50:13 INFO Resources restored: namespace=chip resources=kubedump/chip/deployment.yaml 2023/08/02 21:50:13 INFO Resources restored: namespace=chip resources=kubedump/chip/hpa.yaml 2023/08/02 21:50:13 INFO Resources restored: namespace=chip resources=kubedump/chip/ingress.yaml 2023/08/02 21:50:13 INFO Resources restored: namespace=chip resources=kubedump/chip/service.yaml
## Using Config Files
You can use dump-file and restore-file command with yaml file configuration to automate dumps between a lot of namespaces at same time.
You can create a kubedump-file.yaml example like this:
yaml project: cluster_x format: yaml namespaces: - chip - whois resources: - deployment - service - hpa - ingress - serviceaccount - daemonset - statefulset - jobs - cronjob - secret - configmap
In any case, you can bootstrap a project config file using init commandbash
kubedump init --project kubedump
2025/03/23 14:39:31 INFO Initializing project=kubedump
2025/03/23 14:39:31 INFO Project folder created folder=./kubedump/
2025/03/23 14:39:31 INFO Project file created project=./kubedump/project.yaml
bash
kubedump dump-file --config-file kubedump-file.yaml
2023/08/02 21:52:13 INFO Dumping resources namespace=chip resource=namespace 2023/08/02 21:52:13 INFO Dumping resources namespace=chip resource=deployment 2023/08/02 21:52:14 INFO Dumping resources namespace=chip resource=service 2023/08/02 21:52:14 INFO Dumping resources namespace=chip resource=hpa 2023/08/02 21:52:14 INFO Dumping resources namespace=chip resource=ingress 2023/08/02 21:52:14 INFO Dumping resources namespace=chip resource=serviceaccount 2023/08/02 21:52:14 WARN No resource found in namespace namespace=chip resource=serviceaccount 2023/08/02 21:52:14 INFO Success namespace=chip outputfiles=./clusterx/chip 2023/08/02 21:52:14 INFO Dumping resources namespace=whois resource=namespace 2023/08/02 21:52:14 INFO Dumping resources namespace=whois resource=deployment 2023/08/02 21:52:14 INFO Dumping resources namespace=whois resource=service 2023/08/02 21:52:14 INFO Dumping resources namespace=whois resource=hpa 2023/08/02 21:52:14 INFO Dumping resources namespace=whois resource=ingress 2023/08/02 21:52:14 INFO Dumping resources namespace=whois resource=serviceaccount 2023/08/02 21:52:14 WARN No resource found in namespace namespace=whois resource=serviceaccount 2023/08/02 21:52:14 INFO Success namespace=whois outputfiles=./clusterx/whois
bash kubedump restore-file --config-file kubedump-file.yaml
2023/08/02 21:52:45 INFO Restoring resources namespace=chip resource=namespace 2023/08/02 21:52:45 INFO Resources restored: namespace=chip resources=cluster_x/chip/00-namespace.yaml 2023/08/02 21:52:45 INFO Resources restored: namespace=chip resources=cluster_x/chip/deployment.yaml 2023/08/02 21:52:45 INFO Resources restored: namespace=chip resources=cluster_x/chip/hpa.yaml 2023/08/02 21:52:46 INFO Resources restored: namespace=chip resources=cluster_x/chip/ingress.yaml 2023/08/02 21:52:46 INFO Resources restored: namespace=chip resources=cluster_x/chip/service.yaml 2023/08/02 21:52:46 INFO Restoring resources namespace=whois resource=namespace 2023/08/02 21:52:46 INFO Resources restored: namespace=whois resources=cluster_x/whois/00-namespace.yaml 2023/08/02 21:52:46 INFO Resources restored: namespace=whois resources=cluster_x/whois/deployment.yaml 2023/08/02 21:52:46 INFO Resources restored: namespace=whois resources=cluster_x/whois/hpa.yaml 2023/08/02 21:52:46 INFO Resources restored: namespace=whois resources=cluster_x/whois/ingress.yaml 2023/08/02 21:52:46 INFO Resources restored: namespace=whois resources=cluster_x/whois/service.yaml ```