1
0
IaC/scripts/node-backup.sh
2024-02-03 01:24:47 +13:00

20 lines
654 B
Bash
Executable File

#!/bin/bash
mkdir -p /backup/etcd
mkdir -p /backup/ceph
TIMESTAMP=$(date +%Y-%m-%d_%H-%M-%S)
# Backup etcd
ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 \
--cacert=/etc/kubernetes/pki/etcd/ca.crt \
--cert=/etc/kubernetes/pki/etcd/server.crt \
--key=/etc/kubernetes/pki/etcd/server.key \
snapshot save /backup/etcd/snapshot_$TIMESTAMP.db
# Backup ceph
tar -czf /backup/ceph/ceph_$TIMESTAMP.tar.gz /var/lib/rook
# Replicate backup to hv00
rsync -az /backup/etcd/snapshot_$TIMESTAMP.db backup:/mnt/backup/etcd/snapshot_$TIMESTAMP.db
rsync -az /backup/ceph/ceph_$TIMESTAMP.tar.gz backup:/mnt/backup/ceph/ceph_$TIMESTAMP.tar.gz