Backing up JEDI One Data to AWS

In Part1 we created a zip file of the acquired JEDI One data.  Here we will list the steps needed to setup and store the file in the cloud using Amazon Web Services (AWS), specifically the S3 storage component.  

  1. Create a free AWS account
  2. Create an S3 bucket  Note: Do not activate public access, it is not needed.  Remember your bucket name.
  3. Login to AWS Console
  4. In the upper right hand corner of the console, click on your name and then navigate to:  My Security Credentials -> Access Keys -> Create New Access Key
  5. Download the keys.  You will need both the access key ID and the secret access key.  Keep these handy (and secure).

Now go back to your raspberry Pi terminal window and enter the following:

$sudo apt update
$sudo apt full-upgrade
$sudo pip3 install boto3

 You've just updated your Pi and installed the Amazon AWS library for Python v3.

In your home directory, create a sub-directory called .aws  (don't forget the dot)

$cd ~
$mkdir .aws
$sudo chmod 777 ~/.aws

Create two files under the .aws sub-directory (you can use Text Editor on the Raspberry Pi -> Accessories):

Call this file, credentials (no extension).  Contents of file:

[default]
aws_access_key_id = YOUR_ACCESS_KEY
aws_secret_access_key = YOUR_SECRET_KEY

Make sure you enter in the access and secret keys from step 5 above.

Create a second file under .aws called, config (no extension).  Contents of file:

[default]
region=us-west-2

Enter the appropriate region for your location - Available Regions

To test that you have done all of this correctly, run the following Python code on your Raspberry Pi:

#!/usr/bin/python3
import boto3

s3 = boto3.resource('s3')

for bucket in s3.buckets.all():
print(bucket.name)

 This will list all the buckets you have by name, like this (I only have one):

boto3-bucket-dir.jpg

Now to write the backup file from Part 1 to the cloud bucket, run this Python code:

#!/usr/bin/python3
import boto3

target_bucket = "drm-test-jedi-one"
source_filename = "/home/pi/jedi/backup33.zip"
target_filename = "backup33.zip"

s3 = boto3.resource('s3')
try:
f = open(source_filename, 'rb')
except OSError:
print('cannot open', source_filename)
else:
s3.Bucket(target_bucket).put_object(Key=target_filename, Body=f)
f.close()

 If all goes well, it will just return the shell prompt:

write-bucket.jpg

Finally go to your AWS console and check for the file (select Storage S3 -> bucket name):

file-on-aws.jpg

Congratulations, your data zip-file is now stored in the cloud.

 

 

 

 

 

 

Was this article helpful?
0 out of 0 found this helpful