diff --git a/scripts/node-backup.sh b/scripts/node-backup.sh new file mode 100755 index 0000000..d32dfb5 --- /dev/null +++ b/scripts/node-backup.sh @@ -0,0 +1,19 @@ +#!/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 diff --git a/systemd/node-backup.service b/systemd/node-backup.service new file mode 100644 index 0000000..4244778 --- /dev/null +++ b/systemd/node-backup.service @@ -0,0 +1,2 @@ +Type=oneshot +ExecStart=/scripts/node-backup.sh \ No newline at end of file diff --git a/systemd/node-backup.timer b/systemd/node-backup.timer new file mode 100644 index 0000000..e69de29