1
0
IaC/scripts/node-backup.sh

24 lines
779 B
Bash
Raw Permalink Normal View History

2024-02-02 07:24:47 -05:00
#!/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
2024-02-10 05:12:35 -05:00
# Cleanup backups older than 7 days
find /backup/etcd -type f -mtime +7 -delete
find /backup/ceph -type f -mtime +7 -delete