Skip to content

Instantly share code, notes, and snippets.

@CypherpunkSamurai
Created September 3, 2024 11:56
Show Gist options
  • Save CypherpunkSamurai/c04aa2033c9ffcd3d28c719d50bbc0dd to your computer and use it in GitHub Desktop.
Save CypherpunkSamurai/c04aa2033c9ffcd3d28c719d50bbc0dd to your computer and use it in GitHub Desktop.
Docker Compose Sync Volume to RCLONE Remote
# services
services:
syncron:
image: rclone/rclone:latest
environment:
RCLONE_REMOTE: "remote:/"
RCLONE_SYNC_FOLDER: "/sync"
entrypoint: ["/bin/sh", "-c"]
command: |
'
mkdir -p /sync
# create
mkdir -p /etc/cron.d/
# run every min (note second format is not supported)
echo "*/1 * * * * echo "Syncing remote..." && rclone sync /sync $$RCLONE_REMOTE | tee -a /var/log/cron.log" > /etc/cron.d/sync
echo "Crontab:"
cat /etc/cron.d/sync
chmod 0644 /etc/cron.d/sync
crontab /etc/cron.d/sync
# sync
rclone listremotes
echo "Syncing from $$RCLONE_REMOTE"
rclone sync $$RCLONE_REMOTE /sync
echo "Sync Complete..." > /var/log/cron.log
# run cron
crond -f -S -l 0
'
restart: unless-stopped
volumes:
- ./rclone:/config/rclone:rw
- remotesync:/sync
healthcheck:
test: cat /var/log/cron.log || exit 1
interval: 10s
timeout: 10s
minio:
image: quay.io/minio/minio
ports:
- 9001:9001
- 9000:9000
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
MINIO_ACCESS_KEY: minioadmin
MINIO_SECRET_KEY: minioadmin
entrypoint:
[
"sh",
"-c",
"mkdir -p /data/test && minio server /data --console-address=0.0.0.0:9001",
]
deploy:
restart_policy:
condition: on-failure
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
volumes:
- remotesync:/data:rw
depends_on:
syncron:
condition: service_healthy
volumes:
remotesync:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment