code/etcd-inmemory/files/opt/wamblee/etcd/bin/etcd-cron
2023-02-26 13:36:15 +01:00

21 lines
666 B
Bash
Executable File

#!/bin/bash
PATH=/opt/wamblee/etcd/bin:$PATH
DATE="$( date +%Y-%m-%d_%H:%M:%S )"
DIR="$( date +%Y-%m-%d )"
etcd-backup etcd-snapshot-latest.db.tmp
mv /var/lib/wamblee/etcd/etcd-snapshot-latest.db.tmp /var/lib/wamblee/etcd/etcd-snapshot-latest.db
ln /var/lib/wamblee/etcd/etcd-snapshot-latest.db /var/lib/wamblee/etcd/etcd-backup-$DATE.db
mkdir -p /var/lib/wamblee/etcd/"$DIR"
if [[ ! -r /var/lib/wamblee/etcd/$DIR/etcd-backup.db ]]
then
ln /var/lib/wamblee/etcd/etcd-snapshot-latest.db /var/lib/wamblee/etcd/$DIR/etcd-backup.db
fi
ls -t /var/lib/wamblee/etcd/etcd-backup* | awk 'NR > 10' | xargs rm -f
find /var/lib/wamblee/etcd -mtime +31 | xargs rm -rf