Backing up your data to S3 using the AWS CLI
AWS S3 is an ideal place to back up your data as it is infinitely scalable and can store and retrieve any amount of data. This section will show you how to use the AWS Command Line interface (CLI) (which we set up in Chapter 1, Setting up the AWS Environment) to access S3. We will build our script for backing up our files and easily retrieving them as needed. We will then add this script in cron to schedule tasks at regular intervals—for example, 5 minutes, which means that our script will make a backup of our files every 5 minutes. These are the steps we need to follow:
- The first step is to create the bucket. This is an optional step; if you already have a bucket created you can use it. To create a new bucket named
my-backup-bucket-master-aws-system-administration
, we need to pass themb
(make bucket) option to thes3
command:$ aws s3 mb s3://my-backup-bucket-master-aws-system-administration make_bucket: my-backup-bucket...