Watch for changes in a directory and sync them to S3
1M+
This container keeps a local directory synced to an AWS S3 bucket. It does an initial sync from the specified S3 bucket to a local directory (if it's empty), and then syncs that directory with that S3 bucket. If the local directory was not empty to begin with, it will not do an initial sync. This is an easy way to back a recent backup copy of data in S3 and have a new node grab it when launched.
This script is intended for a single node to sync it's files to S3, and SHOULD NOT be used as a permanent backup solution.
The download location inside the container defaults to /sync and can be changed via the SYNCDIR environment variable.
You can declare AWS credentials in 3 ways:
docker run ...
-e AWS_ACCESS_KEY_ID=1234 \
-e AWS_SECRET_ACCESS_KEY=5678 \
-e AWS_DEFAULT_REGION=us-east-1 \
...
docker run ...
-v ~/.aws:/root/.aws:ro
...
aws_credentials secret (if it exists). This will link to ~/.aws/credentials. For more information on Docker Swarm secrets, read: https://docs.docker.com/engine/swarm/secrets/. For information about a AWS CLI credentials file, read: http://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.htmldownload: (default) downloads the files and exitsupload: uploads the files and exitssync: uses inotify to upload a directory to S3 when files change (see SYNCDIR)periodic_upload: sets up a cron job to upload files to S3 periodically (see CRON_TIME and INITIAL_DOWNLOAD)periodic_download: sets up a cron job to download files from S3 periodically (see CRON_TIME and INITIAL_DOWNLOAD)AWS_ACCESS_KEY_ID (or functional IAM profile)AWS_SECRET_ACCESS_KEY (or functional IAM profile)AWS_DEFAULT_REGION (or functional IAM profile)S3PATH: the S3 synchronize location (ex: s3://mybucket/myprefix)SYNCDIR: the local synchronize location (defaults to /sync)AWS_S3_SSE: use S3 Server Side Encryption; it can be false for no encryption, aes256 or true for Server-Side Encryption with Amazon S3-Managed Keys (SSE-S3) and kms for Server-Side Encryption with AWS KMS-Managed Keys (SSE-KMS) (defaults to false). For more information refer to https://docs.aws.amazon.com/AmazonS3/latest/dev/serv-side-encryption.html (Note: Server-Side Encryption with Customer-Provided Keys (SSE-C) is not currently supported)AWS_S3_SSE_KMS_KEY_ID: The AWS KMS key ID that should be used to server-side encrypt the object in S3 (only available if use in conjunction with AWS_S3_SSE)CRON_TIME: a valid cron expression (ex: CRON_TIME='0 */6 * * *' runs every 6 hours; defaults to hourly)INITIAL_DOWNLOAD: whether to download files initially (defaults to true); this will only download the files if the directory is empty. Set this to force to skip this checkdocker run \
-e S3PATH='s3://mybucket/myprefix' \
vladgh/s3sync
docker run \
-e S3PATH='s3://mybucket/myprefix' \
vladgh/s3sync \
upload
docker run -d \
-e S3PATH='s3://mybucket/myprefix' \
-e CRON_TIME='0 */6 * * *' \
vladgh/s3sync \
cron
docker run -d \
-e S3PATH='s3://mybucket/myprefix' \
vladgh/s3sync \
sync
docker run -d \
-e S3PATH='s3://mybucket/myprefix' \
-e SYNCDIR='/mydir' \
-v $(pwd):/mydir \
vladgh/s3sync \
sync
docker run -d \
-e S3PATH='s3://mybucket/myprefix' \
-v ~/.aws:/root/.aws:ro \
vladgh/s3sync
Thanks to https://github.com/danieldreier/docker-puppet-master-ssl
Content type
Image
Digest
sha256:4f4caea62…
Size
57.4 MB
Last updated
20 days ago
docker pull vladgh/s3sync