#!/bin/bash PATH=/opt/wamblee/etcd/bin:$PATH if [[ $# -ne 1 ]] then echo "Usage: $0 " 1>&2 exit 1 fi BACKUP="$1" IMAGE="$( /opt/wamblee/etcd/bin/docker ps | awk '/\/etcd$/ { print $2}' )" if [[ -z "$IMAGE" ]] then echo "$0: could not create backup" 1>&2 exit 1 fi docker run --network host \ -v /etc/kubernetes/pki/etcd:/etc/kubernetes/pki/etcd \ -v /var/lib/wamblee/etcd:/var/lib/wamblee/etcd \ --rm "$IMAGE" sh -c "etcdctl \ --endpoints=https://127.0.0.1:2379 \ --cacert=/etc/kubernetes/pki/etcd/ca.crt \ --cert=/etc/kubernetes/pki/etcd/healthcheck-client.crt \ --key=/etc/kubernetes/pki/etcd/healthcheck-client.key \ snapshot save /var/lib/wamblee/etcd/$BACKUP" echo "IMAGE=$IMAGE" > /var/lib/wamblee/etcd/etcdimage echo "Backup done at /var/lib/wamblee/etcd/$BACKUP"