Skip to content
Welcome To Charanjit Cheema Blog

Welcome To Charanjit Cheema Blog

An Open Source and Cloud Blog

Menu
  • Home
  • About Me!
  • Way to my Technical Blog
  • Contact me
  • Privacy Policy
Menu

How to backup Linux machine to Amazon S3

Posted on February 11, 2019 by Charanjit Cheema

AWS Amazon S3 is a Simple Cloud object storage solution provided by Amazon. Have a look below what Amazon write and say about S3:

Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance. This means customers of all sizes and industries can use it to store and protect any amount of data for a range of use cases, such as websites, mobile applications, backup and restore, archive, enterprise applications, IoT devices, and big data analytics. Amazon S3 provides easy-to-use management features so you can organize your data and configure finely-tuned access controls to meet your specific business, organizational, and compliance requirements. Amazon S3 is designed for 99.999999999% (11 9’s) of durability, and stores data for millions of applications for companies all around the world.

Short Introduction of Amazon S3. Click on this Link to read more.

Amazon S3 has multiple features, applications and can be used with different technologies but can we use Amazon S3 storage solution as a cloud backup solution for Linux machine? Answer is Yes, we can. Because of contribution of many developers and companies world wide to opensource or FOSS it almost possible to address our requirement.
Here I will use s3cmd plugin for accessing S3 bucket  as a Cloud Storage media from my Ubuntu 16.04 LTS Linux machine which is in my premises. The s3cmd is an opensource plugin and can be download from here.
Prerequisite of installing s3cmd plugin
  • Create AWS user account: 

AWS user account Access Key and Secret access key will be responsible for providing S3 bucket access through s3cmd plugin inside Linux machine.  All you need to do now is to create a user and add it to the group you created.  For that Go to Services of AWS select IAM. Select Users from the panel on the left, and click Add User. Choose any username you like(In below reference screenshot I am creating s3_linux_user), under access type make sure Programmatic Access and Allow Management Console Access is selected and click Next: Permissions. On the next page select the group you created and click on Next: Review. AWS will confirm that you’re adding this user to the selected group and confirm the permissions being granted. Click on Create User to move on to the next page. You’ll now see an Access key ID and a Secret access key. These are self-generated and only displayed  once. You can either copy and paste them to a secure location, or click Download .csv which will download a spreadsheet containing these details. This is the equivalent of the username and password that your computer will be using to access S3.

Below are the reference screenshots for these steps:

  • Create S3 Linux machine backup bucket.

For creating Amazon S3 bucket go to Services > Storage > S3. Click on Create bucket button. Chose a globally unique name (lowercase only), pick a region that you would like your bucket to live in. Clicking the Create button will create your Linux machine backup S3 bucket.

 

  • Install the python-setuptools before installing s3cmd plugin.

Execute below command for installing python-setuptools:

sudo apt install python-setuptools
Installation and Configuration of s3cmd plugin
  • Unzip the downloaded s3cmd zip file in your desire directory.

  • Go inside the unzipped s3cmd plugin files and execute the below command for installing the s3cmd plugin:
sudo python setup.py install

  • Post installation now it is time to configure s3cmd plugin so that you can get access of your S3 bucket in Linux machine. Run the below command for doing configuration:
s3cmd --configure
  • Above command will prompt to enter a few details. First of all it will prompt to enter your Access key ID followed by your Secret access key (these details can be available in user detail under IAM service in AWS console). Leave the rest settings as default by just hitting the enter key, except the Encryption setting. Here you need to put password so that data sent in and out of S3 in encrypted form. Encryption of data transmission is necessary for preventing Man in Middle attack.
  • Post configuration it will prompt you to test the connection with AWS S3.

  • You can also test by listing s3 bucket with below command post configuration:
s3cmd ls

Testing Linux machine backup to S3 bucket

  • Now it is time to test Linux machine backup to S3 bucket. In below demonstration I have created two test files which I have taken backup to my S3 bucket. I have used below s3cmd sync command for syncing Backup to my S3 bucket:

  • Same synced backup files you can see in my AWS S3 console as well:

To restore lost data in Linux machine from S3 Bucket

