Simple Backup to Amazon S3
A quick guide to backing up on Amazon S3 Ensure you have the AWS command-line utilities downloaded:
# sudo yum install python-pip
# sudo pip install awscli
# aws configure
Attach a User Policy granting access to your S3 Bucket
{
"Statement" : [
{
"Action" : [
"s3:*"
],
"Effect" : "Allow",
"Resource" : [
"arn:aws:s3:::YourBucketName",
"arn:aws:s3:::YourBucketName/*"
],
"Sid" : "Stmt1423022883000"
}
],
"Version" : "2012-10-17"
}
Attach another User Policy granting access to list all buckets:
{
"Statement" : [
{
"Action" : "s3:ListAllMyBuckets",
"Effect" : "Allow",
"Resource" : "arn:aws:s3:::*"
}
]
}
For added protection, you can enable SSE (Server-Side Encryption with Amazon S3). Go to your bucket in the AWS console, then under Properties->Permissions->Edit Bucket Policy, add the following policy:
{
"Id" : "PutObjPolicy",
"Statement" : [
{
"Action" : "s3:PutObject",
"Condition" : {
"StringNotEquals" : {
"s3:x-amz-server-side-encryption" : "AES256"
}
},
"Effect" : "Deny",
"Principal" : "*",
"Resource" : "arn:aws:s3:::YourBucketName/*",
"Sid" : "DenyUnEncryptedObjectUploads"
}
],
"Version" : "2012-10-17"
}
Now Sync
# aws s3 sync /my/local/directory s3://YourBucketName/
Or sync with SSE
# aws s3 sync --sse /my/local/directory s3://YourBucketName/