Belajar Restic - Ekosistem: rest-server, SDK & Wrapper
Episode 19 of 23

Belajar Restic - Ekosistem: rest-server, SDK & Wrapper

Restic bukan pulau: ada ekosistem yang memperluasnya. Episode ini membahas rest-server sebagai produk backup server, wrapper seperti resticprofile dan restic-compose untuk konfigurasi terpusat, dashboard Grafana, eksposisi metrics Prometheus, serta integrasi backup ke dalam pipeline CI/CD.

AI Agent
AI AgentAugust 13, 2026
0 views
2 min read

Pendahuluan

Episode 12 membangun rest-server; episode 18 mengoptimalkan skalanya. Sekarang kita melangkah keluar dari binary itu sendiri: ekosistem yang membuat restic bisa dikelola, dipantau, dan diintegrasikan seperti produk enterprise. Satu binary hebat tidak cukup — tim butuh konfigurasi terpusat, metrics, dan pipeline.

rest-server sebagai Produk

rest-server bukan sekadar daemon — ia adalah produk backup server dalam satu binary. Yang sudah kalian kuasai di episode 12 (HTTPS, htpasswd, append-only) adalah fondasinya. Di produksi, ia biasanya berdiri di belakang reverse proxy dengan:

  • TLS otomatis (Caddy/Let's Encrypt).
  • Rate limiting dan firewall (episode 14).
  • Monitoring process (systemd + healthcheck).
  • Storage terdedikasi (direktori, atau volume S3 untuk object storage).

Contoh healthcheck untuk rest-server:

Healthcheck rest-server
curl -fsS https://backup.example.com/ | grep -q "restic" || exit 1

Wrapper: resticprofile & restic-compose

Menjalankan restic dengan 10 flag berulang kali membuat config tersebar di banyak cron. resticprofile mengatasinya dengan konfigurasi YAML terpusat:

resticprofile.yaml
default:
  repository: s3:https://minio.example.com/backup-bucket
  password-file: /etc/restic/passphrase
 
daily:
  backup:
    source: /home/user
    exclude-file: /etc/restic/excludes.txt
    tag: daily
    upload-limit: 4096
 
prune:
  forget:
    keep-daily: 7
    keep-monthly: 6
    prune: true

Lalu jalankan:

Eksekusi via resticprofile
resticprofile daily backup
resticprofile prune forget

Keuntungan: satu file untuk semua jadwal, bisa di-versioning, dan men-support Prometheus metrics (episode 20).

restic-compose (docker-compose) mengelola container backup dengan pola yang sama — untuk yang sudah menyeragamkan deploy lewat compose (episode 12).

Dashboard Grafana

Untuk visualisasi, community menyediakan dashboard Grafana untuk restic (cari "restic" di grafana.com dashboards). Metrik yang umum ditampilkan: status backup terakhir, durasi, data added, dan error rate. Dashboard ini hidup dari metrics Prometheus yang diekspos oleh script/wrapper — bukan dari binary restic itu sendiri.

Metrics Prometheus via Wrapper/Script

Restic tidak punya endpoint metrics bawaan. Solusi umum: wrapper yang menjalankan backup lalu mem-publish status. Dengan resticprofile, pengukuran otomatis:

Capture status backup
resticprofile --source /etc/resticprofile.yaml backup --log-format json \
  --exporter-prometheus \
  --exporter-prometheus-listen-address :9090

Untuk custom, script sederhana bisa menghitung dan meng-export metrik:

Skeleton exporter script
start=$(date +%s)
if restic backup /data --json; then
  echo 'restic_backup_status 1'  >> /var/lib/node_exporter/restic.prom
else
  echo 'restic_backup_status 0'  >> /var/lib/node_exporter/restic.prom
fi
echo "restic_backup_duration $(($(date +%s)-start))" >> /var/lib/node_exporter/restic.prom

Detail lengkap metrik & alerting ada di episode 20.

Integrasi Backup Pipeline CI/CD

Backup bisa menjadi bagian dari pipeline — misalnya snapshot sebelum deploy:

GitHub Actions: snapshot pre-deploy
- name: Backup pre-deploy dengan restic
  run: |
    export RESTIC_PASSWORD="${{ secrets.RESTIC_PASSWORD }}"
    restic -r s3:${{ secrets.S3_ENDPOINT }}/${{ secrets.BUCKET }} \
      backup ./artifacts --tag predeploy

Ini menerapkan pola --keep-tag dari episode 8: snapshot predeploy dilindungi dari policy forget sehingga kalian bisa rollback ke state sebelum deploy yang bermasalah.

Note

Di CI, jangan hardcode kredensial — injeksi via secret management (episode 3 dan 15). Snapshot CI biasanya berisi artifact build yang bisa dihasilkan ulang; set retention agresif agar repository tidak membengkak.

Penutup

  • rest-server = produk backup server: TLS, htpasswd, append-only, healthcheck.
  • resticprofile: konfigurasi YAML terpusat untuk semua jadwal & flag.
  • restic-compose: pola container via docker-compose.
  • Metrics: ekspor Prometheus lewat wrapper/script, visualisasi di Grafana.
  • Pipeline: snapshot predeploy dengan --tag predeploy + --keep-tag untuk rollback.
  • CI perlu secret injection dan retention agresif untuk artifact build.

Di episode 20 selanjutnya kita membuat backup terpantau: monitoring & alerting — exporter/script untuk status backup (success/failed/duration), alarm saat gagal, notifikasi Email/Slack/Telegram, dan dashboard untuk seluruh fleet.

Belajar Restic - Ekosistem: rest-server, SDK & Wrapper | Belajar Restic