Files
kube-cluster/backup.md
2026-03-31 15:30:40 +00:00

66 lines
1.2 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## 3⃣ Create the backup script on the master node
Create /usr/local/bin/backup-storage.sh:
sudo nano /usr/local/bin/backup-storage.sh
```
#!/bin/bash
set -e
SRC="/storage/"
DEST="debian@192.168.1.30:/backup/master-storage/"
SSH_KEY="/home/adrien/.ssh/id_backup"
LOG="/var/log/storage-backup.log"
echo "=== Backup started at $(date) ===" >> $LOG
rsync -aHAX --numeric-ids --delete \
--link-dest=/backup/master-storage/latest \
-e "ssh -i $SSH_KEY" \
"$SRC" "$DEST/$(date +%F)/" >> $LOG 2>&1
ssh -i $SSH_KEY debian@192.168.1.30 \
"ln -sfn /backup/master-storage/$(date +%F) /backup/master-storage/latest"
echo "=== Backup finished at $(date) ===" >> $LOG
```
### What this gives you
Daily folders (2025-01-14/)
A latest symlink
Efficient incremental backups
Clean deletions mirrored (--delete)
```
sudo crontab -e
0 2 * * * /usr/local/bin/backup-storage.sh
```
### 5⃣ Verify backups on vm-nfs
ls -lah /backup/master-storage
You should see:
2025-01-14/
latest -> 2025-01-14
## 6⃣ Restore (very important)
To restore everything:
rsync -aHAX /backup/master-storage/latest/ /storage/
To restore a single folder:
rsync -aHAX /backup/master-storage/2025-01-10/prometheus/ /storage/prometheus/