Deployment
Production deployment guides for different platforms.
systemd (Linux)
Section titled “systemd (Linux)”The recommended way to run walsync on Linux servers.
[Unit]Description=Walsync SQLite BackupAfter=network.target
[Service]Type=simpleUser=appGroup=appWorkingDirectory=/var/lib/app
# CredentialsEnvironment=AWS_ACCESS_KEY_ID=tid_xxxxxEnvironment=AWS_SECRET_ACCESS_KEY=tsec_xxxxxEnvironment=AWS_ENDPOINT_URL_S3=https://fly.storage.tigris.devEnvironment=RUST_LOG=walsync=info
# CommandExecStart=/usr/local/bin/walsync watch \ /var/lib/app/data.db \ --bucket my-backups \ --snapshot-interval 1800
# Restart policyRestart=alwaysRestartSec=5
# Security hardeningNoNewPrivileges=trueProtectSystem=strictProtectHome=trueReadWritePaths=/var/lib/app
[Install]WantedBy=multi-user.targetEnable and start:
sudo systemctl daemon-reloadsudo systemctl enable walsyncsudo systemctl start walsyncView logs:
sudo journalctl -u walsync -fCheck status:
sudo systemctl status walsyncDocker
Section titled “Docker”Dockerfile
Section titled “Dockerfile”FROM rust:1.75-slim as builderWORKDIR /appRUN cargo install walsync
FROM debian:bookworm-slimRUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*COPY --from=builder /usr/local/cargo/bin/walsync /usr/local/bin/
ENTRYPOINT ["walsync"]Docker Compose
Section titled “Docker Compose”version: '3.8'services: app: image: myapp volumes: - app-data:/data
walsync: image: walsync command: watch /data/app.db --bucket my-backups environment: AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID} AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY} AWS_ENDPOINT_URL_S3: https://fly.storage.tigris.dev RUST_LOG: walsync=info volumes: - app-data:/data:ro depends_on: - app restart: always
volumes: app-data:Run:
docker-compose up -ddocker-compose logs -f walsyncFly.io
Section titled “Fly.io”fly.toml
Section titled “fly.toml”app = "myapp"
[env] AWS_ENDPOINT_URL_S3 = "https://fly.storage.tigris.dev" RUST_LOG = "walsync=info"
[[mounts]] source = "data" destination = "/data"
[processes] app = "myapp" walsync = "walsync watch /data/app.db --bucket my-backups"Set secrets
Section titled “Set secrets”fly secrets set AWS_ACCESS_KEY_ID=tid_xxxxxfly secrets set AWS_SECRET_ACCESS_KEY=tsec_xxxxxScale the walsync process
Section titled “Scale the walsync process”fly scale count walsync=1Kubernetes
Section titled “Kubernetes”Deployment
Section titled “Deployment”apiVersion: apps/v1kind: Deploymentmetadata: name: walsyncspec: replicas: 1 selector: matchLabels: app: walsync template: metadata: labels: app: walsync spec: containers: - name: walsync image: walsync:latest args: - watch - /data/app.db - --bucket - my-backups env: - name: AWS_ACCESS_KEY_ID valueFrom: secretKeyRef: name: walsync-secrets key: aws-access-key-id - name: AWS_SECRET_ACCESS_KEY valueFrom: secretKeyRef: name: walsync-secrets key: aws-secret-access-key - name: AWS_ENDPOINT_URL_S3 value: https://fly.storage.tigris.dev - name: RUST_LOG value: walsync=info volumeMounts: - name: data mountPath: /data readOnly: true volumes: - name: data persistentVolumeClaim: claimName: app-dataSecret
Section titled “Secret”apiVersion: v1kind: Secretmetadata: name: walsync-secretstype: OpaquestringData: aws-access-key-id: tid_xxxxx aws-secret-access-key: tsec_xxxxxkubectl apply -f walsync-secret.yamlkubectl apply -f walsync-deployment.yamlkubectl logs -f deployment/walsyncSidecar Pattern
Section titled “Sidecar Pattern”Run walsync as a sidecar container alongside your application:
apiVersion: v1kind: Podmetadata: name: app-with-backupspec: containers: - name: app image: myapp volumeMounts: - name: data mountPath: /data
- name: walsync image: walsync args: ["watch", "/data/app.db", "--bucket", "my-backups"] env: - name: AWS_ACCESS_KEY_ID valueFrom: secretKeyRef: name: walsync-secrets key: aws-access-key-id - name: AWS_SECRET_ACCESS_KEY valueFrom: secretKeyRef: name: walsync-secrets key: aws-secret-access-key - name: AWS_ENDPOINT_URL_S3 value: https://fly.storage.tigris.dev volumeMounts: - name: data mountPath: /data readOnly: true
volumes: - name: data emptyDir: {}Health Checks
Section titled “Health Checks”Walsync doesn’t expose an HTTP endpoint, but you can monitor it via:
- Process status: Check if the walsync process is running
- S3 objects: Check for recent WAL uploads
- Logs: Monitor for errors in logs
Example health check script:
#!/bin/bash# Check if walsync process is runningpgrep -x walsync > /dev/null || exit 1
# Check for recent S3 activity (last 5 minutes)LAST_MODIFIED=$(aws s3 ls s3://my-backups/app.db/ \ --endpoint-url $AWS_ENDPOINT_URL_S3 \ --recursive | tail -1 | awk '{print $1" "$2}')
if [ -z "$LAST_MODIFIED" ]; then exit 1fi
# Parse and check timestamp (implementation depends on your needs)exit 0