Skip to content

Instantly share code, notes, and snippets.

@panupan
Created October 25, 2011 20:34
Show Gist options
  • Save panupan/1314173 to your computer and use it in GitHub Desktop.
Save panupan/1314173 to your computer and use it in GitHub Desktop.
Mirror all Amazon S3 buckets with daily cron script using s3cmd
#!/bin/bash
BACKUP_DIR='/backups/S3 Mirror/'
BUCKETS=$(s3cmd ls | grep s3 | awk '{ print $3 }')
for i in $BUCKETS; do
CURRENT_DIR=$BACKUP_DIR${i//s3:\/\//}/
echo Mirroring $i to $CURRENT_DIR
mkdir -p "$CURRENT_DIR"
s3cmd sync --verbose --no-check-md5 --recursive --no-delete-removed $i "$CURRENT_DIR"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment