Sunday, October 28, 2018

thumbnail

S3cmd : Command Line S3 Client and Backup for Linux


Amazon S3 is a reasonably priced data storage service. Ideal for off-site file backups, file archiving, web hosting and other data storage needs. It is generally more reliable than your regular web hosting for storing your files and images.


S3cmd is a free command line tool and client for uploading, retrieving and managing data in Amazon S3 and other cloud storage service providers that use the S3 protocol, such as Google Cloud Storage or DreamHost DreamObjects. It is best suited for power users who are familiar with command line programs. It is also ideal for batch scripts and automated backup to S3, triggered from cron, etc. This article will help you to install s3cmd on CentOS/RHEL.


I will show simple steps to enable s3cmd on your host system through which you can upload your backup files to amazon s3 bucket.


Install s3cmd

yum install s3cmd

Configure s3cmd Environment

In order to configure s3cmd we would require Access Key and Secret Key of your S3 Amazon account. Get these security keys from aws securityCredentials page. If will prompt to login to your amazon account.

After getting key files, use below commands to configure s3cmd:

export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
s3cmd --configure

Uses of s3cmd Command Line

1. List All S3 Bucket

s3cmd ls

2. Creating New Bucket

s3cmd mb s3://bucketname

3. Uploading file in Bucket

s3cmd put /path/to/file s3://bucketname/

4. Uploading directory in Bucket

s3cmd put -r /path/to/directory s3://bucketname/

5. Syncing file/folder in Bucket

s3cmd sync -r File_or_folder s3://Buckt_name/

6. Listing data of S3 Bucket

s3cmd ls s3://bucketname/

7. Download file from S3 Bucket

s3cmd get s3://bucketname/path/to/file

8. Remove Data of S3 Bucket

s3cmd del s3://bucketname/path/to/file_or_folder

9. Remove S3 Bucket

(Before removing bucket make sure it is empty)
s3cmd rb s3://bucketname

Subscribe by Email

Follow Updates Articles from This Blog via Email

No Comments

Search This Blog

Powered by Blogger.