Jothir wrote great blog post
, introducing MEB's "Backup to Cloud"
feature. And while this blog post is great source of information for Amazon users who consider using MEB it is not so clear how to setup the cloud storage itself for those MEB users who are only considering storing backups in the Cloud. I actually was one of them and decided to share my experience.
OK, so what do you need to start using MEB with Amazon S3 service?
- Amazon AWS account. You can register it for free at https://portal.aws.amazon.com/gp/aws/developer/registration/index.html
- A bucket where backup image will be stored. To create it, choose S3 service under "Services" menu, then click "Create Bucket" button and enter the name. You will pass this name to --cloud-bucket option.
- Access key and secret access key for a user which will connect to AWS. You can use root user for such purpose or create a special one. Latter option is the safest. To create a user choose "AIM" service, then "Manage Users" under "Create individual AIM users" tab, then click "Create new users" and enter user names. After you created a user you will have an option to see its security credentials. It will be somethiing like this:
Access Key ID:
Secret Access Key:
You will pass "Access Key ID" to --cloud-access-key-id option and "Secret Access Key" to --cloud-secret-access-key option.
- After you created a user you need to grant necessary permissions to it. There are many ways to manage AWS user permissions, but for our test we can choose simplest way: click on "Attach User Policy" button under "User Policies" part, then select "Amazon S3 Full Access". We are ready to try backup now.
- To summarize, following Cloud options are required:
--cloud-service=s3 - it is always s3 and must be specified
--cloud-aws-region='us-west-2' - here is the tricky part: you could specify different region when created the bucket, but default region should be used, so AWS is able to find the bucket
--cloud-bucket=ourbucket - name of the bucket
--cloud-access-key-id=AKIAJ2DK2OBDEGQSBGSQ - access key ID
--cloud-secret-access-key=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 - Secret Access Key
--cloud-object-key=test - any name: this will be name of the image in the bucket
- Add common MEB options, such as:
--backup-image=- - so we are storing in stdout
backup-to-image - this is not an option, but the command =)
- Our final command is:
$mysqlbackup --cloud-service=s3 --cloud-aws-region='us-west-2' \
--cloud-bucket=ourbucket --cloud-access-key-id=AKIAJ2DK2OBDEGQSBGSQ \
--cloud-object-key=test --backup-dir=/home/sveta/BACKUPDIR/cloud_test \
Here is the cloud operation part of the MEB output:
Uploading part %:10 20 30 40 50 60 70 80 90
mysqlbackup: INFO: Finalizing data upload.
mysqlbackup: INFO: Cloud operation complete.
You can see the file in your bucket using AWS console.
Nice thing is that you don't need to care about URLs, remote streaming and things like this: MEB will take care about everything itself.