Created
February 7, 2022 16:21
-
-
Save Jivvon/aec125eb77f1745ae5e7007546414371 to your computer and use it in GitHub Desktop.
Backup all k8s resources per namespace into Minio bucket
This file contains 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
# using velero | |
# backup k8s resources per namespace without pv snapshot | |
# required: velero server & client are installed | |
NAMESPACES=`kubectl get ns | grep -v NAME | awk '{ print $1 }'` | |
EXCEPT_NAMESPACES=(velero) | |
BUCKET_LOCATION=default | |
for NAMESPACE in $NAMESPACES; do | |
skip_flag=false | |
for EXCEPT_NAMESPACE in ${EXCEPT_NAMESPACES[@]}; do | |
if [[ $NAMESPACE =~ $EXCEPT_NAMESPACE ]]; then | |
skip_flag=true | |
break | |
fi | |
done | |
if [[ $skip_flag == true ]]; then | |
echo Skip Backup All Resources in ${NAMESPACE}~ | |
continue | |
fi | |
# backup logic | |
echo Backup Start All Resources in ${NAMESPACE}! | |
backup_name=daily-$NAMESPACE | |
velero schedule create $backup_name --schedule="0 */4 * * *" --ttl 720h0m0s \ | |
--include-namespaces=$NAMESPACE --storage-location $BUCKET_LOCATION | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment