To authorize the container with AWS, mount secrets with the names:
- Use
awsKeyto mount your aws key - Use
awsSecretto mount your aws secret - Use
awsSecurityTokento mount your aws security token (optional)
to the /run/secrets folder
Additional AWS parameters can be set using environment variables:
- Use
S3_HOST_BASEto specify the region of the bucket (optional) - Use
S3_BUCKET_PATHto specify the path to the s3 bucket (e.g. s3://mybucket/folder/) (required) - Use
CRON_SCHEDULEto specify the cron schedule when performing in cron mode. (e.g. 0 1 * * *)
The container can be setup to perform a one time sync from or to s3, or perform scheduled syncs to or from s3 using cron.
sync-local-to-s3Performs a one time sync to s3sync-s3-to-localPerforms a one time sync from s3cron sync-local-to-s3Performs scheduled sync to as per theCRON_SCHEDULEenvironment variable.cron sync-s3-to-localPerforms scheduled sync from as per theCRON_SCHEDULEenvironment variable.
The following example demonstrates how to perform a scheduled sync every minute.
version: '3.4'
secrets:
awsKey:
file: ./secrets/awsKey
awsSecret:
file: ./secrets/awsSecret
services:
docker-s3cmd:
image: 'threevl/docker-s3cmd'
build:
context: '.'
dockerfile: 'Dockerfile'
command: ['cron', 'sync-local-to-s3']
secrets:
- awsKey
- awsSecret
volumes:
- ./samples:/opt/src
environment:
- "CRON_SCHEDULE=* * * * *"
- "S3_BUCKET_PATH=s3://canvet-backups/uploads-backup/"