s3cmd: Command-Line Tool for S3 Compatible Storage Management

Summary
s3cmd is a powerful command-line tool for managing data in Amazon S3 and other S3-compatible cloud storage services. Written in Python, it provides a robust solution for power users, batch scripts, and automated backups. Its extensive features, including multipart uploads and encryption, make it an essential utility for cloud storage interaction.
Repository Info
Tags
Click on any tag to explore related repositories
Introduction
s3cmd is an official command-line tool and client designed for efficient management of data within Amazon S3 and other S3-compatible cloud storage services, such as Google Cloud Storage or DreamHost DreamObjects. Written in Python and released under the GPLv2 license, it's a free and open-source solution ideal for power users, batch scripts, and automated backup tasks triggered by cron.
Since its initial release in 2008, s3cmd has evolved to include a comprehensive set of features. These capabilities encompass multipart uploads, encryption, incremental backup, S3 sync, ACL and Metadata management, S3 bucket size analysis, and bucket policies, providing robust control over your cloud storage.
Installation
To get started with s3cmd, you'll need Python 2.6 or newer, with Python 3+ supported from version 2 onwards. The primary installation steps involve:
- Register for Amazon AWS / S3: Obtain your Access Key and Secret Key from your AWS account. Ensure any IAM user keys have necessary permissions like
s3:ListAllMyBuckets,s3:GetBucketLocation, ands3:ListBucket. More example policies can be found on the AWS documentation. - Install s3cmd: Refer to the detailed official installation instructions for your specific environment.
- Configure s3cmd: Run
s3cmd --configureand provide your Access Key and Secret Key when prompted. This step creates a~/.s3cfgfile, which can be further customized.
Examples
Here are some fundamental s3cmd commands to help you manage your S3 storage:
- List all your buckets:
s3cmd ls - Create a new bucket:
s3cmd mb s3://my-unique-bucket-nameRemember, bucket names must be globally unique across all S3 users.
- Upload a file:
s3cmd put local-file.txt s3://my-unique-bucket-name/remote-file.txt - Recursively upload a directory:
s3cmd put --recursive local-directory/ s3://my-unique-bucket-name/remote-path/Alternatively, use
syncfor efficient synchronization:s3cmd sync local-directory/ s3://my-unique-bucket-name/remote-path/ - List contents of a bucket (recursively):
s3cmd ls --recursive s3://my-unique-bucket-name - Download a file:
s3cmd get s3://my-unique-bucket-name/remote-file.txt local-destination.txt - Recursively download a directory:
s3cmd get --recursive s3://my-unique-bucket-name/remote-path/ local-destination-directory/ - Delete a file:
s3cmd del s3://my-unique-bucket-name/remote-file.txt - Forcefully remove a bucket and all its contents:
s3cmd rb --force s3://my-unique-bucket-name/Use with caution, as this will permanently delete all data in the bucket.
Why Use s3cmd?
s3cmd stands out as an indispensable tool for several reasons:
- Efficiency: Perform S3 operations quickly and directly from your terminal, ideal for quick tasks and troubleshooting.
- Automation: Its command-line nature makes it perfect for scripting and integrating into automated workflows, such as daily backups via cron jobs.
- Versatility: Beyond Amazon S3, it supports any S3-compatible storage service, offering flexibility in your cloud infrastructure choices.
- Comprehensive Features: From basic file transfers to advanced features like encryption, multipart uploads, and access control, s3cmd provides granular control over your data.
- Open Source: Being open-source and GPLv2 licensed, it's free to use for both commercial and private purposes, backed by a community of contributors.
Links
For more information and to contribute, explore the official resources: