pgBackRest로 full, differential, incremental 백업 수행
PostgreSQL백업 및 PITR명령어
sudo -u postgres pgbackrest --stanza=<stanza> --type=full backup
sudo -u postgres pgbackrest --stanza=<stanza> --type=diff backup # changes since the last full
sudo -u postgres pgbackrest --stanza=<stanza> --type=incr backup # changes since the last backup of any type
# cron example (postgres user): full on Sunday, diff on other days
# 30 1 * * 0 pgbackrest --stanza=<stanza> --type=full backup
# 30 1 * * 1-6 pgbackrest --stanza=<stanza> --type=diff backup하는 일
full 백업은 클러스터 전체를 복사하고, diff는 마지막 full 이후 변경된 파일을, incr는 유형과 관계없이 마지막 백업 이후 변경된 파일을 복사한다. 마지막에 필요한 WAL이 아카이브되었는지 검증하고 보존 정책에 따라 expire가 자동으로 실행된다.
사용 시점
정기 백업 일정: 일반적으로 주간 full + 일일 diff/incr, 대형 클러스터에서는 더 잦은 incr.
주의
이전 full이 없으면 diff/incr 요청은 자동으로 full로 승격된다. incr 체인이 길수록 복원 시간과 의존성이 커지며, 체인의 백업 하나를 잃으면 이후 백업을 사용할 수 없다. primary 부하를 줄이려면 backup-standby=y로 standby에서 백업한다(조정을 위해 primary는 여전히 필요).