Skip to content

Instantly share code, notes, and snippets.

@copernicus
Forked from panupan/s3mirror.sh
Created December 10, 2011 05:37
Show Gist options
  • Save copernicus/1454647 to your computer and use it in GitHub Desktop.
Save copernicus/1454647 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 $i "$CURRENT_DIR"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment