Storage & backups

s3cmd

1 min read

s3cmd is a lightweight command-line S3 client for Linux and macOS. It is convenient for simple uploads, downloads and sync on servers.

Installation

sudo apt install s3cmd        # Ubuntu, Debian
sudo dnf install s3cmd        # Rocky Linux, AlmaLinux (EPEL)
pip install s3cmd             # any system with Python

Configuration

Create the ~/.s3cfg file:

[default]
access_key = <Access Key>
secret_key = <Secret Key>
host_base = s3.uzcstorage.uz
host_bucket = s3.uzcstorage.uz
bucket_location = default
use_https = True
signature_v2 = False

Restrict access to the file, since it contains the keys:

chmod 600 ~/.s3cfg

Note

host_bucket = s3.uzcstorage.uz (without %(bucket)s) enables path-style addressing.

Working with Files

s3cmd ls                                   # list buckets
s3cmd ls s3://my-bucket/                   # list objects
s3cmd put report.pdf s3://my-bucket/docs/  # upload
s3cmd get s3://my-bucket/docs/report.pdf   # download
s3cmd sync ./backups/ s3://my-bucket/backups/   # sync a folder
s3cmd del s3://my-bucket/docs/report.pdf   # delete
s3cmd du -H s3://my-bucket                 # bucket size

Create a temporary link to an object, valid for one hour:

s3cmd signurl s3://my-bucket/docs/report.pdf +3600

Tip

See also: