Skip to content

Instantly share code, notes, and snippets.

@wimleers
Created January 20, 2011 10:49
Show Gist options
  • Save wimleers/787721 to your computer and use it in GitHub Desktop.
Save wimleers/787721 to your computer and use it in GitHub Desktop.
Script that syncs a directory recursively to Amazon S3 using s3sync.
#!/bin/bash
export AWS_ACCESS_KEY_ID=yourID
export AWS_SECRET_ACCESS_KEY=yourSecret
export AWS_TARGET_BUCKET=DriverPacks_back-up
export AWS_TARGET_DIR=/
export SOURCE_DIR=/data/www/downlodsorigin.driverpacks.net/
export S3SYNC_DIR=/home/wim/scripts/s3sync
export SSL_CERT_DIR=/etc/ssl/certs
LOGFILE=/data/logs/dps-s3-rsync/$(date "+%Y-%m").log
EXCLUDES_COMMON="--exclude lost+found --exclude .ssh --exclude .bash_history"
# Append a header first, so we know when this script was run.
date "+%n%n=====%nSyncing DriverPacks to Amazon S3 at %Y-%m-%d %H:%M:%S" >> $LOGFILE
# Now perform the actual syncing, still appending to the logfile.
ruby $S3SYNC_DIR/s3sync.rb --recursive --verbose --ssl $EXCLUDES_COMMON $SOURCE_DIR $AWS_TARGET_BUCKET:$AWS_TARGET_DIR >> $LOGFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment