11.6 Barman
Barman(Backup and Recovery Manager)은 2ndQuadrant(현 EDB)가 만든 PostgreSQL 백업 도구입니다. GPL 라이선스, Python 기반입니다. pgBackRest와 함께 양대 표준입니다. Barman의 구조·기본 사용·pgBackRest와의 차이를 정리합니다.
2025년 EDB가 Barman 메인테이너십 종료를 발표 — pgBarman 라이선스·운영 미래에 변화가 있습니다. 신규 도입은 pgBackRest 권장합니다. 기존 운영자는 그대로 사용 가능하지만 장기적으로는 마이그레이션 검토 대상입니다.
핵심 기능
| 기능 | 메모 |
|---|---|
풀 백업 (barman backup) | rsync 또는 pg_basebackup 모드 |
| WAL streaming/archive | pg_receivewal 또는 archive_command |
PITR (barman recover --target-time) | 시점·LSN·xid |
보존 정책 (retention_policy) | recovery window 기반 |
| 다중 서버 관리 | 한 Barman 호스트가 여러 PG 서버 |
| 백업 검증 | barman check |
| 외부 cloud (barman-cloud-*) | S3 / Azure / GCS — 보조 도구 |
구성 — 보통 별도 호스트
Barman은 별도 백업 서버를 띄워 거기에 데이터를 모으는 패턴입니다. pgBackRest는 PostgreSQL 호스트에서 실행 후 외부 repo로 push가 일반적이라 차이가 큽니다.
flowchart LR
PG["PostgreSQL primary"]
BARMAN["Barman 서버"]
STORE["로컬 디스크 또는<br/>NFS"]
PG -- "SSH + rsync<br/>또는 pg_receivewal" --> BARMAN --> STORE
classDef pg fill:#ede9fe,stroke:#6d28d9,color:#3b0764,stroke-width:2px
classDef barman fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a
classDef store fill:#d1fae5,stroke:#047857,color:#064e3b
class PG pg
class BARMAN barman
class STORE store
설치
sudo dnf install -y barman # RHEL/Rocky (PGDG)
sudo apt-get install -y barman # Debian/Ubuntubarman OS 사용자가 자동 생성합니다. 그 사용자의 SSH 키로 PostgreSQL 호스트에 접근.
설정 — /etc/barman.conf
[barman]
barman_home = /var/lib/barman
log_file = /var/log/barman/barman.log
configuration_files_directory = /etc/barman.d/
barman_user = barman
compression = gzip
retention_policy = RECOVERY WINDOW OF 14 DAYS서버별 /etc/barman.d/main.conf:
[main]
description = "Main production"
conninfo = host=primary.example.com user=barman dbname=postgres
ssh_command = ssh postgres@primary.example.com
backup_method = rsync
reuse_backup = link # 증분 (hard link)
parallel_jobs = 4
streaming_conninfo = host=primary.example.com user=streaming_barman
streaming_archiver = on
slot_name = barman
create_slot = autoPostgreSQL 측
CREATE ROLE barman LOGIN PASSWORD 'secret' SUPERUSER; -- 또는 더 세밀한 권한
CREATE ROLE streaming_barman LOGIN PASSWORD 'secret' REPLICATION;
GRANT EXECUTE ON FUNCTION pg_start_backup, pg_stop_backup TO barman;
GRANT pg_read_all_settings TO barman;
GRANT pg_read_all_stats TO barman;pg_hba.conf:
hostssl all barman 10.0.0.0/8 scram-sha-256
hostssl replication streaming_barman 10.0.0.0/8 scram-sha-256archive_command는 옵션 — streaming mode면 pg_receivewal을 Barman이 자체 띄워 WAL 수집.
검증과 첫 백업
sudo -u barman barman check main
sudo -u barman barman backup mainbarman check는 conninfo, ssh, archive, replication slot, 디스크 공간 등 한 번에 점검합니다. 자주 쓰는 운영 진단 명령합니다.
백업 목록과 복원
sudo -u barman barman list-backup main
# main 20260523T010000 - Fri May 23 01:00:00 2026 - Size: 240.5 GiB - WAL Size: 4.2 GiB
sudo -u barman barman show-backup main 20260523T010000# PITR 복원 — 다른 호스트에
sudo -u barman barman recover \
--target-time '2026-05-23 09:50:00' \
--remote-ssh-command 'ssh postgres@new-host' \
main 20260523T010000 /var/lib/pgsql/17/data복원 후 recovery.signal이 자동 생성, postgresql.conf의 restore_command도 자동 설정합니다.
보존 정책
retention_policy = RECOVERY WINDOW OF 14 DAYS
# 또는
retention_policy = REDUNDANCY 5 # 풀 백업 5개 유지RECOVERY WINDOW가 더 안전 — 14일 PITR을 항상 가능하게 백업·WAL을 자동 유지합니다.
백업 방법 비교
| 방법 | 의미 |
|---|---|
backup_method = rsync | SSH + rsync. 증분에 link 사용 |
backup_method = postgres | pg_basebackup 사용 — 더 간단, network 비용 큼 |
backup_method = snapshot | LVM/EBS 스냅샷 (PG 16+) — 매우 빠른 백업 |
rsync + reuse_backup = link 조합이 저장 공간 절약의 표준입니다. 하드 링크로 변경 안 된 파일은 공유.
barman-cloud-*
barman은 로컬 또는 NFS 저장이 중심. S3·Azure·GCS는 보조 도구 (barman-cloud-backup, barman-cloud-wal-archive, barman-cloud-restore)로 별도 운영.
sudo -u barman barman-cloud-backup \
--cloud-provider aws-s3 \
s3://my-pg-backups \
mainarchive_command:
archive_command = 'barman-cloud-wal-archive -P aws s3://my-pg-backups main %p'pgBackRest와 달리 하나의 통합 도구가 아니라 명령 모음. 운영 자동화는 직접 짜야.
pgBackRest vs Barman
| 측면 | pgBackRest | Barman |
|---|---|---|
| 외부 저장소 | 본 도구 통합 (S3/Azure/GCS/SFTP) | 보조 도구 (barman-cloud-*) |
| 증분 백업 | 페이지 단위 | rsync 하드 링크 |
| 운영 위치 | PostgreSQL 호스트에서 push | 별도 Barman 서버에서 pull |
| 검증 | verify 명령 | barman check |
| 라이선스 | BSD | GPL |
| 메인테이너십 | 활발 (Crunchy, 커뮤니티) | 2025 EDB 종료 발표 |
| 매니지드 클라우드 통합 | 일부 | 일부 |
| 한국 도입 사례 | 많음 | 있음 |
신규 도입: pgBackRest 권장. 기존 Barman 운영자는 안정 운영 가능하지만 장기적으로 마이그레이션 검토합니다.
Barman → pgBackRest 마이그레이션 패턴
- 두 도구를 같이 운영 (overlap window)
- 새 pgBackRest 풀 백업 + archive 시작
- Barman 일정 기간 유지 (오래된 PITR 보장)
- pgBackRest 운영 안정 확인 후 Barman 정지
archive_command를 한 번에 둘 다 보내는 shell 래퍼:
archive_command = '/usr/local/bin/archive_dual %p'#!/bin/bash
pgbackrest --stanza=main archive-push "$1" || exit 1
barman-archive ... # 또는 cp to barman운영 안티패턴
| 안티패턴 | 위험 |
|---|---|
| Barman 호스트 디스크 풀 | 새 백업 실패 |
barman check가 WARN인데 무시 | 사고 시 복원 실패 |
| 같은 host에 Barman + Postgres | 사고 시 둘 다 |
| 보존 정책이 너무 짧음 | PITR window 좁음 |
| streaming archiver 단독 (archive_command 없음) | streaming 실패 시 WAL 누락 |
권장: streaming + archive_command 둘 다 — 한쪽이 실패해도 백업 유지합니다.
정리
- Barman = GPL Python 기반입니다. 별도 백업 서버에 PG가 SSH/streaming으로 데이터 모음
- 풀 + WAL streaming + PITR을 통합 — pgBackRest와 유사
- 외부 저장소는 barman-cloud-* 별도 도구
- 2025 EDB 메인테이너십 종료 → 신규 도입은 pgBackRest 권장
- 기존 운영자는 안정 사용 가능하지만 장기 마이그레이션 계획
다음 절(11.7)에서는 실전 — 복구 시나리오와 정기 복구 훈련을 봅니다.