In case of data loss in your Linux machine you can use same s3cmd sync command for restoring lost data from Amazon S3 storage bucket. In this below demonstration you can see with the help of same s3cmd sync command I have restored the accidentally removed data in my Linux machine from my S3 backup bucket:

 

Conclusion 

In my this blog you have seen Amazon S3 can be prove very cost effective and robust Backup storage in AWS Cloud. You can use Amazon S3 as a Backup storage for your Linux machines infrastructure which are available in your premises.

 

Good to read more about Amazon S3:

https://docs.aws.amazon.com/AmazonS3/latest/dev/Welcome.html

Loading

  • Author
  • Recent Posts
Charanjit Cheema
Follow him
Charanjit Cheema
Charanjit is currently working as a Cloud Architect at Mphasis, with 17 years of experience in IT infrastructure projects, implementation, and support. While his main role is as a DevOps engineer, he holds a Cloud Architect position and has strong skills in cloud technologies and automation. His expertise includes Terraform, Ansible, AWS, Azure DevOps, Azure Cloud, VMware, and Linux systems.

Charanjit is passionate about automating tasks and improving processes. He uses tools like Terraform and Azure DevOps to build and manage cloud infrastructure and streamline deployment. He also enjoys using Shell scripts and Ansible playbooks to make systems run more efficiently.

In his free time, Charanjit enjoys learning about new technologies and sharing his knowledge through his blog. When he’s not working, he likes listening to music, having a cup of coffee, and relaxing in nature.

You can connect with Charanjit on Twitter, Facebook, LinkedIn, or email him at charanjit.cheema@cjcheema.com.
Charanjit Cheema
Follow him
Latest posts by Charanjit Cheema (see all)
  • How to optimize the performance of Ansible Automation Platform or Ansible Tower - July 16, 2023
  • How to fix code and text file linting errors with the help of Visual Studio Code - June 27, 2023
  • How to migrate existing WordPress blog from AWS EC2 instance to Amazon Lightsail - May 29, 2023

Like this:

Like Loading...

Related

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Tags

AWS Cloud Computing Dockers Networking Open Networking OpenSource RHEL-CentOS SDN Server Hardware SLES tcpdump Ubuntu WSL

Follow me @

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 2 other subscribers

Recent Posts

  • How to Deploy Docker Containers with NGINX on AWS EC2 Using Ansible and GitHub Actions
  • No More DynamoDB! Use Native S3 locking for Terraform State
  • How to Bring and Manage Manually Created AWS Resources Under Terraform Management
  • Iterating Cloud Resource Provisioning Using Terraform Count and For_Each Meta-Arguments
  • Terraform and Ansible Collaboration for AWS Cloud Deployment

Recent Comments

  1. Charanjit Singh on Terraform and Ansible Collaboration for AWS Cloud Deployment
  2. christinatodd2020aeaa798563 on Terraform and Ansible Collaboration for AWS Cloud Deployment
  3. Charanjit Singh on How to Set password policy in CentOS or RHEL system
  4. SAURABH on How to recover or rebuild initramfs in CentOS 7 Linux
  5. Sangita on How to Set password policy in CentOS or RHEL system

Archives

  • April 2025
  • February 2025
  • January 2025
  • August 2024
  • July 2024
  • June 2024
  • January 2024
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • September 2022
  • August 2022
  • July 2020
  • May 2020
  • February 2020
  • November 2019
  • June 2019
  • May 2019
  • March 2019
  • February 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • June 2018
  • May 2018
  • April 2018

Categories

  • Automation
  • Cloud Computing
  • Coding
  • CyberSecurity
  • Networking
  • OpenSource
  • RHEL-CentOS
  • Server Hardware
  • SLES
  • Technical Blog
  • Ubuntu
  • WSL

Blog Stats

  • 18,353 hits
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Home
  • About Me!
  • Way to my Technical Blog
  • Contact me
  • Privacy Policy
© 2025 Welcome To Charanjit Cheema Blog | Powered by Superbs Personal Blog theme
Menu
  • Home
  • About Me!
  • Way to my Technical Blog
  • Contact me
  • Privacy Policy
 

Loading Comments...
 

    %d