Sign inSign up

zachbg/s3-sync

By zachbg

•Updated 6 months ago

Continuous file sync between Docker volumes and S3/R2/MinIO with watch mode

Image
1

2.8K

zachbg/s3-sync repository overview

⁠S3 Sync

Continuously sync files between a Docker volume and S3/R2/MinIO. Supports interval-based polling, filesystem watching, and bidirectional sync.

⁠Why?

Most backup solutions are schedule-based. This image provides continuous file sync, so your data is always backed up. Works with AWS S3, Cloudflare R2, MinIO, and any S3-compatible storage.

⁠Quick Start

services:
  s3-sync:
    image: zachbg/s3-sync:latest
    restart: unless-stopped
    volumes:
      - app-data:/data
    environment:
      S3_BUCKET: my-bucket
      AWS_ACCESS_KEY_ID: your-key
      AWS_SECRET_ACCESS_KEY: your-secret
      AWS_DEFAULT_REGION: us-east-1
      SYNC_INTERVAL: 300

⁠Environment Variables

VariableDefaultDescription
S3_BUCKETrequiredS3 bucket name
S3_PREFIXPrefix/folder inside the bucket
AWS_ACCESS_KEY_IDAWS access key
AWS_SECRET_ACCESS_KEYAWS secret key
AWS_DEFAULT_REGIONAWS region
AWS_ENDPOINT_URLCustom S3 endpoint (R2, MinIO)
DATA_DIR/dataLocal directory to sync
DIRECTIONuploadupload, download, or both
SYNC_MODEintervalinterval, watch, or once
SYNC_INTERVAL300Seconds between syncs (interval mode)
DELETE_REMOVEDfalseDelete remote files removed locally
EXCLUDEComma-separated exclude patterns
INCLUDEComma-separated include patterns
INITIAL_SYNCtrueRun sync immediately on start

⁠Examples

⁠Cloudflare R2
environment:
  S3_BUCKET: my-bucket
  AWS_ACCESS_KEY_ID: r2-key
  AWS_SECRET_ACCESS_KEY: r2-secret
  AWS_ENDPOINT_URL: https://account-id.r2.cloudflarestorage.com
  SYNC_INTERVAL: 60
⁠Real-time watch mode
environment:
  S3_BUCKET: my-bucket
  SYNC_MODE: watch
⁠Download from S3 on startup
environment:
  S3_BUCKET: my-bucket
  DIRECTION: download
  SYNC_MODE: once
⁠Bidirectional sync with exclusions
environment:
  S3_BUCKET: my-bucket
  DIRECTION: both
  EXCLUDE: "*.tmp,*.log,.git/*"
  DELETE_REMOVED: "true"
  SYNC_INTERVAL: 120

Tag summary

Content type

Image

Digest

sha256:a4e99af45…

Size

42.9 MB

Last updated

6 months ago

docker pull zachbg/s3-sync