Backing up Amazon S3 files to local storage
It's always good to have a backup of all your files on local storage.
Usually, it's an easy task.
But if you are using AWS it can be much harder than you expect.
This tutorial will show you how to backup the whole bucket from your AWS account to your local machine using the Command Line Interface (CLI), step by step.
Don't worry, it's pretty simple.
The result is you'll be able to back up all of your Amazon S3 files to your local storage (as pictured in the screenshot below).
Table of Contents
ToggleWhat You'll Need For This Tutorial
1 – AWS account
2 – AWS Command Line Interface
Video tutorial
Configure Command Line Interface (CLI)
1.1 Open command-line interpreter.
1.2 – Enter “aws configure”
1.3 – After that you need to enter the following data:
=> AWS Access Key ID
=> AWS Secret Access Key
=> Default region name
=> Default output format
You can find how to get AWS Access Key ID and AWS Secret Access Key here.
The default region can be chosen by you.
I've entered up “us-east-1”.
Set default output format as “json”.
Configure local folder
2.1 – You need to choose a folder where you want to save your files.
To go to the subfolder you need to enter “cd FOLDERNAME”, to go back “cd ../”.
2.2 – When you choose the folder you will see it in command line.
Backup files
3.1 – To backup files you need to enter “aws s3 sync s3://yourbucket .”
3.2 – After that you will see the backup process.
3.3 – Go to the folder you chose and check if all files were transferred.
That's all.
You can now back up any bucket from your AWS server and get the files onto your local hard drive. 🙂
Nice one! Thanks! Any chance to have a tutorial how to restore files from local backup to s3? Are all file rights included there? Thanks
Hello Niko,
Thank you for the feedback.
You can upload it manually using the inner interface.
But if you want to save all rights you need to use the S3 console.
I will try to create a tutorial sometime.
But meanwhile, you can check how to do it in S3 documentation: https://docs.aws.amazon.com/AmazonS3/latest/userguide/upload-objects.html
If you’ll have any questions, I’m always glad to help you.