ETCD的备份与恢复

备份

写一个简单的etcd备份脚本如下:
`#!/bin/bash
set -e
exec >> /var/log/backup_etcd.log

Date=date +%Y-%m-%d-%H-%M
EtcdEndpoints="localhost:2379"
EtcdCmd="/usr/bin/etcdctl"
BackupDir="/home/www/server/backup/etcd"
BackupFile="snapshot.db.$Date"

echo "date backup etcd..."

export ETCDCTL_API=3
$EtcdCmd --endpoints $EtcdEndpoints snapshot save $BackupDir/$BackupFile

echo "date backup done!"
`

恢复
etcdctl snapshot restore snapshot.db.2019-05-21-10-02 -data-dir /home/www/server/etcd
参数说明:

restore: 指定用于恢复的快照文件
-data-dir:恢复到哪个目录

posted @ 2024-01-24 14:55  戴红领巾的少年  阅读(71)  评论(0编辑  收藏  举报
感谢您的阅读,如果您觉得阅读本文对您有帮助,请点一下“推荐”按钮。本文欢迎各位转载,但是转载文章之后必须在文章页面中给出作者和原文连接