dotfiles/bin/backup-localstorage

14 lines
456 B
Plaintext
Raw Normal View History

2021-01-10 17:18:21 +00:00
#!/bin/sh
# backup
kubectl get pv -A -o json | jq '.items[] | select(.spec.storageClassName == "sc-1-name" or .spec.storageClassName == "sc-2-name")' | jq -M 'del(.spec.claimRef)' > volumes.json
kubectl get pvc -A -o json | jq '.items[] | select(.spec.storageClassName == "sc-1-name" or .spec.storageClassName == "sc-2-name")' > claims.json
tar czf data.tar.gz /data
# restore
tar xzf data.tar.gz
kubectl create claims.json
kubectl create volumes.json