How to recursively upload a folder to S3 using AWS CLI? - Big Data In Real World

How to recursively upload a folder to S3 using AWS CLI?

How to delete an index in Elasticsearch?
June 26, 2023
How to fix unassigned shards issue in Elasticsearch?
July 10, 2023
How to delete an index in Elasticsearch?
June 26, 2023
How to fix unassigned shards issue in Elasticsearch?
July 10, 2023

This is a pretty common requirement and here is the solution.

Solution

Let’s create a bucket named hirw-sample-aws-bucket first.

[osboxes@wk1 ~]$ aws s3 mb s3://hirw-sample-aws-bucket

Use the cp with recursive option to upload the folder named aws to hirw-sample-aws-bucket

[osboxes@wk1 ~]$ aws s3 cp --recursive aws s3://hirw-sample-aws-bucket

----
----
upload: aws/dist/libz.so.1 to s3://hirw-sample-aws-bucket/dist/libz.so.1
upload: aws/dist/math.cpython-37m-x86_64-linux-gnu.so to s3://hirw-sample-aws-bucket/dist/math.cpython-37m-x86_64-linux-gnu.so
upload: aws/dist/termios.cpython-37m-x86_64-linux-gnu.so to s3://hirw-sample-aws-bucket/dist/termios.cpython-37m-x86_64-linux-gnu.so
upload: aws/dist/mmap.cpython-37m-x86_64-linux-gnu.so to s3://hirw-sample-aws-bucket/dist/mmap.cpython-37m-x86_64-linux-gnu.so
upload: aws/dist/select.cpython-37m-x86_64-linux-gnu.so to s3://hirw-sample-aws-bucket/dist/select.cpython-37m-x86_64-linux-gnu.so
upload: aws/install to s3://hirw-sample-aws-bucket/install
upload: aws/dist/zlib.cpython-37m-x86_64-linux-gnu.so to s3://hirw-sample-aws-bucket/dist/zlib.cpython-37m-x86_64-linux-gnu.so
upload: aws/dist/zlib/cpython-37m-x86_64-linux-gnu/soib.cpython-37m-x86_64-linux-gnu.so to s3://hirw-sample-aws-bucket/dist/zlib/cpython-37m-x86_64-linux-gnu/soib.cpython-37m-x86_64-linux-gnu.so
----
----

Now we do a listing on hirw-sample-aws-bucket, we can see all the files and directory under aws inside the bucket.

[osboxes@wk1 ~]$ aws s3 ls s3://hirw-sample-aws-bucket
                           PRE dist/
2020-11-18 18:15:50       1465 README.md
2020-11-18 18:16:08      68271 THIRD_PARTY_LICENSES
2020-11-18 18:17:37       4047 install
Big Data In Real World
Big Data In Real World
We are a group of Big Data engineers who are passionate about Big Data and related Big Data technologies. We have designed, developed, deployed and maintained Big Data applications ranging from batch to real time streaming big data platforms. We have seen a wide range of real world big data problems, implemented some innovative and complex (or simple, depending on how you look at it) solutions.

Comments are closed.

How to recursively upload a folder to S3 using AWS CLI?
This website uses cookies to improve your experience. By using this website you agree to our Data Protection Policy.

Hadoop In Real World is now Big Data In Real World!

X