Last active
March 22, 2023 16:07
-
-
Save ekanant/6f7f63a87e3e36238cf65ea255ed9122 to your computer and use it in GitHub Desktop.
Shell script for backup kubernetes everything by namespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespaces=("namespace_a" "namespace_b") | |
| for n in "${namespaces[@]}" | |
| do | |
| echo "Process for namespace=${n}" | |
| # Backup kubernetes namespace | |
| echo "Backup namespace" | |
| kubectl get namespaces "${n}" -o yaml > "ns-${n}.yaml" | |
| # Backup kubernetes deployment | |
| echo "Backup deployment" | |
| kubectl get deployment -n "${n}" -o yaml > "deployment-${n}.yaml" | |
| # Backup kubernetes service | |
| echo "Backup services" | |
| kubectl get services -n "${n}" -o yaml > "svc-${n}.yaml" | |
| # Backup kubernetes ingress | |
| echo "Backup ingress" | |
| kubectl get ingress -n "${n}" -o yaml > "ingress-${n}.yaml" | |
| # Backup kubernetes secret | |
| echo "Backup secret" | |
| kubectl get secret -n ${n} -o yaml > "secret-${n}.yaml" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment