Skip to content

Docker container that periodically backups files to Amazon S3 using s3cmd and cron

License

Notifications You must be signed in to change notification settings

francescor/docker-backup-to-s3

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fork of https://github.com/istepanov/docker-backup-to-s3 so to update Debian

I had the need, for security purposes, to update all valuable work done by istepanov at https://github.com/istepanov/docker-backup-to-s3 so I forked his repo here.

oriettaxx/backup-to-s3

https://hub.docker.com/r/oriettaxx/docker-backup-to-s3

docker pull oriettaxx/docker-backup-to-s3

Docker container that periodically backups files to Amazon S3 using s3cmd sync and cron.

Usage

docker run -d [OPTIONS] oriettaxx/docker-backup-to-s3

Parameters:

  • -e ACCESS_KEY=<AWS_KEY>: Your AWS key.
  • -e SECRET_KEY=<AWS_SECRET>: Your AWS secret.
  • -e S3_PATH=s3://<BUCKET_NAME>/<PATH>/: S3 Bucket name and path. Should end with trailing slash.
  • -v /path/to/backup:/data:ro: mount target local folder to container's data folder. Content of this folder will be synced with S3 bucket.

Optional parameters:

  • -e PARAMS="--dry-run": parameters to pass to the sync command (full list here).
  • -e DATA_PATH=/data/: container's data folder. Default is /data/. Should end with trailing slash.
  • -e 'CRON_SCHEDULE=0 1 * * *': specifies when cron job starts (details). Default is 0 1 * * * (runs every day at 1:00 am).
  • no-cron: run container once and exit (no cron scheduling).

Examples:

Run upload to S3 everyday at 12:00pm:

docker run -d \
    -e ACCESS_KEY=myawskey \
    -e SECRET_KEY=myawssecret \
    -e S3_PATH=s3://my-bucket/backup/ \
    -e 'CRON_SCHEDULE=0 12 * * *' \
    -v /home/user/data:/data:ro \
    oriettaxx/docker-backup-to-s3

Run once then delete the container:

docker run --rm \
    -e ACCESS_KEY=myawskey \
    -e SECRET_KEY=myawssecret \
    -e S3_PATH=s3://my-bucket/backup/ \
    -v /home/user/data:/data:ro \
    oriettaxx/docker-backup-to-s3 no-cron

Run once to get from S3 then delete the container:

docker run --rm \
    -e ACCESS_KEY=myawskey \
    -e SECRET_KEY=myawssecret \
    -e S3_PATH=s3://my-bucket/backup/ \
    -v /home/user/data:/data:rw \
    oriettaxx/docker-backup-to-s3 get

Run once to delete from s3 then delete the container:

docker run --rm \
    -e ACCESS_KEY=myawskey \
    -e SECRET_KEY=myawssecret \
    -e S3_PATH=s3://my-bucket/backup/ \
    oriettaxx/docker-backup-to-s3 delete

Security considerations: on restore, this opens up permissions on the restored files widely.

About

Docker container that periodically backups files to Amazon S3 using s3cmd and cron

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 76.4%
  • Dockerfile 23.6%