etcd數據備份
環境
版本:etcd-v3.0.0-linux-amd64
目錄:/home/work/etcd-backup
程序:etcd-dump、jq
腳本:backup.sh
程序
- etcd-dump
- 使用幫助
Usage of ./etcd-dump:
-action=”“: only support backup or restore
-backupfile=”backup.db”: backup filename
-etcdaddr=”http://127.0.0.1:2379”: backup etcd address
-etcdnode=”/”: backup etcd node
-password=”“: iff not auth enable, not need
-recursive=true: recursive backup etcd node
-restorefile=”“: restore filename
-username=”“: if not auth enable, not need
- 使用幫助
腳本
- backup.sh
#!/bin/bash
cd /home/work/shell
dir=”./”
date=date -d now +%Y-%m-%d:%H`
./etcd-dump -action=”backup” -backupfile=datemvdate /home/work/etcd-backup
cd /home/work/etcd-backup
find $dir -type f -mtime +7 -delete
rm ./output
計劃任務
0 3 * * * sh /home/work/shell/backup.sh >> /home/work/etcd-backup/output
0 15 * * * sh /home/work/shell/backup.sh >> /home/work/etcd-backup/output
驗證數據
- jq,以json格式排版格式查看備份的etcd數據
cat 2016-10-12:01 | jq .
恢復數據
- 暫時沒有測試