to Amazon S3 using the AWS CLI

In this tutorial we are going to help you use the AWS Command Line Interface (CLI) to access Amazon S3. We will do this and then you can easily build your ain scripts for backing up your files to the cloud and easily call up them as needed. This will brand automating your backup procedure faster, more than reliable, and more programmatic. Y'all can use this information to build a scheduled job (or cron job) to handle your backup operations.

Note: This tutorial builds upon the concepts from the Backing Upwards Your Files to Amazon S3 tutorial. If you haven't done that tutorial yet, you should complete that tutorial first.

In this pace, using the IAM service you lot will create a user business relationship with administrative permission. In subsequently steps you will use this user business relationship to securely access AWS services using the AWS CLI.

a.  When you click here, the AWS direction console will open in a new browser window, so you can proceed this step-by-step guide open. When this screen loads, enter your user proper noun and password to get started. Then blazon IAM in the search bar and select IAM to open the Identity and Admission Management dashboard.

TMT_S3-CLI_00

(click to enlarge)

TMT_S3-CLI_00

b. From the AWS Identity and Access Management dashboard, click on Users on the left side.

TMT_S3-CLI_01

(click to overstate)

TMT_S3-CLI_01

c. Click the Add user push button.

TMT_S3-CLI_02

(click to expand)

TMT_S3-CLI_02

d. Enter a user name in the textbox next to User proper name: (we'll employ AWS_Admin for this example) and select Programmatic access in the Select AWS Access Blazon section. Click the Next: Permissions button.

TMT_S3-CLI_03

(click to expand)

TMT_S3-CLI_03

eastward. Click on Attach existing policies directly selection. Select AdministratorAccess then click Side by side: Review.

TMT_S3-CLI_04

(click to expand)

TMT_S3-CLI_04

TMT_S3-CLI_05

(click to expand)

TMT_S3-CLI_05

one thousand. Click the Download Credentials button and salve the credentials.csv file in a safe location (you'll demand this later in footstep 3) and so click the Close button.

TMT_S3-CLI_06

(click to expand)

TMT_S3-CLI_06

Now that you accept your IAM user, y'all need to install the AWS Control Line Interface (CLI). Below are instructions based on the kind of operating system you are using; please select the tab that corresponds to your operating arrangement.

Select PC from the tabs below if you are using a Windows-based computer.

Select Mac/Linux from the tabs beneath if you are using a machine running OSX or Linux.

  • PC

    a. Download and run the Windows installer (64-bit, 32-bit).

    Note: users of Windows Server 2008 v6.0.6002 you volition need to employ a unlike install method listed here.

    b. Open up a command prompt past pressing the Windows Key + r to open the run box and enter cmd and press the OK push button.

    Getting-Started-S3-CLI-Run-Win

    (click to expand)

    Getting-Started-S3-CLI-Run-Win

    c. Blazon aws configure and press enter. When prompted, enter the following:

    AWS Access Key ID [None]: enter the Admission Key Id from the credentials.csv file yous downloaded in stride one part d

    Note: this should look something like AKIAPWINCOKAO3U4FWTN

    AWS Hugger-mugger Access Key [None]: enter the Hole-and-corner Access Key from the credentials.csv file you downloaded in step 1 part d

    Note: this should await something like 5dqQFBaGuPNf5z7NhFrgou4V5JJNaWPy1XFzBfX3

    Default region name [None]: enter us-due east-1

    Default output format [None]: enter json

    Getting-Started-S3-CLI-Config-Win

    (click to expand)

    Getting-Started-S3-CLI-Config-Win

  • Mac / Linux

    b. OSX users: Open a last window by pressing Control + Space and typing terminal in the search window. Then press enter to open the terminal window.

    Linux users

    : Open a last window.

    Getting-Started-CLI-OSX1

    (click to expand)

    Getting-Started-CLI-OSX1

    c. Blazon aws configure and press enter. Enter the following when prompted:

    AWS Access Key ID [None]: enter the Access Cardinal Id from the credentials.csv file yous downloaded in stride one part d

    Note: this should look something like AKIAPWINCOKAO3U4FWTN

    AWS Secret Admission Central [None]: enter the Hush-hush Admission Key from the credentials.csv file you downloaded in step ane function d

    Note: this should look something similar 5dqQFBaGuPNf5z7NhFrgou4V5JJNaWPy1XFzBfX3

    Default region name [None]: enter united states of america-east-1

    Default output format [None]: enter json

    Getting-Started-CLI-Config-OSX

    (click to expand)

    Getting-Started-CLI-Config-OSX

In this step, you volition use the AWS CLI to create a bucket in S3 and copy a file to the bucket.

a. Creating a bucket is optional if yous already have a bucket created that y'all want to use. To create a new saucepan named my-first-fill-in-bucket blazon:

aws s3 mb s3://my-starting time-backup-bucket

Annotation: bucket naming has some restrictions; 1 of those restrictions is that saucepan names must be globally unique (e.g. two different AWS users tin can not take the aforementioned bucket proper noun); because of this, if you lot try the control to a higher place you will become a BucketAlreadyExists fault.

Getting-Started-S3-Create-Buscket-OSX

(click to expand)

Getting-Started-S3-Create-Buscket-OSX

b. To upload the file my first backup.bak located in the local directory (C:\users) to the S3 bucket my-commencement-fill-in-bucket, yous would utilize the following command:

aws s3 cp "C:\users\my first backup.bak" s3://my-first-backup-bucket/

Or, apply the original syntax if the filename contains no spaces.

Getting-Started-S3-Upload-OSX

(click to enlarge)

Getting-Started-S3-Upload-OSX

c. To download my-first-backup.bak from S3 to the local directory nosotros would opposite the gild of the commands as follows:

aws s3 cp s3://my-first-fill-in-bucket/my-start-fill-in.bak ./

Getting-Started-S3-Restore-OSX

(click to enlarge)

Getting-Started-S3-Restore-OSX

d. To delete my-first-fill-in.bak from yourmy-first-backup-saucepan bucket, employ the following control:

aws s3 rm s3://my-first-backup-saucepan/my-first-backup.bak

Getting-Started-S3-Delete-OSX

(click to enlarge)

Getting-Started-S3-Delete-OSX

Congratulations! You have gear up upwardly an IAM user, configured your machine for use with the AWS command line interface and you have learned how to create, copy, think, and delete files from the cloud. In the next tutorial you'll larn how to ready a virtual tape drive for use in backing up file from an existing backup program like Veeam, Symantec Backup Exec, Microsoft Organisation Center 2012 Data Protection Managing director, or other support programs.

Learn how to create a Virtual Tape Library and employ it with your existing backup software »