기타

Apache APISIX의 환경 설정값을 백업

ipxy 2025. 4. 18. 15:42
728x90

Apache APISIX의 환경 설정값을 백업하려면, 다음 주요 파일들과 설정 요소들을 확인하고 백업하면 됩니다.


✅ 1. 주요 설정 파일 백업 목록

경로 설명
/usr/local/apisix/conf/config.yaml APISIX의 핵심 설정 파일 (플러그인, etcd, 로그 등 설정 포함)
/usr/local/apisix/conf/apisix.yaml 정적 Route 및 Upstream 정의 파일 (선택적으로 사용됨)
/usr/local/apisix/conf/config-default.yaml 기본값 설정 파일 (사용자 설정 아님, 참고용)
/usr/local/apisix/plugins/ Lua 기반 커스텀 플러그인 디렉토리
/usr/local/apisix/conf/certs/ SSL 인증서 저장 디렉토리 (HTTPS 설정 시)

💡 기본 설치 경로는 /usr/local/apisix/이며, 도커나 Helm 환경에서는 경로가 다를 수 있습니다.


✅ 2. etcd에 저장되는 동적 설정 백업

APISIX는 대부분의 설정(Routes, Services, Upstreams 등)을 etcd에 저장합니다. 따라서 etcd 데이터도 백업해야 합니다.

방법 1: etcd snapshot 백업

ETCDCTL_API=3 etcdctl \
  --endpoints=https://127.0.0.1:2379 \
  --cacert=/etc/etcd/ssl/ca.pem \
  --cert=/etc/etcd/ssl/etcd.pem \
  --key=/etc/etcd/ssl/etcd-key.pem \
  snapshot save /backup/etcd_snapshot.db

방법 2: etcd의 모든 Key-Value JSON 백업

ETCDCTL_API=3 etcdctl get "" --prefix --keys-only > etcd-keys.txt
ETCDCTL_API=3 etcdctl get "" --prefix -w=json > etcd-backup.json

✅ 3. Helm 기반 설치 시

Helm으로 설치한 경우에는 아래 값 파일(values.yaml)도 함께 백업:

helm get values apisix -n apisix > apisix-values-backup.yaml

✅ 4. 전체 백업 스크립트 예시 (로컬 설치 기준)

#!/bin/bash

BACKUP_DIR=~/apisix-backup-$(date +%Y%m%d)
mkdir -p $BACKUP_DIR

echo "📁 config.yaml 백업"
cp /usr/local/apisix/conf/config.yaml $BACKUP_DIR/

echo "📁 apisix.yaml 백업"
cp /usr/local/apisix/conf/apisix.yaml $BACKUP_DIR/

echo "📁 certs 디렉토리 백업"
cp -r /usr/local/apisix/conf/certs $BACKUP_DIR/

echo "📁 플러그인 디렉토리 백업"
cp -r /usr/local/apisix/plugins $BACKUP_DIR/

echo "📁 etcd json 백업"
ETCDCTL_API=3 etcdctl get "" --prefix -w=json > $BACKUP_DIR/etcd-backup.json

echo "✅ APISIX 설정 백업 완료: $BACKUP_DIR"

✅ 5. 복원 시 주의사항

  • 설정 파일(config.yaml, apisix.yaml)은 서비스 재시작이 필요
  • etcd 데이터 복원 시 기존 데이터가 덮어쓰기 되므로 주의 필요
ETCDCTL_API=3 etcdctl snapshot restore etcd_snapshot.db --data-dir /var/lib/etcd

필요 시 추가 백업 대상

구성 요소 백업 항목
Grafana / Prometheus 대시보드, 설정 등
Dashboard UI 설정 (별도 사용 시) /usr/local/apisix-dashboard/conf.yaml
custom Lua plugin plugins/my_plugin.lua 및 schema.json

 

728x90