diff --git a/scripts/node-backup.sh b/scripts/node-backup.sh index d32dfb5..3623c02 100755 --- a/scripts/node-backup.sh +++ b/scripts/node-backup.sh @@ -17,3 +17,7 @@ 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 + +# Cleanup backups older than 7 days +find /backup/etcd -type f -mtime +7 -delete +find /backup/ceph -type f -mtime +7 -delete diff --git a/systemd/node-backup.service b/systemd/node-backup.service index 4244778..a547cd7 100644 --- a/systemd/node-backup.service +++ b/systemd/node-backup.service @@ -1,2 +1,6 @@ +[Unit] +Description=Backup K8s node etcd and ceph data + +[Service] Type=oneshot -ExecStart=/scripts/node-backup.sh \ No newline at end of file +ExecStart=/bin/bash /scripts/node-backup.sh \ No newline at end of file diff --git a/systemd/node-backup.timer b/systemd/node-backup.timer index e69de29..3773a04 100644 --- a/systemd/node-backup.timer +++ b/systemd/node-backup.timer @@ -0,0 +1,9 @@ +[Unit] +Description=K8s node backup timer + +[Timer] +OnStartupSec=450s +OnUnitInactiveSec=86400s + +[Install] +WantedBy=timers.target \ No newline at end of file