S3 cli usage examples

Once install of aws client is in place and you have

  • Access key
  • Secret key

https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html

Have your user with keys;

After that you should be able to use

Make bucket (create)
aws s3 mb s3://demo-bucket --endpoint-url=https://object.peakox.com

Remove bucket
aws s3 rb s3://demo-bucket --endpoint-url=https://object.peakox.com

Option: –force

List stuff
aws s3 ls --endpoint-url=https://object.peakox.com

aws s3 ls s3://demo-bucket --endpoint-url=https://object.peakox.com

aws s3 ls s3://demo-bucket --endpoint-url=https://object.peakox.com --recursive --human-readable --summarize

Copy stuff to and from bucket
aws s3 cp s3://demo-bucket --endpoint-url=https://object.peakox.com

aws s3 cp s3://demo-bucket --endpoint-url=https://object.peakox.com --recursive

aws s3 cp s3://demo-bucket/ --endpoint-url=https://object.peakox.com

Same for mv, rm

Sync buckets
aws s3 sync s3://demo-bucket s3://backupbucket-new --endpoint-url=https://object.peakox.com

Can also do local folders

Config locations
~/.aws/config

~/.aws/credentials

How to use in your code
https://docs.aws.amazon.com/code-library/latest/ug/python_3_s3_code_examples.html