Hello everyone, welcome to Linux Tutorial Blog. Today I am going to show you how I backup to Amazon S3 from Debian Linux. On my previous tutorial, I have shown the similar tutorial to backup to Amazon S3 using third party software called Syncovery on a Linux Server. But today, we will not use any graphical application like Syncovery. We will backup to Amazon S3 using AWS CLI. AWS CLI (Command Line Interface) is a free command line program to communicate with Amazon AWS Console.
Backup Planning
We are going to backup Documents folder inside a user’s home directory to Amazon S3. We will use the sync command to do this backup job.
Steps to Backup to Amazon S3 using AWS CLI
Before we continue to the backup process. Make sure you install AWS CLI on your Linux distribution. You may interested on this post, How to install AWS CLI on Debian.
Lets start.
The following example will sync my Documents directory to my Amazon S3 bucket
aws s3 sync ~/dhani/Documents/ s3://personal-database/Documents_Backup/ --dryrun
The dryrun options will simulate the sync process. It will not copy anything to Amazon S3. If there is no error, we can continue to perform the actual backup process.
aws s3 sync Documents/ s3://personal-database/Documents_Backup/
The command will start copying files from local directory to my Amazon S3 bucket. On your Terminal you will see the uploading progress as follow
To check the content of the Amazon S3 bucket, use the ls command as follow
aws s3 ls your-bucket-name
This is a great solution if you are looking for a low cost cloud backup solution for Linux. We can synchronize our data from Linux to Amazon S3 without having to purchase any third party software. With a little works we can put our backup in the cloud.
How to Restore or copy data from Amazon S3 to Local directory
In case you want to copy the data from your bucket to local directory, use the sync command in the following format
aws s3 sync s3://personal-database/Documents_Backup/ /home/dhani/Documents/
You can then automate this process by creating a cron job on your Linux distribution. The backup job can be executed automatically based on the time you specify on the cron job.
Leave a Reply