C.W.K.
Stream
Lesson 01 of 10 · published

백업 전략 — Hot, Cold, Streaming

~14 min · backup, production, litestream

Level 0Scout
0 XP0/80 lessons0/10 achievements
0/120 XP to next level120 XP to go0% complete

3 가지 접근, 3 가지 트레이드오프

Production SQLite 는 진짜 데이터 갖기 전 백업 전략 필요. Viable 한 3 가지:

  • Cold 백업 — writer 멈추고 파일 복사. 가장 단순, downtime 필요.
  • Online 백업sqlite3 source.db ".backup target.db" 또는 C-level sqlite3_backup API. Writer 활성 상태에서 동작; consistent snapshot 생성.
  • Streaming 백업 — Litestream/LiteFS/Turso 가 WAL 을 S3/peer/매니지드 서비스에 continuously replicate. 최근 어느 시점이든 recovery.

개인 제품 (피파, 사이드 프로젝트) 면 NAS 또는 S3 에 시간당 한 번 online 백업이 99% 재해 cover. 다중 유저 제품이면 Litestream 이 시간 대신 분 단위 데이터 손실로 point-in-time recovery 줘.

Warning: Restore 안 한 백업은 백업 아냐. 어떤 백업 setup 도 신뢰하기 전 다른 머신에 full restore drill. 진짜 incident 동안에야 백업이 corrupt/incomplete 알게 되는 제품 수가 거대.

Code

Online 백업 — daily cron·bash
#!/bin/bash
# Daily; writer 활성 상태에서 동작
set -euo pipefail

DB=/var/lib/myapp/myapp.db
DEST=/backups/myapp/$(date +%Y%m%d).db

sqlite3 "$DB" ".backup $DEST"
sqlite3 "$DEST" 'PRAGMA integrity_check'  # 복사 검증
gzip "$DEST"
Litestream — S3 로 continuous replication·yaml
# /etc/litestream.yml — 사이드카 (launchd / systemd)
dbs:
  - path: /var/lib/myapp/myapp.db
    replicas:
      - type: s3
        bucket: myapp-backups
        path:   prod/myapp
        region: us-east-1
        retention: 168h        # 7 일 point-in-time recovery

External links

Exercise

피파 (또는 본인 SQLite DB) 에 daily online 백업 setup. launchd (mac) / systemd-timer (linux) 로 schedule. 진짜 restore: 최신 백업을 다른 머신에 복사, open, PRAGMA integrity_check, row count 확인. Surprise 문서화.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.