Skip to content

Instantly share code, notes, and snippets.

@arthuralvim
Forked from niraj-shah/s3cmd_sync.sh
Last active September 1, 2015 20:44
Show Gist options
  • Save arthuralvim/7361d8281f30e2e37a0f to your computer and use it in GitHub Desktop.
Save arthuralvim/7361d8281f30e2e37a0f to your computer and use it in GitHub Desktop.
Downloading files from S3.
# Installation
wget -O- -q http://s3tools.org/repo/deb-all/stable/s3tools.key | sudo apt-key add -
sudo wget -O/etc/apt/sources.list.d/s3tools.list http://s3tools.org/repo/deb-all/stable/s3tools.list
sudo apt-get update && sudo apt-get install s3cmd
# Configuration
s3cmd --configure
# Requirements
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
ENCRIPTION_PASSWORD
# Command Line to run from terminal
# Logs result to file s3_backup.log
# Command will run in the background
s3cmd sync -v --dry-run --skip-existing /path/to/folder/ s3://s3-bucket/folder/ > s3_backup.log 2>&1 &
# from local to s3
s3cmd sync -v /path/to/folder/ s3://s3-bucket/folder/ > s3_backup.log 2>&1 &
# from s3 to local
s3cmd sync -v s3://s3-bucket/folder/ /path/to/folder/ > s3_backup.log 2>&1 &
# Crontab command to sync folder to S3
# Command will run 1am every day and logs result to /root/s3_backup.log
0 1 * * * /usr/bin/s3cmd sync -rv /path/to/folder/ s3://s3-bucket/folder/ >> /root/s3_backup.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment